Line Chart with View Finder

Source Code

 1 nv.addGraph(function() {
 2   var chart = nv.models.lineWithFocusChart();
 3 
 4   chart.xAxis
 5       .tickFormat(d3.format(',f'));
 6 
 7   chart.yAxis
 8       .tickFormat(d3.format(',.2f'));
 9 
10   chart.y2Axis
11       .tickFormat(d3.format(',.2f'));
12 
13   d3.select('#chart svg')
14       .datum(testData())
15     .transition().duration(500)
16       .call(chart);
17 
18   nv.utils.windowResize(chart.update);
19 
20   return chart;
21 });
22 
23 
24 
25 /**************************************
26  * Simple test data generator
27  */
28 
29 function testData() {
30   return stream_layers(3,128,.1).map(function(data, i) {
31     return { 
32       key: 'Stream' + i,
33       values: data
34     };
35   });
36 }
comments powered by Disqus