Created
May 3, 2016 17:21
-
-
Save teguhn/87b4677f62b4a8e5fc1ad2900c6e7014 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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