mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Schema: export existing types in @grafana/data|ui (#38518)
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { size } from 'lodash';
|
||||
import { BarAlignment, DrawStyle, StackingMode } from '@grafana/schema';
|
||||
import { BarAlignment, GraphDrawStyle, StackingMode } from '@grafana/schema';
|
||||
import { ansicolor, colors } from '@grafana/ui';
|
||||
|
||||
import {
|
||||
@@ -145,7 +145,7 @@ export function makeDataFramesForLogs(sortedRows: LogRowModel[], bucketSize: num
|
||||
data.fields[valueField.index].config.decimals = 0;
|
||||
|
||||
data.fields[valueField.index].config.custom = {
|
||||
drawStyle: DrawStyle.Bars,
|
||||
drawStyle: GraphDrawStyle.Bars,
|
||||
barAlignment: BarAlignment.Center,
|
||||
barWidthFactor: 0.9,
|
||||
barMaxWidth: 5,
|
||||
|
||||
@@ -24,7 +24,7 @@ import {
|
||||
useTheme2,
|
||||
ZoomPlugin,
|
||||
} from '@grafana/ui';
|
||||
import { LegendDisplayMode, TooltipDisplayMode, DrawStyle } from '@grafana/schema';
|
||||
import { LegendDisplayMode, TooltipDisplayMode, GraphDrawStyle } from '@grafana/schema';
|
||||
import { defaultGraphConfig, getGraphFieldConfig } from 'app/plugins/panel/timeseries/config';
|
||||
import { ContextMenuPlugin } from 'app/plugins/panel/timeseries/plugins/ContextMenuPlugin';
|
||||
import { ExemplarsPlugin } from 'app/plugins/panel/timeseries/plugins/ExemplarsPlugin';
|
||||
@@ -83,7 +83,7 @@ export function ExploreGraphNGPanel({
|
||||
mode: FieldColorModeId.PaletteClassic,
|
||||
},
|
||||
custom: {
|
||||
drawStyle: DrawStyle.Line,
|
||||
drawStyle: GraphDrawStyle.Line,
|
||||
fillOpacity: 0,
|
||||
pointSize: 5,
|
||||
},
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { DrawStyle, StackingMode } from '@grafana/schema';
|
||||
import { GraphDrawStyle, StackingMode } from '@grafana/schema';
|
||||
import { lastValueFrom } from 'rxjs';
|
||||
import {
|
||||
ArrayVector,
|
||||
@@ -365,7 +365,7 @@ describe('decorateWithLogsResult', () => {
|
||||
decimals: 0,
|
||||
unit: undefined,
|
||||
custom: {
|
||||
drawStyle: DrawStyle.Bars,
|
||||
drawStyle: GraphDrawStyle.Bars,
|
||||
barAlignment: 0,
|
||||
barMaxWidth: 5,
|
||||
barWidthFactor: 0.9,
|
||||
|
||||
@@ -8,7 +8,7 @@ import {
|
||||
} from '@grafana/data';
|
||||
import {
|
||||
BarAlignment,
|
||||
DrawStyle,
|
||||
GraphDrawStyle,
|
||||
GraphFieldConfig,
|
||||
GraphGradientMode,
|
||||
LineInterpolation,
|
||||
@@ -26,7 +26,7 @@ import { SpanNullsEditor } from './SpanNullsEditor';
|
||||
import { ThresholdsStyleEditor } from './ThresholdsStyleEditor';
|
||||
|
||||
export const defaultGraphConfig: GraphFieldConfig = {
|
||||
drawStyle: DrawStyle.Line,
|
||||
drawStyle: GraphDrawStyle.Line,
|
||||
lineInterpolation: LineInterpolation.Linear,
|
||||
lineWidth: 1,
|
||||
fillOpacity: 0,
|
||||
@@ -73,7 +73,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
settings: {
|
||||
options: graphFieldOptions.lineInterpolation,
|
||||
},
|
||||
showIf: (c) => c.drawStyle === DrawStyle.Line,
|
||||
showIf: (c) => c.drawStyle === GraphDrawStyle.Line,
|
||||
})
|
||||
.addRadio({
|
||||
path: 'barAlignment',
|
||||
@@ -83,7 +83,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
settings: {
|
||||
options: graphFieldOptions.barAlignment,
|
||||
},
|
||||
showIf: (c) => c.drawStyle === DrawStyle.Bars,
|
||||
showIf: (c) => c.drawStyle === GraphDrawStyle.Bars,
|
||||
})
|
||||
.addSliderInput({
|
||||
path: 'lineWidth',
|
||||
@@ -95,7 +95,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
max: 10,
|
||||
step: 1,
|
||||
},
|
||||
showIf: (c) => c.drawStyle !== DrawStyle.Points,
|
||||
showIf: (c) => c.drawStyle !== GraphDrawStyle.Points,
|
||||
})
|
||||
.addSliderInput({
|
||||
path: 'fillOpacity',
|
||||
@@ -107,7 +107,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
max: 100,
|
||||
step: 1,
|
||||
},
|
||||
showIf: (c) => c.drawStyle !== DrawStyle.Points,
|
||||
showIf: (c) => c.drawStyle !== GraphDrawStyle.Points,
|
||||
})
|
||||
.addRadio({
|
||||
path: 'gradientMode',
|
||||
@@ -117,7 +117,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
settings: {
|
||||
options: graphFieldOptions.fillGradient,
|
||||
},
|
||||
showIf: (c) => c.drawStyle !== DrawStyle.Points,
|
||||
showIf: (c) => c.drawStyle !== GraphDrawStyle.Points,
|
||||
})
|
||||
.addCustomEditor({
|
||||
id: 'fillBelowTo',
|
||||
@@ -135,7 +135,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
path: 'lineStyle',
|
||||
name: 'Line style',
|
||||
category: categoryStyles,
|
||||
showIf: (c) => c.drawStyle === DrawStyle.Line,
|
||||
showIf: (c) => c.drawStyle === GraphDrawStyle.Line,
|
||||
editor: LineStyleEditor,
|
||||
override: LineStyleEditor,
|
||||
process: identityOverrideProcessor,
|
||||
@@ -149,7 +149,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
defaultValue: false,
|
||||
editor: SpanNullsEditor,
|
||||
override: SpanNullsEditor,
|
||||
showIf: (c) => c.drawStyle === DrawStyle.Line,
|
||||
showIf: (c) => c.drawStyle === GraphDrawStyle.Line,
|
||||
shouldApply: (f) => f.type !== FieldType.time,
|
||||
process: identityOverrideProcessor,
|
||||
})
|
||||
@@ -161,7 +161,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
settings: {
|
||||
options: graphFieldOptions.showPoints,
|
||||
},
|
||||
showIf: (c) => c.drawStyle !== DrawStyle.Points,
|
||||
showIf: (c) => c.drawStyle !== GraphDrawStyle.Points,
|
||||
})
|
||||
.addSliderInput({
|
||||
path: 'pointSize',
|
||||
@@ -173,7 +173,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
||||
max: 40,
|
||||
step: 1,
|
||||
},
|
||||
showIf: (c) => c.showPoints !== PointVisibility.Never || c.drawStyle === DrawStyle.Points,
|
||||
showIf: (c) => c.showPoints !== PointVisibility.Never || c.drawStyle === GraphDrawStyle.Points,
|
||||
});
|
||||
|
||||
commonOptionsBuilder.addStackingConfig(builder, cfg.stacking, categoryStyles);
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
LegendDisplayMode,
|
||||
TooltipDisplayMode,
|
||||
AxisPlacement,
|
||||
DrawStyle,
|
||||
GraphDrawStyle,
|
||||
GraphFieldConfig,
|
||||
GraphGradientMode,
|
||||
GraphTresholdsStyleMode,
|
||||
@@ -173,7 +173,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
||||
if (v) {
|
||||
rule.properties.push({
|
||||
id: 'custom.drawStyle',
|
||||
value: DrawStyle.Bars,
|
||||
value: GraphDrawStyle.Bars,
|
||||
});
|
||||
rule.properties.push({
|
||||
id: 'custom.fillOpacity',
|
||||
@@ -182,7 +182,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
||||
} else {
|
||||
rule.properties.push({
|
||||
id: 'custom.drawStyle',
|
||||
value: DrawStyle.Line, // Change from bars
|
||||
value: GraphDrawStyle.Line, // Change from bars
|
||||
});
|
||||
}
|
||||
break;
|
||||
@@ -257,7 +257,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
||||
}
|
||||
|
||||
const graph = y1.custom ?? ({} as GraphFieldConfig);
|
||||
graph.drawStyle = angular.bars ? DrawStyle.Bars : angular.lines ? DrawStyle.Line : DrawStyle.Points;
|
||||
graph.drawStyle = angular.bars ? GraphDrawStyle.Bars : angular.lines ? GraphDrawStyle.Line : GraphDrawStyle.Points;
|
||||
|
||||
if (angular.points) {
|
||||
graph.showPoints = PointVisibility.Always;
|
||||
@@ -265,7 +265,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
||||
if (isNumber(angular.pointradius)) {
|
||||
graph.pointSize = 2 + angular.pointradius * 2;
|
||||
}
|
||||
} else if (graph.drawStyle !== DrawStyle.Points) {
|
||||
} else if (graph.drawStyle !== GraphDrawStyle.Points) {
|
||||
graph.showPoints = PointVisibility.Never;
|
||||
}
|
||||
|
||||
@@ -291,7 +291,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
||||
graph.lineInterpolation = LineInterpolation.StepAfter;
|
||||
}
|
||||
|
||||
if (graph.drawStyle === DrawStyle.Bars) {
|
||||
if (graph.drawStyle === GraphDrawStyle.Bars) {
|
||||
graph.fillOpacity = 100; // bars were always
|
||||
}
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { GraphFieldConfig, DrawStyle } from '@grafana/schema';
|
||||
import { GraphFieldConfig, GraphDrawStyle } from '@grafana/schema';
|
||||
import { PanelPlugin } from '@grafana/data';
|
||||
import { commonOptionsBuilder } from '@grafana/ui';
|
||||
import { XYChartPanel } from './XYChartPanel';
|
||||
@@ -10,7 +10,7 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(XYChartPanel)
|
||||
.useFieldConfig(
|
||||
getGraphFieldConfig({
|
||||
...defaultGraphConfig,
|
||||
drawStyle: DrawStyle.Points,
|
||||
drawStyle: GraphDrawStyle.Points,
|
||||
})
|
||||
)
|
||||
.setPanelOptions((builder) => {
|
||||
|
||||
Reference in New Issue
Block a user