AngularJS directive for NVD3 reusable charting library (based on D3). Easily customize your charts via JSON API.
AngularJS directive for NVD3 reusable charting library (based on D3). Easily customize your charts via JSON API.
This thing is designed to make it easier to work with nvd3.js re-usable charting library. This directive allows you to easily customize your charts via JSON API.
The key feature is that the original hierarchical structure of nvd3 models is completely preserved in directive JSON structure. This means that while you creating a complex chart that containing multiple elementary chart models (such as line, bar, axis, ...), you can in turn customize the properties of each internal elementary models as well as the global charting properties the way you want. This can be done as usual, but it becomes quite easily to customize while applying JSON approach to.
Try it online.
https://cdnjs.cloudflare.com/ajax/libs/angular-nvd3/1.0.9/angular-nvd3.min.js$ bower install angular-nvd3An angular.js, D3.js and nvd3.js would be installed as a dependency automatically. If it won't for some reason, install it manually:
$ bower install angular
$ bower install d3
$ bower install nvd3Add dependencies to the `` section of your main html:
$ npm install angular-nvd3If you don't use bower or npm, you can manually download and unpack directive with the latest version (zip, tar.gz).
Inject nvd3 directive into angular module, set up some chart options and push some data to the controller:
angular.module('myApp', ['nvd3'])
.controller('myCtrl', function('$scope'){
$scope.options = { /* JSON data */ };
$scope.data = { /* JSON data */ }
})and in html again you can use it like:
The chart would be displayed on the page.
Let's create a simple Discrete Bar Chart.
Configure options:
…Push some data:
$scope.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 }
]
}];See the result.
Read more docs.
Test it using command:
$npm testThen build using grunt (node.js must be installed):
$gruntfocus optionsupdateWithOptions and updateWithData api functionsdebounceImmediate flagzoomend eventindex.jsonReady attributegetElement api methoddeepWatchData = true by defaultautorefresh, deepWatchConfig configsdeepWatchDataDepth = 2 config to specify watch depth level for data: 0 - by reference (cheap), 1 - by collection item (the middle), 2 - by value (expensive)onReady attributeupdateWithTimeout, refreshWithTimeout methods to apirefreshDataOnly = true by defaultzoom & pan functionalitytooltip #222 for interactive guideline.deepWatchData to false by defaultdeepWatchOptions and deepWatchConfig propertiesCandlestick Chart, OHLC Chart, Sunburst Chart, Pox Plot Chartstacked parameterutils module to avoid conflictsclassUnder developing in master (1.x) branch
--
If you use the old nvd3 version (v1.1.15-beta), I recommend you to use an updated assembly (
nv.d3.jsandnv.d3.css, you can find it in thelibdirectory of this project) with some fixes rather than the last one installed via bower.
Under developing in 0.x branch
multiChart$scope.api.getScope().chart)...
Licensed under the terms of the MIT License
No open issues yet, or sync has not completed.