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

@bijujoseph/ng2-nvd3

v1.2.1

Published

Angular2 component for NVD3.js reusable charting library, a fork from https://github.com/jrmce/ng2-nvd3

Downloads

6

Readme

ng2-nvd3

Build Status NPM Version

Angular2 component for nvd3. It has similar technique as angular-nvd3 for angular 1, but designed for angular 2 and without extra features (like extended mode) you won't need.

Demos

Online demos:

  1. web page
  2. plnkr

Install

npm install ng2-nvd3

it requires angular2, d3 and nvd3 as dependencies. Tested with the current @angular version ^2.0.0-rc.4.

Basic usage

Simple bar chart

Note: d3 and nvd3 should be also included in your project bundle.

Simple discrete bar chart:

import {Component, OnInit} from '@angular/core';
import {nvD3} from 'ng2-nvd3'
declare let d3: any;

@Component({
  selector: 'main',
  directives: [nvD3],
  template: `
    <div>
      <nvd3 [options]="options" [data]="data"></nvd3>
    </div>
  `
})

export class Main implements OnInit{
  options;
  data;
  ngOnInit(){
    this.options = {
      resizeTimeout:300,  
      chart: {
        type: 'discreteBarChart',
        height: 450,
        margin : {
          top: 20,
          right: 20,
          bottom: 50,
          left: 55
        },
        x: function(d){return d.label;},
        y: function(d){return d.value;},
        showValues: true,
        valueFormat: function(d){
          return d3.format(',.4f')(d);
        },
        duration: 500,
        xAxis: {
          axisLabel: 'X Axis'
        },
        yAxis: {
          axisLabel: 'Y Axis',
          axisLabelDistance: -10
        }
      }
    }
    this.data = [
      {
        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
          }
        ]
      }
    ];
  }

}

Usage directive api

No need to use api as in angular 1 case. We can get access to directive instance from parent component via @ViewChild:

import {Component, OnInit, AfterViewInit, ViewChild} from '@angular/core';
import {nvD3} from 'ng2-nvd3';

@Component({
  selector: 'main',
  directives: [nvD3],
  template: `<div><nvd3 [options]="options" [data]="data"></nvd3></div>`
})
export class Main {
  options;
  data;

  @ViewChild(nvD3)
  nvD3: nvD3;

  ngOnInit(){
    this.options = {...};
    this.data = [...];
  }

  ngAfterViewInit() {
    // this.nvD3 - directive instance
    // for example, to update the chart
    this.nvD3.chart.update()
  } 
}

Tests

npm test

Change Log

1.1.3 (master)

  • Angular2 - v2.0.0-rc4

1.1.2

  • Angular2 - v2.0.0-rc3

1.1.1

  • Angular2 - v2.0.0-rc2

1.1.0

  • Angular2 - v2.0.0-rc1

1.0.7

  • Angular2 - v2.0.0-beta.3

1.1.8

  • Angular2 - v2.4.0
  • Angular modules support
  • AOT support

1.2.0

  • Added property resizeTimeout to control how frequently the chart.update should be done.
  • Update ngOnChanges to call updateWithData when data is changed.

License

MIT