From ec819693ccba561391735566913b5c78c064e238 Mon Sep 17 00:00:00 2001 From: "thomas.duval" Date: Wed, 29 Sep 2021 17:16:47 +1000 Subject: [PATCH 1/4] thomas-AOT-4029 add arguments to the draw symbol to get datapoints and time series --- src/jquery.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.flot.js b/src/jquery.flot.js index 30e4e0d..f9293bc 100644 --- a/src/jquery.flot.js +++ b/src/jquery.flot.js @@ -3082,7 +3082,7 @@ Licensed under the MIT license. if (symbol === "circle") { ctx.arc(x, y, radius, 0, shadow ? Math.PI : Math.PI * 2, false); } else { - symbol(ctx, x, y, radius, shadow); + symbol(ctx, x, y, radius, shadow, datapoints, series); } ctx.closePath(); From 3dcdcbd7ca6b21954c2d675c584780da24c53eb9 Mon Sep 17 00:00:00 2001 From: "thomas.duval" Date: Thu, 30 Sep 2021 11:16:17 +1000 Subject: [PATCH 2/4] thomas-AOT-4029 add extra parameters to show alarm on graph --- src/jquery.flot.js | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/src/jquery.flot.js b/src/jquery.flot.js index f9293bc..7e46334 100644 --- a/src/jquery.flot.js +++ b/src/jquery.flot.js @@ -3067,11 +3067,12 @@ Licensed under the MIT license. } function drawSeriesPoints(series) { - function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol) { + function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol, extraData = null) { var points = datapoints.points, ps = datapoints.pointsize; for (var i = 0; i < points.length; i += ps) { var x = points[i], y = points[i + 1]; + var value = x; if (x == null || x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) { continue; } @@ -3081,16 +3082,17 @@ Licensed under the MIT license. y = axisy.p2c(y) + offset; if (symbol === "circle") { ctx.arc(x, y, radius, 0, shadow ? Math.PI : Math.PI * 2, false); + ctx.closePath(); + if (fillStyle) { + ctx.fillStyle = fillStyle; + ctx.fill(); + } + ctx.stroke(); } else { - symbol(ctx, x, y, radius, shadow, datapoints, series); - } - ctx.closePath(); - - if (fillStyle) { - ctx.fillStyle = fillStyle; + symbol(ctx, x, y, radius, shadow, extraData, value); + ctx.fillStyle = "#FF0000"; ctx.fill(); } - ctx.stroke(); } } @@ -3100,7 +3102,8 @@ Licensed under the MIT license. var lw = series.points.lineWidth, sw = series.shadowSize, radius = series.points.radius, - symbol = series.points.symbol; + symbol = series.points.symbol, + extraData = series.points.extraData; // If the user sets the line width to 0, we change it to a very // small value. A line width of 0 seems to force the default of 1. @@ -3117,18 +3120,18 @@ Licensed under the MIT license. ctx.lineWidth = w; ctx.strokeStyle = "rgba(0,0,0,0.1)"; plotPoints(series.datapoints, radius, null, w + w / 2, true, - series.xaxis, series.yaxis, symbol); + series.xaxis, series.yaxis, symbol, extraData); ctx.strokeStyle = "rgba(0,0,0,0.2)"; plotPoints(series.datapoints, radius, null, w / 2, true, - series.xaxis, series.yaxis, symbol); + series.xaxis, series.yaxis, symbol, extraData); } ctx.lineWidth = lw; ctx.strokeStyle = series.points.strokeColor || series.color; plotPoints(series.datapoints, radius, getFillStyle(series.points, series.color), 0, false, - series.xaxis, series.yaxis, symbol); + series.xaxis, series.yaxis, symbol, extraData); ctx.restore(); } @@ -3710,7 +3713,7 @@ Licensed under the MIT license. if (x < axisx.min || x > axisx.max || y < axisy.min || y > axisy.max) { return; } - + var value = x; var pointRadius, radius; if (series.points.show) { @@ -3729,7 +3732,7 @@ Licensed under the MIT license. if (series.points.symbol === "circle") { octx.arc(x, y, radius, 0, 2 * Math.PI, false); } else { - series.points.symbol(octx, x, y, radius, false); + series.points.symbol(octx, x, y, radius, false, series.points.extraData, value); } octx.closePath(); octx.stroke(); From 1f14b71bb8a1962df62b087849587041712d5287 Mon Sep 17 00:00:00 2001 From: "thomas.duval" Date: Fri, 1 Oct 2021 14:32:49 +1000 Subject: [PATCH 3/4] thomas-AOT-4029 add index of the series --- src/jquery.flot.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/jquery.flot.js b/src/jquery.flot.js index 7e46334..d0b9af0 100644 --- a/src/jquery.flot.js +++ b/src/jquery.flot.js @@ -2263,7 +2263,7 @@ Licensed under the MIT license. for (var i = 0; i < series.length; ++i) { executeHooks(hooks.drawSeries, [ctx, series[i]]); - drawSeries(series[i]); + drawSeries(series[i], i); } executeHooks(hooks.draw, [ctx]); @@ -2762,7 +2762,7 @@ Licensed under the MIT license. }); } - function drawSeries(series) { + function drawSeries(series, i) { if (series.lines.show) { drawSeriesLines(series); } @@ -2770,7 +2770,7 @@ Licensed under the MIT license. drawSeriesBars(series); } if (series.points.show) { - drawSeriesPoints(series); + drawSeriesPoints(series, i); } } @@ -3066,8 +3066,8 @@ Licensed under the MIT license. ctx.restore(); } - function drawSeriesPoints(series) { - function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol, extraData = null) { + function drawSeriesPoints(series, i) { + function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol, extraData = null, t) { var points = datapoints.points, ps = datapoints.pointsize; for (var i = 0; i < points.length; i += ps) { @@ -3089,7 +3089,7 @@ Licensed under the MIT license. } ctx.stroke(); } else { - symbol(ctx, x, y, radius, shadow, extraData, value); + symbol(ctx, x, y, radius, shadow, extraData, value, t); ctx.fillStyle = "#FF0000"; ctx.fill(); } @@ -3120,18 +3120,18 @@ Licensed under the MIT license. ctx.lineWidth = w; ctx.strokeStyle = "rgba(0,0,0,0.1)"; plotPoints(series.datapoints, radius, null, w + w / 2, true, - series.xaxis, series.yaxis, symbol, extraData); + series.xaxis, series.yaxis, symbol, extraData, i); ctx.strokeStyle = "rgba(0,0,0,0.2)"; plotPoints(series.datapoints, radius, null, w / 2, true, - series.xaxis, series.yaxis, symbol, extraData); + series.xaxis, series.yaxis, symbol, extraData, i); } ctx.lineWidth = lw; ctx.strokeStyle = series.points.strokeColor || series.color; plotPoints(series.datapoints, radius, getFillStyle(series.points, series.color), 0, false, - series.xaxis, series.yaxis, symbol, extraData); + series.xaxis, series.yaxis, symbol, extraData, i); ctx.restore(); } From 5de5f3190b78f558c77e8e95eb52b623c21f6ecb Mon Sep 17 00:00:00 2001 From: "thomas.duval" Date: Fri, 1 Oct 2021 15:06:01 +1000 Subject: [PATCH 4/4] thomas-AOT-4029 pr --- src/jquery.flot.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.flot.js b/src/jquery.flot.js index d0b9af0..e992b2b 100644 --- a/src/jquery.flot.js +++ b/src/jquery.flot.js @@ -3067,7 +3067,7 @@ Licensed under the MIT license. } function drawSeriesPoints(series, i) { - function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol, extraData = null, t) { + function plotPoints(datapoints, radius, fillStyle, offset, shadow, axisx, axisy, symbol, extraData = null, t = 0) { var points = datapoints.points, ps = datapoints.pointsize; for (var i = 0; i < points.length; i += ps) {