From 150deacce9727c07ac7bef24309c7922dd7444df Mon Sep 17 00:00:00 2001 From: Atul Pratap Singh Date: Wed, 17 Apr 2013 15:36:42 +0530 Subject: [PATCH] Improved tooltip for monitor charts --- js/server_status_monitor.js | 45 +++++++++++++++++++++++++++++++++---- 1 file changed, 41 insertions(+), 4 deletions(-) diff --git a/js/server_status_monitor.js b/js/server_status_monitor.js index b5f97aef47..7fab7fd1a3 100644 --- a/js/server_status_monitor.js +++ b/js/server_status_monitor.js @@ -1178,10 +1178,7 @@ AJAX.registerOnload('server_status_monitor.js', function () { lineWidth: 2 }, highlighter: { - show: true, - showTooltip: true, - tooltipAxes: 'y', - useAxesFormatters: true + show: true } }; @@ -1221,6 +1218,46 @@ AJAX.registerOnload('server_status_monitor.js', function () { for (i in chartObj.series) { series.push([[0, 0]]); } + + // set Tooltip for each series + for(i in settings.series) { + settings.series[i].highlighter = { + show: true, + tooltipContentEditor: function (str, seriesIndex, pointIndex, plot) { + var tooltipHtml = '
'; + // x value i.e. time + var timeValue = str.split(",")[0]; + tooltipHtml += 'Time: ' + timeValue; + tooltipHtml += ''; + // Add y values to the tooltip per series + for (j in plot.series) { + // get y value if present + if (plot.series[j].data.length > pointIndex) { + var seriesValue = plot.series[j].data[pointIndex][1]; + } + else { + return; + } + var seriesLabel = plot.series[j].label; + var seriesColor = plot.series[j].color; + // format y value + if (plot.series[0]._yaxis.tickOptions.formatter) { + // using formatter function + seriesValue = plot.series[0]._yaxis.tickOptions.formatter('%s', seriesValue); + } else if (plot.series[0]._yaxis.tickOptions.formatString) { + // using format string + seriesValue = $.sprintf(plot.series[0]._yaxis.tickOptions.formatString, seriesValue); + } + tooltipHtml += '
' + + seriesLabel + ': ' + seriesValue + ''; + } + tooltipHtml += '
'; + return tooltipHtml; + } + }; + } + chartObj.chart = $.jqplot('gridchart' + runtime.chartAI, series, settings); // remove [0,0] after plotting for (i in chartObj.chart.series) {