Skip to content

Instantly share code, notes, and snippets.

@bpostlethwaite
Last active August 29, 2015 14:05
Show Gist options
  • Save bpostlethwaite/df4a6100f8a64b29450a to your computer and use it in GitHub Desktop.
Save bpostlethwaite/df4a6100f8a64b29450a to your computer and use it in GitHub Desktop.
post to plotly /datacache endpoint
$(function(){
var payload;
function getPlotlyGraphData() {
return [{x:[1,2,3],y:[2,4,3]},{x:[1,2,3],y:[9,7,8]}];
}
function getPlotlyGraphLayout() {
return {};
}
function postCallback (body) {
var res = JSON.parse(body)
console.log(res.url) // gives you the url which will open the webapp w/ the data
}
payload = {
data: getPlotlyGraphData(),
layout: getPlotlyGraphLayout()
};
$('#plotly-graph-export').click( function () {
$.post(
'https://plot.ly/datacache/',
{payload: JSON.stringify(payload)},
postCallback
);
});
return;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment