mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
BarChart: Prevent label clipping at top (#91990)
* BarChart: Prevent label clipping at top * Fix const issue
This commit is contained in:
parent
126169f3ca
commit
3c5d799c8c
@ -399,7 +399,7 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) {
|
||||
// Calculate final co-ordinates for text position
|
||||
const x =
|
||||
u.bbox.left + (isXHorizontal ? lft + wid / 2 : value < 0 ? lft - labelOffset : lft + wid + labelOffset);
|
||||
const y =
|
||||
let y =
|
||||
u.bbox.top +
|
||||
(isXHorizontal ? (value < 0 ? top + hgt + labelOffset : top - labelOffset) : top + hgt / 2 - middleShift);
|
||||
|
||||
@ -436,6 +436,11 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) {
|
||||
xAdjust = value < 0 ? textMetrics.width * scaleFactor : 0;
|
||||
}
|
||||
|
||||
// Force label bounding box y position to not be negative
|
||||
if (y - yAdjust < 0) {
|
||||
y = yAdjust;
|
||||
}
|
||||
|
||||
// Construct final bounding box for the label text
|
||||
labels[dataIdx][seriesIdx].x = x;
|
||||
labels[dataIdx][seriesIdx].y = y;
|
||||
|
Loading…
Reference in New Issue
Block a user