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:
@@ -25,3 +25,6 @@ export { LayoutModes, LayoutMode } from './types/layout';
|
|||||||
export { PanelPlugin, SetFieldConfigOptionsArgs, StandardOptionConfig } from './panel/PanelPlugin';
|
export { PanelPlugin, SetFieldConfigOptionsArgs, StandardOptionConfig } from './panel/PanelPlugin';
|
||||||
export { createFieldConfigRegistry } from './panel/registryFactories';
|
export { createFieldConfigRegistry } from './panel/registryFactories';
|
||||||
export { QueryRunner, QueryRunnerOptions } from './types/queryRunner';
|
export { QueryRunner, QueryRunnerOptions } from './types/queryRunner';
|
||||||
|
|
||||||
|
// Moved to `@grafana/schema`, in Grafana 9, this will be removed
|
||||||
|
export * from './schema';
|
||||||
|
|||||||
11
packages/grafana-data/src/schema.ts
Normal file
11
packages/grafana-data/src/schema.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
// Moved to `@grafana/schema`, in Grafana 9, this will be removed
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// grafana/grafana/packages/grafana-schema$ grep export src/schema/*.ts
|
||||||
|
/**
|
||||||
|
* @deprecated Moved to `@grafana/schema` package and will be removed in Grafana 9
|
||||||
|
* @public
|
||||||
|
*/
|
||||||
|
export {
|
||||||
|
// Styles that changed
|
||||||
|
VizTextDisplayOptions as TextDisplayOptions, // rename
|
||||||
|
} from '@grafana/schema';
|
||||||
@@ -23,17 +23,6 @@ export interface DisplayValue extends FormattedValue {
|
|||||||
description?: string;
|
description?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Explicit control for text settings
|
|
||||||
* @deprecated Use VizTextDisplayOptions from @grafana/ui instead
|
|
||||||
*/
|
|
||||||
export type TextDisplayOptions = {
|
|
||||||
/* Explicit text size */
|
|
||||||
titleSize?: number;
|
|
||||||
/* Explicit text size */
|
|
||||||
valueSize?: number;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* These represents the display value with the longest title and text.
|
* These represents the display value with the longest title and text.
|
||||||
* Used to align widths and heights when displaying multiple DisplayValues
|
* Used to align widths and heights when displaying multiple DisplayValues
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export enum PointVisibility {
|
|||||||
Auto = 'auto',
|
Auto = 'auto',
|
||||||
Never = 'never',
|
Never = 'never',
|
||||||
}
|
}
|
||||||
export enum DrawStyle {
|
export enum GraphDrawStyle {
|
||||||
Bars = 'bars',
|
Bars = 'bars',
|
||||||
Line = 'line',
|
Line = 'line',
|
||||||
Points = 'points',
|
Points = 'points',
|
||||||
@@ -207,7 +207,7 @@ export interface GraphFieldConfig
|
|||||||
BarConfig,
|
BarConfig,
|
||||||
StackableFieldConfig,
|
StackableFieldConfig,
|
||||||
HideableFieldConfig {
|
HideableFieldConfig {
|
||||||
drawStyle?: DrawStyle;
|
drawStyle?: GraphDrawStyle;
|
||||||
gradientMode?: GraphGradientMode;
|
gradientMode?: GraphGradientMode;
|
||||||
thresholdsStyle?: GraphThresholdsStyleConfig;
|
thresholdsStyle?: GraphThresholdsStyleConfig;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { calculateFontSize } from '../../utils/measureText';
|
|||||||
// Types
|
// Types
|
||||||
import { BigValueColorMode, Props, BigValueJustifyMode, BigValueTextMode } from './BigValue';
|
import { BigValueColorMode, Props, BigValueJustifyMode, BigValueTextMode } from './BigValue';
|
||||||
import { getTextColorForBackground } from '../../utils';
|
import { getTextColorForBackground } from '../../utils';
|
||||||
import { DrawStyle, GraphFieldConfig } from '@grafana/schema';
|
import { GraphDrawStyle, GraphFieldConfig } from '@grafana/schema';
|
||||||
import { Sparkline } from '../Sparkline/Sparkline';
|
import { Sparkline } from '../Sparkline/Sparkline';
|
||||||
|
|
||||||
const LINE_HEIGHT = 1.2;
|
const LINE_HEIGHT = 1.2;
|
||||||
@@ -178,7 +178,7 @@ export abstract class BigValueLayout {
|
|||||||
// The graph field configuration applied to Y values
|
// The graph field configuration applied to Y values
|
||||||
const config: FieldConfig<GraphFieldConfig> = {
|
const config: FieldConfig<GraphFieldConfig> = {
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
lineWidth: 1,
|
lineWidth: 1,
|
||||||
fillColor,
|
fillColor,
|
||||||
lineColor,
|
lineColor,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import {
|
|||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import {
|
import {
|
||||||
BarAlignment,
|
BarAlignment,
|
||||||
DrawStyle,
|
GraphDrawStyle,
|
||||||
GraphFieldConfig,
|
GraphFieldConfig,
|
||||||
GraphGradientMode,
|
GraphGradientMode,
|
||||||
LineInterpolation,
|
LineInterpolation,
|
||||||
@@ -36,7 +36,7 @@ function mockDataFrame() {
|
|||||||
displayName: 'Metric 1',
|
displayName: 'Metric 1',
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
gradientMode: GraphGradientMode.Opacity,
|
gradientMode: GraphGradientMode.Opacity,
|
||||||
lineColor: '#ff0000',
|
lineColor: '#ff0000',
|
||||||
lineWidth: 2,
|
lineWidth: 2,
|
||||||
@@ -60,7 +60,7 @@ function mockDataFrame() {
|
|||||||
displayName: 'Metric 2',
|
displayName: 'Metric 2',
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Bars,
|
drawStyle: GraphDrawStyle.Bars,
|
||||||
gradientMode: GraphGradientMode.Hue,
|
gradientMode: GraphGradientMode.Hue,
|
||||||
lineColor: '#ff0000',
|
lineColor: '#ff0000',
|
||||||
lineWidth: 2,
|
lineWidth: 2,
|
||||||
@@ -84,7 +84,7 @@ function mockDataFrame() {
|
|||||||
displayName: 'Metric 3',
|
displayName: 'Metric 3',
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
gradientMode: GraphGradientMode.Opacity,
|
gradientMode: GraphGradientMode.Opacity,
|
||||||
lineColor: '#ff0000',
|
lineColor: '#ff0000',
|
||||||
lineWidth: 2,
|
lineWidth: 2,
|
||||||
@@ -107,7 +107,7 @@ function mockDataFrame() {
|
|||||||
displayName: 'Metric 4',
|
displayName: 'Metric 4',
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Bars,
|
drawStyle: GraphDrawStyle.Bars,
|
||||||
gradientMode: GraphGradientMode.Hue,
|
gradientMode: GraphGradientMode.Hue,
|
||||||
lineColor: '#ff0000',
|
lineColor: '#ff0000',
|
||||||
lineWidth: 2,
|
lineWidth: 2,
|
||||||
@@ -130,7 +130,7 @@ function mockDataFrame() {
|
|||||||
displayName: 'Metric 4',
|
displayName: 'Metric 4',
|
||||||
decimals: 2,
|
decimals: 2,
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Bars,
|
drawStyle: GraphDrawStyle.Bars,
|
||||||
gradientMode: GraphGradientMode.Hue,
|
gradientMode: GraphGradientMode.Hue,
|
||||||
lineColor: '#ff0000',
|
lineColor: '#ff0000',
|
||||||
lineWidth: 2,
|
lineWidth: 2,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import {
|
|||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import {
|
import {
|
||||||
AxisPlacement,
|
AxisPlacement,
|
||||||
DrawStyle,
|
GraphDrawStyle,
|
||||||
GraphFieldConfig,
|
GraphFieldConfig,
|
||||||
PointVisibility,
|
PointVisibility,
|
||||||
ScaleDirection,
|
ScaleDirection,
|
||||||
@@ -38,7 +38,7 @@ interface State {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const defaultConfig: GraphFieldConfig = {
|
const defaultConfig: GraphFieldConfig = {
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
showPoints: PointVisibility.Auto,
|
showPoints: PointVisibility.Auto,
|
||||||
axisPlacement: AxisPlacement.Hidden,
|
axisPlacement: AxisPlacement.Hidden,
|
||||||
};
|
};
|
||||||
@@ -162,7 +162,8 @@ export class Sparkline extends PureComponent<SparklineProps, State> {
|
|||||||
|
|
||||||
const colorMode = getFieldColorModeForField(field);
|
const colorMode = getFieldColorModeForField(field);
|
||||||
const seriesColor = colorMode.getCalculator(field, theme)(0, 0);
|
const seriesColor = colorMode.getCalculator(field, theme)(0, 0);
|
||||||
const pointsMode = customConfig.drawStyle === DrawStyle.Points ? PointVisibility.Always : customConfig.showPoints;
|
const pointsMode =
|
||||||
|
customConfig.drawStyle === GraphDrawStyle.Points ? PointVisibility.Always : customConfig.showPoints;
|
||||||
|
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
pxAlign: false,
|
pxAlign: false,
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { UPlotConfigBuilder, UPlotConfigPrepFn } from '../uPlot/config/UPlotConf
|
|||||||
import { FIXED_UNIT } from '../GraphNG/GraphNG';
|
import { FIXED_UNIT } from '../GraphNG/GraphNG';
|
||||||
import {
|
import {
|
||||||
AxisPlacement,
|
AxisPlacement,
|
||||||
DrawStyle,
|
GraphDrawStyle,
|
||||||
GraphFieldConfig,
|
GraphFieldConfig,
|
||||||
GraphTresholdsStyleMode,
|
GraphTresholdsStyleMode,
|
||||||
PointVisibility,
|
PointVisibility,
|
||||||
@@ -30,7 +30,7 @@ import uPlot from 'uplot';
|
|||||||
const defaultFormatter = (v: any) => (v == null ? '-' : v.toFixed(1));
|
const defaultFormatter = (v: any) => (v == null ? '-' : v.toFixed(1));
|
||||||
|
|
||||||
const defaultConfig: GraphFieldConfig = {
|
const defaultConfig: GraphFieldConfig = {
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
showPoints: PointVisibility.Auto,
|
showPoints: PointVisibility.Auto,
|
||||||
axisPlacement: AxisPlacement.Auto,
|
axisPlacement: AxisPlacement.Auto,
|
||||||
};
|
};
|
||||||
@@ -150,7 +150,8 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn<{ sync: DashboardCursor
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const showPoints = customConfig.drawStyle === DrawStyle.Points ? PointVisibility.Always : customConfig.showPoints;
|
const showPoints =
|
||||||
|
customConfig.drawStyle === GraphDrawStyle.Points ? PointVisibility.Always : customConfig.showPoints;
|
||||||
|
|
||||||
let pointsFilter: uPlot.Series.Points.Filter = () => null;
|
let pointsFilter: uPlot.Series.Points.Filter = () => null;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import React from 'react';
|
|||||||
import { UPlotChart } from './Plot';
|
import { UPlotChart } from './Plot';
|
||||||
import { render } from '@testing-library/react';
|
import { render } from '@testing-library/react';
|
||||||
import { ArrayVector, dateTime, FieldConfig, FieldType, MutableDataFrame } from '@grafana/data';
|
import { ArrayVector, dateTime, FieldConfig, FieldType, MutableDataFrame } from '@grafana/data';
|
||||||
import { GraphFieldConfig, DrawStyle } from '@grafana/schema';
|
import { GraphFieldConfig, GraphDrawStyle } from '@grafana/schema';
|
||||||
import uPlot from 'uplot';
|
import uPlot from 'uplot';
|
||||||
import createMockRaf from 'mock-raf';
|
import createMockRaf from 'mock-raf';
|
||||||
import { UPlotConfigBuilder } from './config/UPlotConfigBuilder';
|
import { UPlotConfigBuilder } from './config/UPlotConfigBuilder';
|
||||||
@@ -42,7 +42,7 @@ const mockData = () => {
|
|||||||
values: new ArrayVector([10, 20, 5]),
|
values: new ArrayVector([10, 20, 5]),
|
||||||
config: {
|
config: {
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
},
|
},
|
||||||
} as FieldConfig<GraphFieldConfig>,
|
} as FieldConfig<GraphFieldConfig>,
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import { SelectableValue } from '@grafana/data';
|
|||||||
import {
|
import {
|
||||||
AxisPlacement,
|
AxisPlacement,
|
||||||
BarAlignment,
|
BarAlignment,
|
||||||
DrawStyle,
|
GraphDrawStyle,
|
||||||
GraphGradientMode,
|
GraphGradientMode,
|
||||||
GraphTresholdsStyleMode,
|
GraphTresholdsStyleMode,
|
||||||
LineInterpolation,
|
LineInterpolation,
|
||||||
@@ -15,10 +15,10 @@ import {
|
|||||||
*/
|
*/
|
||||||
export const graphFieldOptions = {
|
export const graphFieldOptions = {
|
||||||
drawStyle: [
|
drawStyle: [
|
||||||
{ label: 'Lines', value: DrawStyle.Line },
|
{ label: 'Lines', value: GraphDrawStyle.Line },
|
||||||
{ label: 'Bars', value: DrawStyle.Bars },
|
{ label: 'Bars', value: GraphDrawStyle.Bars },
|
||||||
{ label: 'Points', value: DrawStyle.Points },
|
{ label: 'Points', value: GraphDrawStyle.Points },
|
||||||
] as Array<SelectableValue<DrawStyle>>,
|
] as Array<SelectableValue<GraphDrawStyle>>,
|
||||||
|
|
||||||
lineInterpolation: [
|
lineInterpolation: [
|
||||||
{ description: 'Linear', value: LineInterpolation.Linear, icon: 'gf-interpolation-linear' },
|
{ description: 'Linear', value: LineInterpolation.Linear, icon: 'gf-interpolation-linear' },
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { UPlotConfigBuilder } from './UPlotConfigBuilder';
|
|||||||
import {
|
import {
|
||||||
GraphGradientMode,
|
GraphGradientMode,
|
||||||
AxisPlacement,
|
AxisPlacement,
|
||||||
DrawStyle,
|
GraphDrawStyle,
|
||||||
PointVisibility,
|
PointVisibility,
|
||||||
ScaleOrientation,
|
ScaleOrientation,
|
||||||
ScaleDirection,
|
ScaleDirection,
|
||||||
@@ -417,7 +417,7 @@ describe('UPlotConfigBuilder', () => {
|
|||||||
it('when fillColor is not set fill', () => {
|
it('when fillColor is not set fill', () => {
|
||||||
const builder = new UPlotConfigBuilder();
|
const builder = new UPlotConfigBuilder();
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
scaleKey: 'scale-x',
|
scaleKey: 'scale-x',
|
||||||
lineColor: '#0000ff',
|
lineColor: '#0000ff',
|
||||||
theme: darkTheme,
|
theme: darkTheme,
|
||||||
@@ -429,7 +429,7 @@ describe('UPlotConfigBuilder', () => {
|
|||||||
it('when fillOpacity is set', () => {
|
it('when fillOpacity is set', () => {
|
||||||
const builder = new UPlotConfigBuilder();
|
const builder = new UPlotConfigBuilder();
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
scaleKey: 'scale-x',
|
scaleKey: 'scale-x',
|
||||||
lineColor: '#FFAABB',
|
lineColor: '#FFAABB',
|
||||||
fillOpacity: 50,
|
fillOpacity: 50,
|
||||||
@@ -442,7 +442,7 @@ describe('UPlotConfigBuilder', () => {
|
|||||||
it('when fillColor is set ignore fillOpacity', () => {
|
it('when fillColor is set ignore fillOpacity', () => {
|
||||||
const builder = new UPlotConfigBuilder();
|
const builder = new UPlotConfigBuilder();
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
scaleKey: 'scale-x',
|
scaleKey: 'scale-x',
|
||||||
lineColor: '#FFAABB',
|
lineColor: '#FFAABB',
|
||||||
fillOpacity: 50,
|
fillOpacity: 50,
|
||||||
@@ -456,7 +456,7 @@ describe('UPlotConfigBuilder', () => {
|
|||||||
it('when fillGradient mode is opacity', () => {
|
it('when fillGradient mode is opacity', () => {
|
||||||
const builder = new UPlotConfigBuilder();
|
const builder = new UPlotConfigBuilder();
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
scaleKey: 'scale-x',
|
scaleKey: 'scale-x',
|
||||||
lineColor: '#FFAABB',
|
lineColor: '#FFAABB',
|
||||||
fillOpacity: 50,
|
fillOpacity: 50,
|
||||||
@@ -470,7 +470,7 @@ describe('UPlotConfigBuilder', () => {
|
|||||||
it('allows series configuration', () => {
|
it('allows series configuration', () => {
|
||||||
const builder = new UPlotConfigBuilder();
|
const builder = new UPlotConfigBuilder();
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
scaleKey: 'scale-x',
|
scaleKey: 'scale-x',
|
||||||
fillOpacity: 50,
|
fillOpacity: 50,
|
||||||
gradientMode: GraphGradientMode.Opacity,
|
gradientMode: GraphGradientMode.Opacity,
|
||||||
@@ -534,7 +534,7 @@ describe('UPlotConfigBuilder', () => {
|
|||||||
const builder = new UPlotConfigBuilder();
|
const builder = new UPlotConfigBuilder();
|
||||||
builder.setStacking();
|
builder.setStacking();
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
scaleKey: 'scale-x',
|
scaleKey: 'scale-x',
|
||||||
fillOpacity: 50,
|
fillOpacity: 50,
|
||||||
gradientMode: GraphGradientMode.Opacity,
|
gradientMode: GraphGradientMode.Opacity,
|
||||||
@@ -545,7 +545,7 @@ describe('UPlotConfigBuilder', () => {
|
|||||||
theme: darkTheme,
|
theme: darkTheme,
|
||||||
});
|
});
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
scaleKey: 'scale-x',
|
scaleKey: 'scale-x',
|
||||||
fillOpacity: 50,
|
fillOpacity: 50,
|
||||||
gradientMode: GraphGradientMode.Opacity,
|
gradientMode: GraphGradientMode.Opacity,
|
||||||
@@ -558,7 +558,7 @@ describe('UPlotConfigBuilder', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
builder.addSeries({
|
builder.addSeries({
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
scaleKey: 'scale-x',
|
scaleKey: 'scale-x',
|
||||||
fillOpacity: 50,
|
fillOpacity: 50,
|
||||||
gradientMode: GraphGradientMode.Opacity,
|
gradientMode: GraphGradientMode.Opacity,
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import uPlot, { Series } from 'uplot';
|
|||||||
import {
|
import {
|
||||||
BarAlignment,
|
BarAlignment,
|
||||||
BarConfig,
|
BarConfig,
|
||||||
DrawStyle,
|
GraphDrawStyle,
|
||||||
FillConfig,
|
FillConfig,
|
||||||
GraphGradientMode,
|
GraphGradientMode,
|
||||||
LineConfig,
|
LineConfig,
|
||||||
@@ -29,7 +29,7 @@ export interface SeriesProps extends LineConfig, BarConfig, FillConfig, PointsCo
|
|||||||
thresholds?: ThresholdsConfig;
|
thresholds?: ThresholdsConfig;
|
||||||
/** Used when gradientMode is set to Scheme */
|
/** Used when gradientMode is set to Scheme */
|
||||||
colorMode?: FieldColorMode;
|
colorMode?: FieldColorMode;
|
||||||
drawStyle?: DrawStyle;
|
drawStyle?: GraphDrawStyle;
|
||||||
pathBuilder?: Series.PathBuilder;
|
pathBuilder?: Series.PathBuilder;
|
||||||
pointsFilter?: Series.Points.Filter;
|
pointsFilter?: Series.Points.Filter;
|
||||||
pointsBuilder?: Series.Points.Show;
|
pointsBuilder?: Series.Points.Show;
|
||||||
@@ -64,13 +64,13 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder<SeriesProps, Series> {
|
|||||||
|
|
||||||
let lineColor = this.getLineColor();
|
let lineColor = this.getLineColor();
|
||||||
|
|
||||||
// DrawStyle.Points mode also needs this for fill/stroke sharing & re-use in series.points. see getColor() below.
|
// GraphDrawStyle.Points mode also needs this for fill/stroke sharing & re-use in series.points. see getColor() below.
|
||||||
lineConfig.stroke = lineColor;
|
lineConfig.stroke = lineColor;
|
||||||
|
|
||||||
if (pathBuilder != null) {
|
if (pathBuilder != null) {
|
||||||
lineConfig.paths = pathBuilder;
|
lineConfig.paths = pathBuilder;
|
||||||
lineConfig.width = lineWidth;
|
lineConfig.width = lineWidth;
|
||||||
} else if (drawStyle === DrawStyle.Points) {
|
} else if (drawStyle === GraphDrawStyle.Points) {
|
||||||
lineConfig.paths = () => null;
|
lineConfig.paths = () => null;
|
||||||
} else if (drawStyle != null) {
|
} else if (drawStyle != null) {
|
||||||
lineConfig.width = lineWidth;
|
lineConfig.width = lineWidth;
|
||||||
@@ -109,11 +109,11 @@ export class UPlotSeriesBuilder extends PlotConfigBuilder<SeriesProps, Series> {
|
|||||||
pointsConfig.points!.show = pointsBuilder;
|
pointsConfig.points!.show = pointsBuilder;
|
||||||
} else {
|
} else {
|
||||||
// we cannot set points.show property above (even to undefined) as that will clear uPlot's default auto behavior
|
// we cannot set points.show property above (even to undefined) as that will clear uPlot's default auto behavior
|
||||||
if (drawStyle === DrawStyle.Points) {
|
if (drawStyle === GraphDrawStyle.Points) {
|
||||||
pointsConfig.points!.show = true;
|
pointsConfig.points!.show = true;
|
||||||
} else {
|
} else {
|
||||||
if (showPoints === PointVisibility.Auto) {
|
if (showPoints === PointVisibility.Auto) {
|
||||||
if (drawStyle === DrawStyle.Bars) {
|
if (drawStyle === GraphDrawStyle.Bars) {
|
||||||
pointsConfig.points!.show = false;
|
pointsConfig.points!.show = false;
|
||||||
}
|
}
|
||||||
} else if (showPoints === PointVisibility.Never) {
|
} else if (showPoints === PointVisibility.Never) {
|
||||||
@@ -184,7 +184,7 @@ interface PathBuilders {
|
|||||||
let builders: PathBuilders | undefined = undefined;
|
let builders: PathBuilders | undefined = undefined;
|
||||||
|
|
||||||
function mapDrawStyleToPathBuilder(
|
function mapDrawStyleToPathBuilder(
|
||||||
style: DrawStyle,
|
style: GraphDrawStyle,
|
||||||
lineInterpolation?: LineInterpolation,
|
lineInterpolation?: LineInterpolation,
|
||||||
barAlignment = 0,
|
barAlignment = 0,
|
||||||
barWidthFactor = 0.6,
|
barWidthFactor = 0.6,
|
||||||
@@ -202,7 +202,7 @@ function mapDrawStyleToPathBuilder(
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (style === DrawStyle.Bars) {
|
if (style === GraphDrawStyle.Bars) {
|
||||||
// each bars pathBuilder is lazy-initialized and globally cached by a key composed of its options
|
// each bars pathBuilder is lazy-initialized and globally cached by a key composed of its options
|
||||||
let barsCfgKey = `bars|${barAlignment}|${barWidthFactor}|${barMaxWidth}`;
|
let barsCfgKey = `bars|${barAlignment}|${barWidthFactor}|${barMaxWidth}`;
|
||||||
|
|
||||||
@@ -214,7 +214,7 @@ function mapDrawStyleToPathBuilder(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return builders[barsCfgKey];
|
return builders[barsCfgKey];
|
||||||
} else if (style === DrawStyle.Line) {
|
} else if (style === GraphDrawStyle.Line) {
|
||||||
if (lineInterpolation === LineInterpolation.StepBefore) {
|
if (lineInterpolation === LineInterpolation.StepBefore) {
|
||||||
return builders.stepBefore;
|
return builders.stepBefore;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,8 @@ export * from './themes';
|
|||||||
export * from './options';
|
export * from './options';
|
||||||
export * from './slate-plugins';
|
export * from './slate-plugins';
|
||||||
|
|
||||||
|
// Moved to `@grafana/schema`, in Grafana 9, this will be removed
|
||||||
|
export * from './schema';
|
||||||
|
|
||||||
// Exposes standard editors for registries of optionsUi config and panel options UI
|
// Exposes standard editors for registries of optionsUi config and panel options UI
|
||||||
export { getStandardFieldConfigs, getStandardOptionEditors } from './utils/standardEditors';
|
export { getStandardFieldConfigs, getStandardOptionEditors } from './utils/standardEditors';
|
||||||
|
|||||||
45
packages/grafana-ui/src/schema.ts
Normal file
45
packages/grafana-ui/src/schema.ts
Normal file
@@ -0,0 +1,45 @@
|
|||||||
|
// Moved to `@grafana/schema`, in Grafana 9, this will be removed
|
||||||
|
//---------------------------------------------------------------
|
||||||
|
// grafana/grafana/packages/grafana-schema$ grep export src/schema/*.ts
|
||||||
|
|
||||||
|
export {
|
||||||
|
// Styles that changed
|
||||||
|
GraphDrawStyle as DrawStyle,
|
||||||
|
// All exports
|
||||||
|
AxisPlacement,
|
||||||
|
PointVisibility,
|
||||||
|
LineInterpolation,
|
||||||
|
ScaleDistribution,
|
||||||
|
GraphGradientMode,
|
||||||
|
LineStyle,
|
||||||
|
PointsConfig,
|
||||||
|
ScaleDistributionConfig,
|
||||||
|
HideSeriesConfig,
|
||||||
|
BarAlignment,
|
||||||
|
BarValueVisibility,
|
||||||
|
ScaleOrientation,
|
||||||
|
ScaleDirection,
|
||||||
|
LineConfig,
|
||||||
|
BarConfig,
|
||||||
|
FillConfig,
|
||||||
|
AxisConfig,
|
||||||
|
HideableFieldConfig,
|
||||||
|
StackingMode,
|
||||||
|
StackingConfig,
|
||||||
|
StackableFieldConfig,
|
||||||
|
GraphTresholdsStyleMode,
|
||||||
|
GraphThresholdsStyleConfig,
|
||||||
|
GraphFieldConfig,
|
||||||
|
LegendPlacement,
|
||||||
|
LegendDisplayMode,
|
||||||
|
VizLegendOptions,
|
||||||
|
OptionsWithLegend,
|
||||||
|
TableFieldOptions,
|
||||||
|
TableCellDisplayMode,
|
||||||
|
FieldTextAlignment,
|
||||||
|
VizTextDisplayOptions,
|
||||||
|
OptionsWithTextFormatting,
|
||||||
|
TooltipDisplayMode,
|
||||||
|
VizTooltipOptions,
|
||||||
|
OptionsWithTooltip,
|
||||||
|
} from '@grafana/schema';
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import { size } from 'lodash';
|
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 { ansicolor, colors } from '@grafana/ui';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@@ -145,7 +145,7 @@ export function makeDataFramesForLogs(sortedRows: LogRowModel[], bucketSize: num
|
|||||||
data.fields[valueField.index].config.decimals = 0;
|
data.fields[valueField.index].config.decimals = 0;
|
||||||
|
|
||||||
data.fields[valueField.index].config.custom = {
|
data.fields[valueField.index].config.custom = {
|
||||||
drawStyle: DrawStyle.Bars,
|
drawStyle: GraphDrawStyle.Bars,
|
||||||
barAlignment: BarAlignment.Center,
|
barAlignment: BarAlignment.Center,
|
||||||
barWidthFactor: 0.9,
|
barWidthFactor: 0.9,
|
||||||
barMaxWidth: 5,
|
barMaxWidth: 5,
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import {
|
|||||||
useTheme2,
|
useTheme2,
|
||||||
ZoomPlugin,
|
ZoomPlugin,
|
||||||
} from '@grafana/ui';
|
} 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 { defaultGraphConfig, getGraphFieldConfig } from 'app/plugins/panel/timeseries/config';
|
||||||
import { ContextMenuPlugin } from 'app/plugins/panel/timeseries/plugins/ContextMenuPlugin';
|
import { ContextMenuPlugin } from 'app/plugins/panel/timeseries/plugins/ContextMenuPlugin';
|
||||||
import { ExemplarsPlugin } from 'app/plugins/panel/timeseries/plugins/ExemplarsPlugin';
|
import { ExemplarsPlugin } from 'app/plugins/panel/timeseries/plugins/ExemplarsPlugin';
|
||||||
@@ -83,7 +83,7 @@ export function ExploreGraphNGPanel({
|
|||||||
mode: FieldColorModeId.PaletteClassic,
|
mode: FieldColorModeId.PaletteClassic,
|
||||||
},
|
},
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
fillOpacity: 0,
|
fillOpacity: 0,
|
||||||
pointSize: 5,
|
pointSize: 5,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { DrawStyle, StackingMode } from '@grafana/schema';
|
import { GraphDrawStyle, StackingMode } from '@grafana/schema';
|
||||||
import { lastValueFrom } from 'rxjs';
|
import { lastValueFrom } from 'rxjs';
|
||||||
import {
|
import {
|
||||||
ArrayVector,
|
ArrayVector,
|
||||||
@@ -365,7 +365,7 @@ describe('decorateWithLogsResult', () => {
|
|||||||
decimals: 0,
|
decimals: 0,
|
||||||
unit: undefined,
|
unit: undefined,
|
||||||
custom: {
|
custom: {
|
||||||
drawStyle: DrawStyle.Bars,
|
drawStyle: GraphDrawStyle.Bars,
|
||||||
barAlignment: 0,
|
barAlignment: 0,
|
||||||
barMaxWidth: 5,
|
barMaxWidth: 5,
|
||||||
barWidthFactor: 0.9,
|
barWidthFactor: 0.9,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import {
|
import {
|
||||||
BarAlignment,
|
BarAlignment,
|
||||||
DrawStyle,
|
GraphDrawStyle,
|
||||||
GraphFieldConfig,
|
GraphFieldConfig,
|
||||||
GraphGradientMode,
|
GraphGradientMode,
|
||||||
LineInterpolation,
|
LineInterpolation,
|
||||||
@@ -26,7 +26,7 @@ import { SpanNullsEditor } from './SpanNullsEditor';
|
|||||||
import { ThresholdsStyleEditor } from './ThresholdsStyleEditor';
|
import { ThresholdsStyleEditor } from './ThresholdsStyleEditor';
|
||||||
|
|
||||||
export const defaultGraphConfig: GraphFieldConfig = {
|
export const defaultGraphConfig: GraphFieldConfig = {
|
||||||
drawStyle: DrawStyle.Line,
|
drawStyle: GraphDrawStyle.Line,
|
||||||
lineInterpolation: LineInterpolation.Linear,
|
lineInterpolation: LineInterpolation.Linear,
|
||||||
lineWidth: 1,
|
lineWidth: 1,
|
||||||
fillOpacity: 0,
|
fillOpacity: 0,
|
||||||
@@ -73,7 +73,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
settings: {
|
settings: {
|
||||||
options: graphFieldOptions.lineInterpolation,
|
options: graphFieldOptions.lineInterpolation,
|
||||||
},
|
},
|
||||||
showIf: (c) => c.drawStyle === DrawStyle.Line,
|
showIf: (c) => c.drawStyle === GraphDrawStyle.Line,
|
||||||
})
|
})
|
||||||
.addRadio({
|
.addRadio({
|
||||||
path: 'barAlignment',
|
path: 'barAlignment',
|
||||||
@@ -83,7 +83,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
settings: {
|
settings: {
|
||||||
options: graphFieldOptions.barAlignment,
|
options: graphFieldOptions.barAlignment,
|
||||||
},
|
},
|
||||||
showIf: (c) => c.drawStyle === DrawStyle.Bars,
|
showIf: (c) => c.drawStyle === GraphDrawStyle.Bars,
|
||||||
})
|
})
|
||||||
.addSliderInput({
|
.addSliderInput({
|
||||||
path: 'lineWidth',
|
path: 'lineWidth',
|
||||||
@@ -95,7 +95,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
max: 10,
|
max: 10,
|
||||||
step: 1,
|
step: 1,
|
||||||
},
|
},
|
||||||
showIf: (c) => c.drawStyle !== DrawStyle.Points,
|
showIf: (c) => c.drawStyle !== GraphDrawStyle.Points,
|
||||||
})
|
})
|
||||||
.addSliderInput({
|
.addSliderInput({
|
||||||
path: 'fillOpacity',
|
path: 'fillOpacity',
|
||||||
@@ -107,7 +107,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
max: 100,
|
max: 100,
|
||||||
step: 1,
|
step: 1,
|
||||||
},
|
},
|
||||||
showIf: (c) => c.drawStyle !== DrawStyle.Points,
|
showIf: (c) => c.drawStyle !== GraphDrawStyle.Points,
|
||||||
})
|
})
|
||||||
.addRadio({
|
.addRadio({
|
||||||
path: 'gradientMode',
|
path: 'gradientMode',
|
||||||
@@ -117,7 +117,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
settings: {
|
settings: {
|
||||||
options: graphFieldOptions.fillGradient,
|
options: graphFieldOptions.fillGradient,
|
||||||
},
|
},
|
||||||
showIf: (c) => c.drawStyle !== DrawStyle.Points,
|
showIf: (c) => c.drawStyle !== GraphDrawStyle.Points,
|
||||||
})
|
})
|
||||||
.addCustomEditor({
|
.addCustomEditor({
|
||||||
id: 'fillBelowTo',
|
id: 'fillBelowTo',
|
||||||
@@ -135,7 +135,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
path: 'lineStyle',
|
path: 'lineStyle',
|
||||||
name: 'Line style',
|
name: 'Line style',
|
||||||
category: categoryStyles,
|
category: categoryStyles,
|
||||||
showIf: (c) => c.drawStyle === DrawStyle.Line,
|
showIf: (c) => c.drawStyle === GraphDrawStyle.Line,
|
||||||
editor: LineStyleEditor,
|
editor: LineStyleEditor,
|
||||||
override: LineStyleEditor,
|
override: LineStyleEditor,
|
||||||
process: identityOverrideProcessor,
|
process: identityOverrideProcessor,
|
||||||
@@ -149,7 +149,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
defaultValue: false,
|
defaultValue: false,
|
||||||
editor: SpanNullsEditor,
|
editor: SpanNullsEditor,
|
||||||
override: SpanNullsEditor,
|
override: SpanNullsEditor,
|
||||||
showIf: (c) => c.drawStyle === DrawStyle.Line,
|
showIf: (c) => c.drawStyle === GraphDrawStyle.Line,
|
||||||
shouldApply: (f) => f.type !== FieldType.time,
|
shouldApply: (f) => f.type !== FieldType.time,
|
||||||
process: identityOverrideProcessor,
|
process: identityOverrideProcessor,
|
||||||
})
|
})
|
||||||
@@ -161,7 +161,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
settings: {
|
settings: {
|
||||||
options: graphFieldOptions.showPoints,
|
options: graphFieldOptions.showPoints,
|
||||||
},
|
},
|
||||||
showIf: (c) => c.drawStyle !== DrawStyle.Points,
|
showIf: (c) => c.drawStyle !== GraphDrawStyle.Points,
|
||||||
})
|
})
|
||||||
.addSliderInput({
|
.addSliderInput({
|
||||||
path: 'pointSize',
|
path: 'pointSize',
|
||||||
@@ -173,7 +173,7 @@ export function getGraphFieldConfig(cfg: GraphFieldConfig): SetFieldConfigOption
|
|||||||
max: 40,
|
max: 40,
|
||||||
step: 1,
|
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);
|
commonOptionsBuilder.addStackingConfig(builder, cfg.stacking, categoryStyles);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import {
|
|||||||
LegendDisplayMode,
|
LegendDisplayMode,
|
||||||
TooltipDisplayMode,
|
TooltipDisplayMode,
|
||||||
AxisPlacement,
|
AxisPlacement,
|
||||||
DrawStyle,
|
GraphDrawStyle,
|
||||||
GraphFieldConfig,
|
GraphFieldConfig,
|
||||||
GraphGradientMode,
|
GraphGradientMode,
|
||||||
GraphTresholdsStyleMode,
|
GraphTresholdsStyleMode,
|
||||||
@@ -173,7 +173,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
|||||||
if (v) {
|
if (v) {
|
||||||
rule.properties.push({
|
rule.properties.push({
|
||||||
id: 'custom.drawStyle',
|
id: 'custom.drawStyle',
|
||||||
value: DrawStyle.Bars,
|
value: GraphDrawStyle.Bars,
|
||||||
});
|
});
|
||||||
rule.properties.push({
|
rule.properties.push({
|
||||||
id: 'custom.fillOpacity',
|
id: 'custom.fillOpacity',
|
||||||
@@ -182,7 +182,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
|||||||
} else {
|
} else {
|
||||||
rule.properties.push({
|
rule.properties.push({
|
||||||
id: 'custom.drawStyle',
|
id: 'custom.drawStyle',
|
||||||
value: DrawStyle.Line, // Change from bars
|
value: GraphDrawStyle.Line, // Change from bars
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -257,7 +257,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
|||||||
}
|
}
|
||||||
|
|
||||||
const graph = y1.custom ?? ({} as GraphFieldConfig);
|
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) {
|
if (angular.points) {
|
||||||
graph.showPoints = PointVisibility.Always;
|
graph.showPoints = PointVisibility.Always;
|
||||||
@@ -265,7 +265,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
|||||||
if (isNumber(angular.pointradius)) {
|
if (isNumber(angular.pointradius)) {
|
||||||
graph.pointSize = 2 + angular.pointradius * 2;
|
graph.pointSize = 2 + angular.pointradius * 2;
|
||||||
}
|
}
|
||||||
} else if (graph.drawStyle !== DrawStyle.Points) {
|
} else if (graph.drawStyle !== GraphDrawStyle.Points) {
|
||||||
graph.showPoints = PointVisibility.Never;
|
graph.showPoints = PointVisibility.Never;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +291,7 @@ export function flotToGraphOptions(angular: any): { fieldConfig: FieldConfigSour
|
|||||||
graph.lineInterpolation = LineInterpolation.StepAfter;
|
graph.lineInterpolation = LineInterpolation.StepAfter;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (graph.drawStyle === DrawStyle.Bars) {
|
if (graph.drawStyle === GraphDrawStyle.Bars) {
|
||||||
graph.fillOpacity = 100; // bars were always
|
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 { PanelPlugin } from '@grafana/data';
|
||||||
import { commonOptionsBuilder } from '@grafana/ui';
|
import { commonOptionsBuilder } from '@grafana/ui';
|
||||||
import { XYChartPanel } from './XYChartPanel';
|
import { XYChartPanel } from './XYChartPanel';
|
||||||
@@ -10,7 +10,7 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(XYChartPanel)
|
|||||||
.useFieldConfig(
|
.useFieldConfig(
|
||||||
getGraphFieldConfig({
|
getGraphFieldConfig({
|
||||||
...defaultGraphConfig,
|
...defaultGraphConfig,
|
||||||
drawStyle: DrawStyle.Points,
|
drawStyle: GraphDrawStyle.Points,
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
.setPanelOptions((builder) => {
|
.setPanelOptions((builder) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user