mirror of
https://github.com/grafana/grafana.git
synced 2025-09-22 06:12:52 +08:00

* Fix panel option bugs and make tooltip options work * Support multiple series in explicit mode. Rename XY/Explicit to Auto/Manual * Fixes * Fix * Legend improvements * Rewrite Pure Component to Function Component * Add datalinks support * Legend fixes and CR modifications * Fix bugs that crash panel
89 lines
2.4 KiB
TypeScript
89 lines
2.4 KiB
TypeScript
import {
|
|
FieldColorModeId,
|
|
FieldConfigProperty,
|
|
FieldType,
|
|
identityOverrideProcessor,
|
|
SetFieldConfigOptionsArgs,
|
|
} from '@grafana/data';
|
|
import { LineStyle, VisibilityMode } from '@grafana/schema';
|
|
import { commonOptionsBuilder, graphFieldOptions } from '@grafana/ui';
|
|
|
|
import { LineStyleEditor } from '../timeseries/LineStyleEditor';
|
|
|
|
import { ScatterFieldConfig, ScatterLineMode } from './models.gen';
|
|
|
|
export function getScatterFieldConfig(cfg: ScatterFieldConfig): SetFieldConfigOptionsArgs<ScatterFieldConfig> {
|
|
return {
|
|
standardOptions: {
|
|
[FieldConfigProperty.Color]: {
|
|
settings: {
|
|
byValueSupport: true,
|
|
bySeriesSupport: true,
|
|
preferThresholdsMode: false,
|
|
},
|
|
defaultValue: {
|
|
mode: FieldColorModeId.PaletteClassic,
|
|
},
|
|
},
|
|
},
|
|
|
|
useCustomConfig: (builder) => {
|
|
builder
|
|
.addRadio({
|
|
path: 'point',
|
|
name: 'Points',
|
|
defaultValue: cfg.point,
|
|
settings: {
|
|
options: graphFieldOptions.showPoints,
|
|
},
|
|
})
|
|
.addSliderInput({
|
|
path: 'pointSize.fixed',
|
|
name: 'Size',
|
|
defaultValue: cfg.pointSize?.fixed,
|
|
settings: {
|
|
min: 1,
|
|
max: 100,
|
|
step: 1,
|
|
},
|
|
showIf: (c) => c.point !== VisibilityMode.Never,
|
|
})
|
|
.addRadio({
|
|
path: 'line',
|
|
name: 'Lines',
|
|
defaultValue: cfg.line,
|
|
settings: {
|
|
options: [
|
|
{ label: 'None', value: ScatterLineMode.None },
|
|
{ label: 'Linear', value: ScatterLineMode.Linear },
|
|
],
|
|
},
|
|
})
|
|
.addCustomEditor<void, LineStyle>({
|
|
id: 'lineStyle',
|
|
path: 'lineStyle',
|
|
name: 'Line style',
|
|
showIf: (c) => c.line !== ScatterLineMode.None,
|
|
editor: LineStyleEditor,
|
|
override: LineStyleEditor,
|
|
process: identityOverrideProcessor,
|
|
shouldApply: (f) => f.type === FieldType.number,
|
|
})
|
|
.addSliderInput({
|
|
path: 'lineWidth',
|
|
name: 'Line width',
|
|
defaultValue: cfg.lineWidth,
|
|
settings: {
|
|
min: 0,
|
|
max: 10,
|
|
step: 1,
|
|
},
|
|
showIf: (c) => c.line !== ScatterLineMode.None,
|
|
});
|
|
|
|
commonOptionsBuilder.addAxisConfig(builder, cfg);
|
|
commonOptionsBuilder.addHideFrom(builder);
|
|
},
|
|
};
|
|
}
|