Skip to content

Instantly share code, notes, and snippets.

@teguhn
Created May 3, 2016 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save teguhn/87b4677f62b4a8e5fc1ad2900c6e7014 to your computer and use it in GitHub Desktop.
Save teguhn/87b4677f62b4a8e5fc1ad2900c6e7014 to your computer and use it in GitHub Desktop.
function getCol(data, colname) {
var x = [];
for (var i = 0; i < data.length; i++) {
x.push(data[i][colname]);
}
return x;
}
function xy(data, x_col, y_col) {
return {
x: getCol(data, x_col),
y: getCol(data, y_col)
};
}
Plotly.d3.csv("https://raw.githubusercontent.com/plotly/datasets/master/2014_apple_stock.csv", function(data) {
var container = 'myDiv';
var line1 = xy(data, 'AAPL_x', 'AAPL_y');
line1.mode = 'lines+markers';
var outputData = [line1];
var layout = {
title: 'Plotting CSV data from AJAX call',
xaxis: {
title: 'xaxis'
},
yaxis: {
title: 'yaxis'
}
};
Plotly.newPlot(container, outputData, layout);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment