Draft of multiple highcharts fed by ERDDAP REST API JSON output. Common Navigator and time selection. Show values on hover. Work in progress - known issues with time zoom, additional parameters to add, potential to combine some parameters into multi-axes plots.
var t0 = performance.now();
// Highcharts datepicker relies on this 'browser' function which is
// no longer included in jquery
jQuery.browser = {};
(function() {
jQuery.browser.msie = false;
jQuery.browser.version = 0;
if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
jQuery.browser.msie = true;
jQuery.browser.version = RegExp.$1;
}
})();
// get dates to use later in data query
// multiple queries
//(one that is shorter and loads fast, then another)
var d = new Date().getTime();
var d1 = new Date(d - (8 * 3600 * 1000 * 24)); // sets first load # of days
var d2 = new Date(d - (400 * 3600 * 1000 * 24)); // sets first load # of days
var n = d1.toISOString();
var n2 = d2.toISOString();
function mouseEv(e) {
var chart, point, i, event;
for (i = 0; i < Highcharts.charts.length; i = i + 1) {
chart = Highcharts.charts[i];
event = chart.pointer.normalize(e.originalEvent); // Find coordinates within the chart
point = chart.series[0].searchPoint(event, true); // Get the hovered point
if (point) {
if (chart['chartHeight'] != 90 && chart.xAxis[0].min > Math.pow(10, 12)) {
point.highlight(e);
}
}
}
}
// Tooltip hover sync
$('#container').bind('mousemove touchmove touchstart', mouseEv);
//Override the reset function, we don't need to hide the tooltips and crosshairs.
Highcharts.Pointer.prototype.reset = function() {
return undefined;
};
//Highlight a point by showing tooltip, setting hover state and drawing crosshair
Highcharts.Point.prototype.highlight = function(event) {
this.onMouseOver(); // Show the hover marker
this.series.chart.xAxis[0].drawCrosshair(event, this); // Show the crosshair
};
//Function to link x-axes on zoom
function syncExtremes(e) {
//get new min and max from current chart
var xMin = e.min;
var xMax = e.max;
// prevent crazy loop
if (e.trigger !== 'syncExtremes') {
...
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.