Skip to content

Instantly share code, notes, and snippets.

@bpostlethwaite
Created August 15, 2014 20:11
Show Gist options
  • Save bpostlethwaite/6c9008a15593b0d1d12d to your computer and use it in GitHub Desktop.
Save bpostlethwaite/6c9008a15593b0d1d12d to your computer and use it in GitHub Desktop.
$(function(){
'use strict';
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);
if ('url' in res) window.open(res.url);
}
payload = {
data: getPlotlyGraphData(),
layout: getPlotlyGraphLayout()
};
$('#plotly-graph-export').click( function () {
$.post(
'https://stage.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