var seriesFull = [];
function makeData(tsURL, tsName) {
//Ajax query for data, JSON format
$.getJSON(tsURL, function (data) {
var data2 = data[0].data;
var data3 = [];
//Loop through date and param values and format for chart
for (var i = 1; i < data2.length; i++) {
var myDate = new Date(data2[i][0].substring(0, 23));
var result = myDate.getTime();
data2[i][0] = result;
data2[i][1] = parseFloat(data2[i][1]);
data3.push(data2[i]);
}
//populate the series for the chart
var singleSeries = {
_colorIndex: seriesFull.length,
_symbolIndex: seriesFull.length,
//Can also extract name directly from query, but lazy example
name: tsName,
data: data3
};
seriesFull.push(singleSeries);
//Create and render the chart passing in the series
createMyChart2(seriesFull);
});
}
$("#btnAddGRCA1").click(function () {
makeData("https://waterdata.grandriver.ca//KiWIS/KiWIS?service=kisters&type=queryServices&request=getTimeseriesValues&datasource=0&ts_id=8629042&from=2015-02-02&to=2015-03-13&format=json", "TS1");
});
$("#btnAddGRCA2").click(function () {
makeData("https://waterdata.grandriver.ca//KiWIS/KiWIS?service=kisters&type=queryServices&request=getTimeseriesValues&datasource=0&ts_id=8647042&from=2015-02-02&to=2015-03-13&format=json", "TS2");
});
$("#btnClear").click(function () {
seriesFull.length = 0;
var dataReset = [];
$("#ChartContainer").html("");
});
function createMyChart2(dataSeries) {
var chart = new Highcharts.StockChart({
chart: {renderTo: 'ChartContainer'},
legend: {enabled: true},
rangeSelector: {selected: 1},
title: {text: 'Station values - Around the World'},
series: dataSeries,
xAxis: {ordinal: false},
tooltip: {valueDecimals: 2,shared: true}
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.