mirror of
https://github.com/grafana/grafana.git
synced 2024-12-24 08:00:08 -06:00
BarChart: Fix threshold lines rendering for horizontal orientation (#95737)
* Use different threshold x/y coordinates depending on orientation * invert wording / semantics --------- Co-authored-by: Leon Sorokin <leeoniya@gmail.com>
This commit is contained in:
parent
7bb1b352e1
commit
95692b3d68
@ -2,7 +2,7 @@ import tinycolor from 'tinycolor2';
|
||||
import uPlot from 'uplot';
|
||||
|
||||
import { GrafanaTheme2, Threshold, ThresholdsConfig, ThresholdsMode } from '@grafana/data';
|
||||
import { GraphThresholdsStyleConfig, GraphThresholdsStyleMode } from '@grafana/schema';
|
||||
import { GraphThresholdsStyleConfig, GraphThresholdsStyleMode, ScaleOrientation } from '@grafana/schema';
|
||||
|
||||
import { getGradientRange, scaleGradient } from './gradientFills';
|
||||
|
||||
@ -58,10 +58,13 @@ export function getThresholdsDrawHook(options: UPlotThresholdOptions) {
|
||||
color.setAlpha(0.7);
|
||||
}
|
||||
|
||||
let x0 = Math.round(u.bbox.left);
|
||||
let y0 = Math.round(u.valToPos(step.value, yScaleKey, true));
|
||||
let x1 = Math.round(u.bbox.left + u.bbox.width);
|
||||
let y1 = Math.round(u.valToPos(step.value, yScaleKey, true));
|
||||
const isHorizontal = u.scales.x!.ori === ScaleOrientation.Horizontal;
|
||||
const scaleVal = u.valToPos(step.value, yScaleKey, true);
|
||||
|
||||
let x0 = Math.round(isHorizontal ? u.bbox.left : scaleVal);
|
||||
let y0 = Math.round(isHorizontal ? scaleVal : u.bbox.top);
|
||||
let x1 = Math.round(isHorizontal ? u.bbox.left + u.bbox.width : scaleVal);
|
||||
let y1 = Math.round(isHorizontal ? scaleVal : u.bbox.top + u.bbox.height);
|
||||
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(x0, y0);
|
||||
|
Loading…
Reference in New Issue
Block a user