Last active
August 29, 2015 14:05
-
-
Save bpostlethwaite/df4a6100f8a64b29450a to your computer and use it in GitHub Desktop.
post to plotly /datacache endpoint
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(){ | |
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