mirror of https://github.com/grafana/grafana
XY Panel: Add and use schema for XY Panel configuration (#62148)
* Add schema for XYChart * Minor cleanup * remove unessecary fields from ScatterFieldConfigVeneer, and cleaning up more * Fix counts Co-authored-by: sam boyer <sdboyer@grafana.com>pull/62167/head
parent
eb1293ebb1
commit
f3aa058886
@ -0,0 +1,132 @@ |
||||
--- |
||||
keywords: |
||||
- grafana |
||||
- schema |
||||
title: XYChartPanelCfg kind |
||||
--- |
||||
> Both documentation generation and kinds schemas are in active development and subject to change without prior notice. |
||||
|
||||
# XYChartPanelCfg kind |
||||
|
||||
## Maturity: experimental |
||||
## Version: 0.0 |
||||
|
||||
## Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|-----------------------|--------------------------------|----------|---------------------------------------------------------| |
||||
| `PanelOptions` | [object](#paneloptions) | **Yes** | | |
||||
| `ScatterFieldConfig` | [object](#scatterfieldconfig) | **Yes** | | |
||||
| `ScatterSeriesConfig` | [object](#scatterseriesconfig) | **Yes** | | |
||||
| `ScatterShow` | string | **Yes** | Possible values are: `points`, `lines`, `points+lines`. | |
||||
| `SeriesMapping` | string | **Yes** | Possible values are: `auto`, `manual`. | |
||||
| `XYDimensionConfig` | [object](#xydimensionconfig) | **Yes** | | |
||||
|
||||
## PanelOptions |
||||
|
||||
### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|-----------------|-----------------------------------------------|----------|----------------------------------------| |
||||
| `dims` | [XYDimensionConfig](#xydimensionconfig) | No | | |
||||
| `seriesMapping` | string | No | Possible values are: `auto`, `manual`. | |
||||
| `series` | [ScatterSeriesConfig](#scatterseriesconfig)[] | No | | |
||||
|
||||
### ScatterSeriesConfig |
||||
|
||||
#### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|----------|--------|----------|-------------| |
||||
| `name` | string | No | | |
||||
| `x` | string | No | | |
||||
| `y` | string | No | | |
||||
|
||||
### XYDimensionConfig |
||||
|
||||
#### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|-----------|----------|----------|-------------| |
||||
| `frame` | integer | **Yes** | | |
||||
| `exclude` | string[] | No | | |
||||
| `x` | string | No | | |
||||
|
||||
## ScatterFieldConfig |
||||
|
||||
### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|--------------|-----------------------------------------------|----------|-------------------------------------------------------------| |
||||
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | |
||||
| `label` | string | No | TODO docs Possible values are: `auto`, `never`, `always`. | |
||||
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | This is actually an empty interface used mainly for naming? | |
||||
| `lineStyle` | [LineStyle](#linestyle) | No | TODO docs | |
||||
| `lineWidth` | integer | No | | |
||||
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | This is actually an empty interface used mainly for naming? | |
||||
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | |
||||
| `show` | string | No | Possible values are: `points`, `lines`, `points+lines`. | |
||||
|
||||
### ColorDimensionConfig |
||||
|
||||
This is actually an empty interface used mainly for naming? |
||||
|
||||
| Property | Type | Required | Description | |
||||
|----------|------|----------|-------------| |
||||
|
||||
### ColorDimensionConfig |
||||
|
||||
This is actually an empty interface used mainly for naming? |
||||
|
||||
| Property | Type | Required | Description | |
||||
|----------|------|----------|-------------| |
||||
|
||||
### LineStyle |
||||
|
||||
TODO docs |
||||
|
||||
#### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|----------|----------|----------|--------------------------------------------------------| |
||||
| `dash` | number[] | No | | |
||||
| `fill` | string | No | Possible values are: `solid`, `dash`, `dot`, `square`. | |
||||
|
||||
### ScaleDimensionConfig |
||||
|
||||
#### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|----------|---------|----------|-------------| |
||||
| `max` | integer | No | | |
||||
| `min` | integer | No | | |
||||
|
||||
### TextDimensionConfig |
||||
|
||||
#### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|----------|--------|----------|----------------------------------------------------| |
||||
| `mode` | string | No | Possible values are: `fixed`, `field`, `template`. | |
||||
|
||||
## ScatterSeriesConfig |
||||
|
||||
### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|----------|--------|----------|-------------| |
||||
| `name` | string | No | | |
||||
| `x` | string | No | | |
||||
| `y` | string | No | | |
||||
|
||||
## XYDimensionConfig |
||||
|
||||
### Properties |
||||
|
||||
| Property | Type | Required | Description | |
||||
|-----------|----------|----------|-------------| |
||||
| `frame` | integer | **Yes** | | |
||||
| `exclude` | string[] | No | | |
||||
| `x` | string | No | | |
||||
|
||||
|
||||
@ -0,0 +1,25 @@ |
||||
package common |
||||
|
||||
BaseDimensionConfig: { |
||||
field?: string |
||||
fixed: string | number |
||||
}@cuetsy(kind="interface") |
||||
|
||||
ScaleDimensionConfig: { |
||||
BaseDimensionConfig |
||||
min: int32 |
||||
max: int32 |
||||
}@cuetsy(kind="interface") |
||||
|
||||
// This is actually an empty interface used mainly for naming? |
||||
ColorDimensionConfig: { |
||||
BaseDimensionConfig |
||||
_empty: _ |
||||
}@cuetsy(kind="interface") |
||||
|
||||
TextDimensionMode: "fixed" | "field" | "template" @cuetsy(kind="enum") |
||||
|
||||
TextDimensionConfig: { |
||||
BaseDimensionConfig |
||||
mode: TextDimensionMode |
||||
}@cuetsy(kind="interface") |
||||
@ -0,0 +1,79 @@ |
||||
// Copyright 2023 Grafana Labs |
||||
// |
||||
// Licensed under the Apache License, Version 2.0 (the "License"); |
||||
// you may not use this file except in compliance with the License. |
||||
// You may obtain a copy of the License at |
||||
// |
||||
// http://www.apache.org/licenses/LICENSE-2.0 |
||||
// |
||||
// Unless required by applicable law or agreed to in writing, software |
||||
// distributed under the License is distributed on an "AS IS" BASIS, |
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
// See the License for the specific language governing permissions and |
||||
// limitations under the License. |
||||
|
||||
package grafanaplugin |
||||
|
||||
import ( |
||||
"github.com/grafana/grafana/packages/grafana-schema/src/common" |
||||
"github.com/grafana/grafana/pkg/plugins/pfs" |
||||
) |
||||
|
||||
// This file (with its sibling .cue files) implements pfs.GrafanaPlugin |
||||
pfs.GrafanaPlugin |
||||
|
||||
composableKinds: PanelCfg: { |
||||
maturity: "experimental" |
||||
|
||||
lineage: { |
||||
seqs: [ |
||||
{ |
||||
schemas: [ |
||||
{ |
||||
|
||||
SeriesMapping: "auto" | "manual" @cuetsy(kind="enum") |
||||
ScatterShow: "points" | "lines" | "points+lines" @cuetsy(kind="enum", memberNames="Points|Lines|PointsAndLines") |
||||
|
||||
XYDimensionConfig: { |
||||
frame: int32 & >=0 |
||||
x?: string |
||||
exclude?: [...string] |
||||
} @cuetsy(kind="interface") |
||||
|
||||
ScatterFieldConfig: { |
||||
common.HideableFieldConfig |
||||
common.AxisConfig |
||||
|
||||
show?: ScatterShow | *"points" |
||||
|
||||
pointSize?: common.ScaleDimensionConfig |
||||
lineColor?: common.ColorDimensionConfig |
||||
pointColor?: common.ColorDimensionConfig |
||||
labelValue?: common.TextDimensionConfig |
||||
|
||||
lineWidth?: int32 & >=0 |
||||
lineStyle?: common.LineStyle |
||||
label?: common.VisibilityMode | *"auto" |
||||
} @cuetsy(kind="interface",TSVeneer="type") |
||||
|
||||
ScatterSeriesConfig: { |
||||
ScatterFieldConfig |
||||
x?: string |
||||
y?: string |
||||
name?: string |
||||
} @cuetsy(kind="interface") |
||||
|
||||
PanelOptions: { |
||||
common.OptionsWithLegend |
||||
common.OptionsWithTooltip |
||||
|
||||
seriesMapping?: SeriesMapping |
||||
dims: XYDimensionConfig |
||||
series: [...ScatterSeriesConfig] |
||||
} @cuetsy(kind="interface") |
||||
}, |
||||
] |
||||
}, |
||||
] |
||||
} |
||||
} |
||||
@ -0,0 +1,66 @@ |
||||
// Code generated - EDITING IS FUTILE. DO NOT EDIT.
|
||||
//
|
||||
// Generated by:
|
||||
// public/app/plugins/gen.go
|
||||
// Using jennies:
|
||||
// TSTypesJenny
|
||||
// PluginTSTypesJenny
|
||||
//
|
||||
// Run 'make gen-cue' from repository root to regenerate.
|
||||
|
||||
import * as common from '@grafana/schema'; |
||||
|
||||
export const PanelCfgModelVersion = Object.freeze([0, 0]); |
||||
|
||||
export enum SeriesMapping { |
||||
Auto = 'auto', |
||||
Manual = 'manual', |
||||
} |
||||
|
||||
export enum ScatterShow { |
||||
Lines = 'lines', |
||||
Points = 'points', |
||||
PointsAndLines = 'points+lines', |
||||
} |
||||
|
||||
export interface XYDimensionConfig { |
||||
exclude?: Array<string>; |
||||
frame: number; |
||||
x?: string; |
||||
} |
||||
|
||||
export const defaultXYDimensionConfig: Partial<XYDimensionConfig> = { |
||||
exclude: [], |
||||
}; |
||||
|
||||
export interface ScatterFieldConfig extends common.HideableFieldConfig, common.AxisConfig { |
||||
label?: common.VisibilityMode; |
||||
labelValue?: common.TextDimensionConfig; |
||||
lineColor?: common.ColorDimensionConfig; |
||||
lineStyle?: common.LineStyle; |
||||
lineWidth?: number; |
||||
pointColor?: common.ColorDimensionConfig; |
||||
pointSize?: common.ScaleDimensionConfig; |
||||
show?: ScatterShow; |
||||
} |
||||
|
||||
export const defaultScatterFieldConfig: Partial<ScatterFieldConfig> = { |
||||
label: common.VisibilityMode.Auto, |
||||
show: ScatterShow.Points, |
||||
}; |
||||
|
||||
export interface ScatterSeriesConfig extends ScatterFieldConfig { |
||||
name?: string; |
||||
x?: string; |
||||
y?: string; |
||||
} |
||||
|
||||
export interface PanelOptions extends common.OptionsWithLegend, common.OptionsWithTooltip { |
||||
dims: XYDimensionConfig; |
||||
series: Array<ScatterSeriesConfig>; |
||||
seriesMapping?: SeriesMapping; |
||||
} |
||||
|
||||
export const defaultPanelOptions: Partial<PanelOptions> = { |
||||
series: [], |
||||
}; |
||||
Loading…
Reference in new issue