Skip to content

Instantly share code, notes, and snippets.

@gtallen1187
Created June 19, 2019 23:07
Show Gist options
  • Save gtallen1187/756edbb6c11676d9d3c0007420216554 to your computer and use it in GitHub Desktop.
Save gtallen1187/756edbb6c11676d9d3c0007420216554 to your computer and use it in GitHub Desktop.
function fetchDataset(url, cb, crop) {
var http = new XMLHttpRequest();
http.open("GET", url);
http.send();
http.onload = function () {
var result = http.responseText && JSON.parse(http.responseText);
cb && result && cb(result, crop);
};
};
function showData(res){
console.log(res);
var data = res.result[0].data.TELLUSCHIN;
var data = res && res.result && res.result[0] && res.result[0].data && res.result[0].data.TELLUSCHIN || []
var data = _get(res, 'result[0].data.TELLUSCHIN', [])
var mySeries = {
name: 'drewSeries',
data: data
}
myChart.addSeries(mySeries)
myChart.redraw()
};
fetchDataset('https://api.kernel.telluslabs.com/api/v1/metrics/?country_iso=USA&geo_level=level_1&data_points=3&metric_code=TELLUSCHIN,TLCHIN5YMN,TLCHIN5YLO,TLCHIN5YHI&api_key=80bcc60a8affd75375870d340463051e&geo_id=00&crop=corn', showData)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment