Database Reference
In-Depth Information
The datum command is used because NVD3 works with series rather than
data, much like shape generators. Using series also allows for the definition
of a series title and a specific series color as shown in the preceding code.
The values are initially blank, but because JavaScript is a reference-based
language the array can be updated later without having to reset the data
element. After the chart is defined, updating it when the data array is
modified is as simple as calling the update command:
$(document).on('data:'+name,function(event,data) {
values.push(data);
if(values.length >= dataLen) values.shift();
chart.update();
});
NVD3's interfaces are fairly standard, which makes switching chart types a
breeze.Toaddthelinechartvisualizationinsteadofabarchartvisualization
to Figure 7.10 , a single line of implementation was changed:
var chart = nv.models.lineChart()
Figure 7.10
The data series for the line chart has an optional area parameter that
can be used to make the line chart an area chart. This standardization of
parameters makes it extremely simple to experiment with different forms of
visualization. It is also trivial to render multiple series in the same chart by
simply modifying the datum statement.
 
Search WWH ::




Custom Search