chart.setData()

Method Definition: setData (Object data)
Parent: Chart
Description: setData() function used to set DataSeries in the Chart. Where each DataSeries holds one or more number of DataPoints

setData() function used to set DataSeries in the Chart. Where each DataSeries holds one or more number of DataPoints.

chart.render() must be called to initiate the drawing of the Chart after setting data using setData() function.

Function Parameters/Arguments
data
- Array of DataSeries where each DataSeries can hold many DataPoints

Pseudo code
                      
var chart = new Cosfire.Chart("chart-container", {....});

let aDataSeries = { plotAs: "bar",
                    points: [{ xLabel: "January", y: 3550 },
                      { xLabel: "February", y: 3000},
                      { xLabel: "March", y: 8550},
                      { xLabel: "April", y: 5900},
                      { xLabel: "May", y: 6500},
                      { xLabel: "June", y: 4550}]
                  };
// Set Data. Setting Array of DataSeries
chart.setData([aDataSeries]);

chart.render(function onRenderCompleted() {
  // chart rendered
}));                  
                  
Let us checkout the example below. Here in the example there is only one DataSeries of type "Bar" and there are 6 DataPoints in it. DataPoints are set through points property of DataSeries. We add more than one DataSeries to create multi-series Chart very easily.