|
|
|
|
@ -24,6 +24,8 @@ import { |
|
|
|
|
ScaleDirection, |
|
|
|
|
ScaleOrientation, |
|
|
|
|
VizLegendOptions, |
|
|
|
|
ScaleDistributionConfig, |
|
|
|
|
ScaleDistribution, |
|
|
|
|
} from '@grafana/schema'; |
|
|
|
|
import { collectStackingGroups, orderIdsByCalcs, preparePlotData } from '../uPlot/utils'; |
|
|
|
|
import uPlot from 'uplot'; |
|
|
|
|
@ -117,11 +119,16 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{ sync: DashboardCursor |
|
|
|
|
|
|
|
|
|
for (let i = 1; i < frame.fields.length; i++) { |
|
|
|
|
const field = frame.fields[i]; |
|
|
|
|
const config = field.config as FieldConfig<GraphFieldConfig>; |
|
|
|
|
const customConfig: GraphFieldConfig = { |
|
|
|
|
|
|
|
|
|
const config = { |
|
|
|
|
...field.config, |
|
|
|
|
custom: { |
|
|
|
|
...defaultConfig, |
|
|
|
|
...config.custom, |
|
|
|
|
}; |
|
|
|
|
...field.config.custom, |
|
|
|
|
}, |
|
|
|
|
} as FieldConfig<GraphFieldConfig>; |
|
|
|
|
|
|
|
|
|
const customConfig: GraphFieldConfig = config.custom!; |
|
|
|
|
|
|
|
|
|
if (field === xField || field.type !== FieldType.number) { |
|
|
|
|
continue; |
|
|
|
|
@ -131,7 +138,8 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{ sync: DashboardCursor |
|
|
|
|
field.state!.seriesIndex = seriesIndex++; |
|
|
|
|
|
|
|
|
|
const fmt = field.display ?? defaultFormatter; |
|
|
|
|
const scaleKey = config.unit || FIXED_UNIT; |
|
|
|
|
|
|
|
|
|
const scaleKey = buildScaleKey(config); |
|
|
|
|
const colorMode = getFieldColorModeForField(field); |
|
|
|
|
const scaleColor = getFieldSeriesColor(field, theme); |
|
|
|
|
const seriesColor = scaleColor.color; |
|
|
|
|
@ -427,3 +435,34 @@ export function getNamesToFieldIndex(frame: DataFrame, allFrames: DataFrame[]): |
|
|
|
|
}); |
|
|
|
|
return originNames; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function buildScaleKey(config: FieldConfig<GraphFieldConfig>) { |
|
|
|
|
const defaultPart = 'na'; |
|
|
|
|
|
|
|
|
|
const scaleRange = `${config.min !== undefined ? config.min : defaultPart}-${ |
|
|
|
|
config.max !== undefined ? config.max : defaultPart |
|
|
|
|
}`;
|
|
|
|
|
|
|
|
|
|
const scaleSoftRange = `${config.custom?.axisSoftMin !== undefined ? config.custom.axisSoftMin : defaultPart}-${ |
|
|
|
|
config.custom?.axisSoftMax !== undefined ? config.custom.axisSoftMax : defaultPart |
|
|
|
|
}`;
|
|
|
|
|
|
|
|
|
|
const scalePlacement = `${config.custom?.axisPlacement !== undefined ? config.custom?.axisPlacement : defaultPart}`; |
|
|
|
|
|
|
|
|
|
const scaleUnit = config.unit ?? FIXED_UNIT; |
|
|
|
|
|
|
|
|
|
const scaleDistribution = config.custom?.scaleDistribution |
|
|
|
|
? getScaleDistributionPart(config.custom.scaleDistribution) |
|
|
|
|
: ScaleDistribution.Linear; |
|
|
|
|
|
|
|
|
|
const scaleLabel = Boolean(config.custom?.axisLabel) ? config.custom!.axisLabel : defaultPart; |
|
|
|
|
|
|
|
|
|
return `${scaleUnit}/${scaleRange}/${scaleSoftRange}/${scalePlacement}/${scaleDistribution}/${scaleLabel}`; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
function getScaleDistributionPart(config: ScaleDistributionConfig) { |
|
|
|
|
if (config.type === ScaleDistribution.Log) { |
|
|
|
|
return `${config.type}${config.log}`; |
|
|
|
|
} |
|
|
|
|
return config.type; |
|
|
|
|
} |
|
|
|
|
|