mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TimeSeries: Separate field unit config for axis ticks and other display means when stacking by percent (#43713)
This commit is contained in:
parent
737bc35219
commit
4b814dbcea
@ -11,6 +11,7 @@ import {
|
||||
getFieldColorModeForField,
|
||||
getFieldSeriesColor,
|
||||
getFieldDisplayName,
|
||||
getDisplayProcessor,
|
||||
} from '@grafana/data';
|
||||
|
||||
import { UPlotConfigBuilder, UPlotConfigPrepFn } from '../uPlot/config/UPlotConfigBuilder';
|
||||
@ -23,6 +24,7 @@ import {
|
||||
ScaleDirection,
|
||||
ScaleOrientation,
|
||||
VizLegendOptions,
|
||||
StackingMode,
|
||||
} from '@grafana/schema';
|
||||
import { collectStackingGroups, orderIdsByCalcs, preparePlotData } from '../uPlot/utils';
|
||||
import uPlot from 'uplot';
|
||||
@ -135,8 +137,19 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{ sync: DashboardCursor
|
||||
// TODO: skip this for fields with custom renderers?
|
||||
field.state!.seriesIndex = seriesIndex++;
|
||||
|
||||
const fmt = field.display ?? defaultFormatter;
|
||||
|
||||
let fmt = field.display ?? defaultFormatter;
|
||||
if (field.config.custom?.stacking?.mode === StackingMode.Percent) {
|
||||
fmt = getDisplayProcessor({
|
||||
field: {
|
||||
...field,
|
||||
config: {
|
||||
...field.config,
|
||||
unit: 'percentunit',
|
||||
},
|
||||
},
|
||||
theme,
|
||||
});
|
||||
}
|
||||
const scaleKey = buildScaleKey(config);
|
||||
const colorMode = getFieldColorModeForField(field);
|
||||
const scaleColor = getFieldSeriesColor(field, theme);
|
||||
|
@ -7,7 +7,7 @@ import {
|
||||
GrafanaTheme2,
|
||||
isBooleanUnit,
|
||||
} from '@grafana/data';
|
||||
import { GraphFieldConfig, LineInterpolation, StackingMode } from '@grafana/schema';
|
||||
import { GraphFieldConfig, LineInterpolation } from '@grafana/schema';
|
||||
|
||||
/**
|
||||
* Returns null if there are no graphable fields
|
||||
@ -47,11 +47,6 @@ export function prepareGraphableFields(series: DataFrame[], theme: GrafanaTheme2
|
||||
),
|
||||
};
|
||||
|
||||
if (copy.config.custom?.stacking?.mode === StackingMode.Percent) {
|
||||
copy.config.unit = 'percentunit';
|
||||
copy.display = getDisplayProcessor({ field: copy, theme });
|
||||
}
|
||||
|
||||
fields.push(copy);
|
||||
break; // ok
|
||||
case FieldType.boolean:
|
||||
|
Loading…
Reference in New Issue
Block a user