Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@bijujoseph/ng2-nvd3
Advanced tools
Angular2 component for NVD3.js reusable charting library, a fork from https://github.com/jrmce/ng2-nvd3
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.
Online demos:
npm install ng2-nvd3
it requires angular2
, d3
and nvd3
as dependencies. Tested with the current @angular
version ^2.0.0-rc.4
.
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
}
]
}
];
}
}
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()
}
}
npm test
resizeTimeout
to control how frequently the chart.update
should be done.ngOnChanges
to call updateWithData
when data
is changed.MIT
FAQs
Angular2 component for NVD3.js reusable charting library, a fork from https://github.com/jrmce/ng2-nvd3
We found that @bijujoseph/ng2-nvd3 demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.