npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nvd3-chart

v0.1.5

Published

nvd3-chart angular2+ component

Downloads

25

Readme

nvd3-chart

nvd3-chart Angular 2+ Component

npm version GitHub issues Package Quality Known Vulnerabilities GitHub forks GitHub stars GitHub license

Table of contents

Installation

To install this library, run:

$ npm install nvd3 nvd3-chart --save

Usage

In your any Angular 2 module:

import { NgModule } from '@angular/core';
import { ChartComponent } from './chart.component';

// Import nvd3-chart library
import Nvd3ChartComponent from 'nvd3-chart';

@NgModule({
  declarations: [
    ChartComponent,
    // Specify Nvd3ChartComponent library in declarations
    Nvd3ChartComponent
  ],
  imports: [],
  providers: []
})
export class ChartModule { }

In your any component, in this example ./chart.component.ts

import { Component } from '@angular/core';
import Nvd3ChartComponent from 'nvd3-chart';
import * as nv from 'nvd3';

@Component({
  selector: 'chart-component',
  templateUrl: './chart.component.html'
})
export class ChartComponent {
  chart = {
    scatter: {
      options: {
        models: nv.models.scatter().margin({top: 20, right: 20, bottom: 20, left: 20}).pointSize(function(d) { return d.z }).useVoronoi(false),
        datum: this. randomData()
      }
    },
    sparkline: { 
      options: {
        models: nv.models.sparkline(),
        datum: this.sin()
      }
    },
    discrete: {
      options: {
        models: nv.models.discreteBarChart().x(function(d) { return d.label })
              .y(function(d) { return d.value })
              .staggerLabels(true)
              //.staggerLabels(historicalBarChart[0].values.length > 8)
              .showValues(true)
            .duration(250),
        datum: [
          {
            key: "Cumulative Return",
            values: [
              {
                "label" : "A" ,
                "value" : 29.765957771107
              } ,
              {
                "label" : "B" ,
                "value" : 0
              } ,
              {
                "label" : "C" ,
                "value" : 32.807804682612
              } ,
              {
                "label" : "D" ,
                "value" : 196.45946739256
              } ,
              {
                "label" : "E" ,
                "value" : 0.19434030906893
              } ,
              {
                "label" : "F" ,
                "value" : 98.079782601442
              } ,
              {
                "label" : "G" ,
                "value" : 13.925743130903
              } ,
              {
                "label" : "H" ,
                "value" : 5.1387322875705
              }
            ]
          }
        ]
      }
    }
  };

  constructor() {
  }

  randomData() {
    var data = [];
    for (var i = 0; i < 2; i++) {
      data.push({
        key: 'Group ' + i,
        values: []
      });
      for (var j = 0; j < 100; j++) {
        data[i].values.push({x: Math.random(), y: Math.random(), z: Math.random()});
      }
    }
    return data;
  }

  sin() {
    return () => {
      var sin = [];
      for (var i = 0; i < 100; i++) {
          sin.push({x: i, y: Math.sin(i/10)});
      }
      return sin;
    };
  }
}

and in ./chart.component.html

<!-- You can now use your library component in chart.component.html -->
<div>
  ChartComponent
</div>
<div>
  <h4>
    Chart discrete bar
  </h4>
  <nvd3-chart [options]="chart.discrete.options"></nvd3-chart>
</div>

<div>
  <h4>
    Chart scatter
  </h4>
  <nvd3-chart [options]="chart.scatter.options"></nvd3-chart>
</div>

<div>
  <h4>
    Chart sparkline
  </h4>
  <nvd3-chart [options]="chart.sparkline.options"></nvd3-chart>
</div>

Versioning

Semantic Versioning 2.0.0 http://semver.org/

Given a version number MAJOR.MINOR.PATCH, increment the:
MAJOR version when you make incompatible API changes,
MINOR version when you add functionality in a backwards-compatible manner, and
PATCH version when you make backwards-compatible bug fixes.
Additional labels for pre-release and build metadata are available as extensions to the MAJOR.MINOR.PATCH format.

FAQ
How should I deal with revisions in the 0.y.z initial development phase?

The simplest thing to do is start your initial development release at 0.1.0 and then increment the minor version for each subsequent release.

How do I know when to release 1.0.0?

If your software is being used in production, it should probably already be 1.0.0. If you have a stable API on which users have come to depend, you should be 1.0.0. If you’re worrying a lot about backwards compatibility, you should probably already be 1.0.0.

GIT commit

  • AngularJS Git Commit Message Conventions https://gist.github.com/stephenparish/9941e89d80e2bc58a153
  • http://karma-runner.github.io/0.10/dev/git-commit-msg.html

License

MIT © wwwdev.io