From 0006469d9fb93428217b6c8a69ff6e29c7c05a00 Mon Sep 17 00:00:00 2001 From: sgissinger Date: Thu, 3 Oct 2013 10:05:20 +0200 Subject: [PATCH] Update jquery.flot.threshold.js Displays the serie base color and the threshold color side by side in the legend. When no treshold is color is set, default black color is used. --- jquery.flot.threshold.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/jquery.flot.threshold.js b/jquery.flot.threshold.js index f0cbb86..0bdcd46 100644 --- a/jquery.flot.threshold.js +++ b/jquery.flot.threshold.js @@ -135,6 +135,26 @@ You may need to check for this in hover events. } plot.hooks.processDatapoints.push(processThresholds); + + + function processThresholdsLegend(ctx, canvas, s) { + if (!s.threshold) { + return; + } + + var color = s.threshold.color ? s.threshold.color : "black"; + + $(".legendLabel").each(function() { + if($(this).text() === s.label) + { + var legend = $(this).prev().find("div > div"); + legend.css("border-right-color" , color); + legend.css("border-bottom-color" , color); + } + }); + } + + plot.hooks.drawSeries.push(processThresholdsLegend); } $.plot.plugins.push({