[Fix]: threshold table issue (#4247)

Co-authored-by: Vishal Sharma <makeavish786@gmail.com>
This commit is contained in:
Rajat Dabade 2023-12-27 10:38:22 +05:30 committed by GitHub
parent 788a38d39c
commit 63efb2b25a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -136,7 +136,18 @@ export const getUPlotChartOptions = ({
if (threshold.thresholdLabel) {
const text = threshold.thresholdLabel;
const textX = plotRight - ctx.measureText(text).width - 20;
const textY = yPos - 15;
const canvasHeight = ctx.canvas.height;
const yposHeight = canvasHeight - yPos;
const isHeightGreaterThan90Percent = canvasHeight * 0.9 < yposHeight;
// Adjust textY based on the condition
let textY;
if (isHeightGreaterThan90Percent) {
textY = yPos + 15; // Below the threshold line
} else {
textY = yPos - 15; // Above the threshold line
}
ctx.fillStyle = threshold.thresholdColor || 'red';
ctx.fillText(text, textX, textY);
}