I am trying to create a chart using anystock that will read data from a csv file. Using the built in anychart.data.loadCsvFile function doesn't give me a working chart for a stock chart while it was working just fine for a line chart. I think I need the csv file to be loaded into a properly formatted table. Is there a function for that?
Here is a sample how to do that, you can avoid creating table if the csv matches the series format and you have no need in mapping: http://jsfiddle.net/3vtszfx0/2/
anychart.onDocumentReady(function () {
anychart.data.loadCsvFile('https://cdn.anychart.com/samples-data/stock-general-features/load-csv-data/data.csv', function (data) {
// create stock chart
chart = anychart.stock();
// create plot
var plot = chart.plot(0);
// create column series on the first plot
var column = plot.column(data);
column.name('MSFT');
// set container id for the chart
chart.container('container');
// initiate chart drawing
chart.draw();
});
});
If you need mapping then: http://jsfiddle.net/3vtszfx0/1/
// create data table on loaded data
var msftDataTable = anychart.data.table();
msftDataTable.addData(data);
mapping = msftDataTable.mapAs({'x': 0, 'value': 1});
// create plot
var plot = chart.plot(0);
// create column series on the first plot
var column = plot.column(mapping);
column.name('MSFT');