mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TimeSeries: fix log-y-axis tick label skipping when decimals=0 (#55868)
This commit is contained in:
parent
2a12644778
commit
b8da1ffdc3
@ -276,6 +276,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{
|
||||
theme,
|
||||
grid: { show: customConfig.axisGridShow },
|
||||
decimals: field.config.decimals,
|
||||
distr: customConfig.scaleDistribution?.type,
|
||||
...axisColorOpts,
|
||||
},
|
||||
field
|
||||
|
@ -10,7 +10,7 @@ import {
|
||||
systemDateFormats,
|
||||
TimeZone,
|
||||
} from '@grafana/data';
|
||||
import { AxisPlacement } from '@grafana/schema';
|
||||
import { AxisPlacement, ScaleDistribution } from '@grafana/schema';
|
||||
|
||||
import { measureText } from '../../../utils/measureText';
|
||||
import { PlotConfigBuilder } from '../types';
|
||||
@ -39,6 +39,7 @@ export interface AxisProps {
|
||||
color?: uPlot.Axis.Stroke;
|
||||
border?: uPlot.Axis.Border;
|
||||
decimals?: DecimalCount;
|
||||
distr?: ScaleDistribution;
|
||||
}
|
||||
|
||||
export const UPLOT_AXIS_FONT_SIZE = 12;
|
||||
@ -121,6 +122,7 @@ export class UPlotAxisBuilder extends PlotConfigBuilder<AxisProps, Axis> {
|
||||
color,
|
||||
border,
|
||||
decimals,
|
||||
distr = ScaleDistribution.Linear,
|
||||
} = this.props;
|
||||
|
||||
const font = `${UPLOT_AXIS_FONT_SIZE}px ${theme.typography.fontFamily}`;
|
||||
@ -131,7 +133,7 @@ export class UPlotAxisBuilder extends PlotConfigBuilder<AxisProps, Axis> {
|
||||
splits = [0, 1];
|
||||
}
|
||||
|
||||
if (decimals === 0) {
|
||||
if (decimals === 0 && distr === ScaleDistribution.Linear) {
|
||||
filter = (u, splits) => splits.map((v) => (Number.isInteger(v) ? v : null));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user