mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
BarChart: fix single group rendering (#45953)
This commit is contained in:
parent
5aab0063c7
commit
1c4b20b268
@ -189,7 +189,7 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) {
|
|||||||
// this expands the distr: 2 scale so that the indicies of each data[0] land at the proper justified positions
|
// this expands the distr: 2 scale so that the indicies of each data[0] land at the proper justified positions
|
||||||
const xRange: Scale.Range = (u, min, max) => {
|
const xRange: Scale.Range = (u, min, max) => {
|
||||||
min = 0;
|
min = 0;
|
||||||
max = u.data[0].length - 1;
|
max = Math.max(1, u.data[0].length - 1);
|
||||||
|
|
||||||
let pctOffset = 0;
|
let pctOffset = 0;
|
||||||
|
|
||||||
@ -199,13 +199,17 @@ export function getConfig(opts: BarsOptions, theme: GrafanaTheme2) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// expand scale range by equal amounts on both ends
|
// expand scale range by equal amounts on both ends
|
||||||
let rn = max - min; // TODO: clamp to 1?
|
let rn = max - min;
|
||||||
|
|
||||||
let upScale = 1 / (1 - pctOffset * 2);
|
if (pctOffset === 0.5) {
|
||||||
let offset = (upScale * rn - rn) / 2;
|
min -= rn;
|
||||||
|
} else {
|
||||||
|
let upScale = 1 / (1 - pctOffset * 2);
|
||||||
|
let offset = (upScale * rn - rn) / 2;
|
||||||
|
|
||||||
min -= offset;
|
min -= offset;
|
||||||
max += offset;
|
max += offset;
|
||||||
|
}
|
||||||
|
|
||||||
return [min, max];
|
return [min, max];
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user