mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 03:01:51 +08:00
BarChart: fix explicit yAxis min (#51768)
This commit is contained in:
@ -45,5 +45,4 @@ export const defaultBarChartFieldConfig: BarChartFieldConfig = {
|
|||||||
lineWidth: 1,
|
lineWidth: 1,
|
||||||
fillOpacity: 80,
|
fillOpacity: 80,
|
||||||
gradientMode: GraphGradientMode.None,
|
gradientMode: GraphGradientMode.None,
|
||||||
axisSoftMin: 0,
|
|
||||||
};
|
};
|
||||||
|
@ -173,6 +173,18 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<BarChartOptionsEX> = ({
|
|||||||
const scaleColor = getFieldSeriesColor(field, theme);
|
const scaleColor = getFieldSeriesColor(field, theme);
|
||||||
const seriesColor = scaleColor.color;
|
const seriesColor = scaleColor.color;
|
||||||
|
|
||||||
|
// make barcharts start at 0 unless explicitly overridden
|
||||||
|
let softMin = customConfig.axisSoftMin;
|
||||||
|
let softMax = customConfig.axisSoftMax;
|
||||||
|
|
||||||
|
if (softMin == null && field.config.min == null) {
|
||||||
|
softMin = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (softMax == null && field.config.max == null) {
|
||||||
|
softMax = 0;
|
||||||
|
}
|
||||||
|
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
scaleKey,
|
scaleKey,
|
||||||
pxAlign: true,
|
pxAlign: true,
|
||||||
@ -187,8 +199,8 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<BarChartOptionsEX> = ({
|
|||||||
thresholds: field.config.thresholds,
|
thresholds: field.config.thresholds,
|
||||||
hardMin: field.config.min,
|
hardMin: field.config.min,
|
||||||
hardMax: field.config.max,
|
hardMax: field.config.max,
|
||||||
softMin: customConfig.axisSoftMin,
|
softMin,
|
||||||
softMax: customConfig.axisSoftMax,
|
softMax,
|
||||||
|
|
||||||
// The following properties are not used in the uPlot config, but are utilized as transport for legend config
|
// The following properties are not used in the uPlot config, but are utilized as transport for legend config
|
||||||
// PlotLegend currently gets unfiltered DataFrame[], so index must be into that field array, not the prepped frame's which we're iterating here
|
// PlotLegend currently gets unfiltered DataFrame[], so index must be into that field array, not the prepped frame's which we're iterating here
|
||||||
@ -207,8 +219,8 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<BarChartOptionsEX> = ({
|
|||||||
scaleKey,
|
scaleKey,
|
||||||
min: field.config.min,
|
min: field.config.min,
|
||||||
max: field.config.max,
|
max: field.config.max,
|
||||||
softMin: customConfig.axisSoftMin,
|
softMin,
|
||||||
softMax: customConfig.axisSoftMax,
|
softMax,
|
||||||
orientation: vizOrientation.yOri,
|
orientation: vizOrientation.yOri,
|
||||||
direction: vizOrientation.yDir,
|
direction: vizOrientation.yDir,
|
||||||
distribution: customConfig.scaleDistribution?.type,
|
distribution: customConfig.scaleDistribution?.type,
|
||||||
|
Reference in New Issue
Block a user