XYChart: Improve base options setup (#67878)

This commit is contained in:
Ryan McKinley
2023-07-10 17:54:01 -07:00
committed by GitHub
parent 4206a4d16a
commit 09cc63329f
21 changed files with 433 additions and 510 deletions

View File

@@ -544,9 +544,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "42"],
[0, 0, 0, "Unexpected any. Specify a different type.", "43"],
[0, 0, 0, "Unexpected any. Specify a different type.", "44"],
[0, 0, 0, "Unexpected any. Specify a different type.", "45"],
[0, 0, 0, "Do not use any type assertions.", "45"],
[0, 0, 0, "Unexpected any. Specify a different type.", "46"],
[0, 0, 0, "Unexpected any. Specify a different type.", "47"],
[0, 0, 0, "Do not use any type assertions.", "47"],
[0, 0, 0, "Unexpected any. Specify a different type.", "48"],
[0, 0, 0, "Unexpected any. Specify a different type.", "49"],
[0, 0, 0, "Unexpected any. Specify a different type.", "50"],
@@ -555,11 +555,11 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "53"],
[0, 0, 0, "Unexpected any. Specify a different type.", "54"],
[0, 0, 0, "Unexpected any. Specify a different type.", "55"],
[0, 0, 0, "Do not use any type assertions.", "56"],
[0, 0, 0, "Unexpected any. Specify a different type.", "56"],
[0, 0, 0, "Unexpected any. Specify a different type.", "57"],
[0, 0, 0, "Do not use any type assertions.", "58"],
[0, 0, 0, "Unexpected any. Specify a different type.", "58"],
[0, 0, 0, "Unexpected any. Specify a different type.", "59"],
[0, 0, 0, "Do not use any type assertions.", "60"],
[0, 0, 0, "Unexpected any. Specify a different type.", "60"],
[0, 0, 0, "Unexpected any. Specify a different type.", "61"],
[0, 0, 0, "Do not use any type assertions.", "62"],
[0, 0, 0, "Unexpected any. Specify a different type.", "63"],
@@ -569,9 +569,9 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "67"],
[0, 0, 0, "Do not use any type assertions.", "68"],
[0, 0, 0, "Unexpected any. Specify a different type.", "69"],
[0, 0, 0, "Unexpected any. Specify a different type.", "70"],
[0, 0, 0, "Do not use any type assertions.", "71"],
[0, 0, 0, "Unexpected any. Specify a different type.", "72"],
[0, 0, 0, "Do not use any type assertions.", "70"],
[0, 0, 0, "Unexpected any. Specify a different type.", "71"],
[0, 0, 0, "Do not use any type assertions.", "72"],
[0, 0, 0, "Unexpected any. Specify a different type.", "73"],
[0, 0, 0, "Do not use any type assertions.", "74"],
[0, 0, 0, "Unexpected any. Specify a different type.", "75"],
@@ -586,7 +586,13 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "84"],
[0, 0, 0, "Unexpected any. Specify a different type.", "85"],
[0, 0, 0, "Do not use any type assertions.", "86"],
[0, 0, 0, "Unexpected any. Specify a different type.", "87"]
[0, 0, 0, "Unexpected any. Specify a different type.", "87"],
[0, 0, 0, "Unexpected any. Specify a different type.", "88"],
[0, 0, 0, "Do not use any type assertions.", "89"],
[0, 0, 0, "Unexpected any. Specify a different type.", "90"],
[0, 0, 0, "Unexpected any. Specify a different type.", "91"],
[0, 0, 0, "Do not use any type assertions.", "92"],
[0, 0, 0, "Unexpected any. Specify a different type.", "93"]
],
"packages/grafana-data/src/utils/Registry.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]

View File

@@ -15,13 +15,128 @@ title: XYChartPanelCfg kind
| Property | Type | Required | Default | Description |
|-----------------------|--------------------------------|----------|---------|---------------------------------------------------------|
| `FieldConfig` | [object](#fieldconfig) | **Yes** | | |
| `Options` | [object](#options) | **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** | | |
### FieldConfig
It extends [HideableFieldConfig](#hideablefieldconfig) and [AxisConfig](#axisconfig).
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisColorMode` | string | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisLabel` | string | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisPlacement` | string | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisSoftMin` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisWidth` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | *(Inherited from [HideableFieldConfig](#hideablefieldconfig))*<br/>TODO docs |
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | |
| `label` | string | No | | TODO docs<br/>Possible values are: `auto`, `never`, `always`. |
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
| `lineStyle` | [LineStyle](#linestyle) | No | | TODO docs |
| `lineWidth` | integer | No | | Constraint: `>=0 & <=2147483647`. |
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs |
| `show` | string | No | | Possible values are: `points`, `lines`, `points+lines`. |
### AxisConfig
TODO docs
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|----------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | |
| `axisColorMode` | string | No | | TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | |
| `axisLabel` | string | No | | |
| `axisPlacement` | string | No | | TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | |
| `axisSoftMin` | number | No | | |
| `axisWidth` | number | No | | |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | TODO docs |
### ScaleDistributionConfig
TODO docs
| Property | Type | Required | Default | Description |
|-------------------|--------|----------|---------|--------------------------------------------------------------------------|
| `type` | string | **Yes** | | TODO docs<br/>Possible values are: `linear`, `log`, `ordinal`, `symlog`. |
| `linearThreshold` | number | No | | |
| `log` | number | No | | |
### ColorDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### BaseDimensionConfig
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|-------------------------------------------|
| `field` | string | No | | fixed: T -- will be added by each element |
### HideSeriesConfig
TODO docs
| Property | Type | Required | Default | Description |
|-----------|---------|----------|---------|-------------|
| `legend` | boolean | **Yes** | | |
| `tooltip` | boolean | **Yes** | | |
| `viz` | boolean | **Yes** | | |
### HideableFieldConfig
TODO docs
| Property | Type | Required | Default | Description |
|------------|---------------------------------------|----------|---------|-------------|
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | TODO docs |
### LineStyle
TODO docs
| Property | Type | Required | Default | Description |
|----------|----------|----------|---------|--------------------------------------------------------|
| `dash` | number[] | No | | |
| `fill` | string | No | | Possible values are: `solid`, `dash`, `dot`, `square`. |
### ScaleDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `max` | number | **Yes** | | |
| `min` | number | **Yes** | | |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | number | No | | |
| `mode` | string | No | | Possible values are: `linear`, `quad`. |
### TextDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `mode` | string | **Yes** | | Possible values are: `fixed`, `field`, `template`. |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### Options
It extends [OptionsWithLegend](#optionswithlegend) and [OptionsWithTooltip](#optionswithtooltip).
@@ -77,147 +192,32 @@ TODO docs
### ScatterSeriesConfig
It extends [ScatterFieldConfig](#scatterfieldconfig).
It extends [FieldConfig](#fieldconfig).
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisColorMode` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisLabel` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisPlacement` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisSoftMin` | number | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisWidth` | number | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs |
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `label` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `never`, `always`. |
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `lineStyle` | [LineStyle](#linestyle) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs |
| `lineWidth` | integer | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>Constraint: `>=0 & <=2147483647`. |
|---------------------|-----------------------------------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisColorMode` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisLabel` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisPlacement` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisSoftMin` | number | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisWidth` | number | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs |
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `label` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `never`, `always`. |
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `lineStyle` | [LineStyle](#linestyle) | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs |
| `lineWidth` | integer | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>Constraint: `>=0 & <=2147483647`. |
| `name` | string | No | | |
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs |
| `show` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>Possible values are: `points`, `lines`, `points+lines`. |
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs |
| `show` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>Possible values are: `points`, `lines`, `points+lines`. |
| `x` | string | No | | |
| `y` | string | No | | |
### ColorDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### BaseDimensionConfig
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|-------------------------------------------|
| `field` | string | No | | fixed: T -- will be added by each element |
### HideSeriesConfig
TODO docs
| Property | Type | Required | Default | Description |
|-----------|---------|----------|---------|-------------|
| `legend` | boolean | **Yes** | | |
| `tooltip` | boolean | **Yes** | | |
| `viz` | boolean | **Yes** | | |
### LineStyle
TODO docs
| Property | Type | Required | Default | Description |
|----------|----------|----------|---------|--------------------------------------------------------|
| `dash` | number[] | No | | |
| `fill` | string | No | | Possible values are: `solid`, `dash`, `dot`, `square`. |
### ScaleDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `max` | number | **Yes** | | |
| `min` | number | **Yes** | | |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | number | No | | |
| `mode` | string | No | | Possible values are: `linear`, `quad`. |
### ScaleDistributionConfig
TODO docs
| Property | Type | Required | Default | Description |
|-------------------|--------|----------|---------|--------------------------------------------------------------------------|
| `type` | string | **Yes** | | TODO docs<br/>Possible values are: `linear`, `log`, `ordinal`, `symlog`. |
| `linearThreshold` | number | No | | |
| `log` | number | No | | |
### ScatterFieldConfig
It extends [HideableFieldConfig](#hideablefieldconfig) and [AxisConfig](#axisconfig).
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisColorMode` | string | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisLabel` | string | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisPlacement` | string | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisSoftMin` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisWidth` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | *(Inherited from [HideableFieldConfig](#hideablefieldconfig))*<br/>TODO docs |
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | |
| `label` | string | No | | TODO docs<br/>Possible values are: `auto`, `never`, `always`. |
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
| `lineStyle` | [LineStyle](#linestyle) | No | | TODO docs |
| `lineWidth` | integer | No | | Constraint: `>=0 & <=2147483647`. |
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs |
| `show` | string | No | | Possible values are: `points`, `lines`, `points+lines`. |
### AxisConfig
TODO docs
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|----------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | |
| `axisColorMode` | string | No | | TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | |
| `axisLabel` | string | No | | |
| `axisPlacement` | string | No | | TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | |
| `axisSoftMin` | number | No | | |
| `axisWidth` | number | No | | |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | TODO docs |
### HideableFieldConfig
TODO docs
| Property | Type | Required | Default | Description |
|------------|---------------------------------------|----------|---------|-------------|
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | TODO docs |
### TextDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `mode` | string | **Yes** | | Possible values are: `fixed`, `field`, `template`. |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### XYDimensionConfig
| Property | Type | Required | Default | Description |

View File

@@ -15,13 +15,142 @@ title: XYChartPanelCfg kind
| Property | Type | Required | Default | Description |
|-----------------------|--------------------------------|----------|---------|---------------------------------------------------------|
| `FieldConfig` | [object](#fieldconfig) | **Yes** | | |
| `Options` | [object](#options) | **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** | | |
### FieldConfig
It extends [HideableFieldConfig](#hideablefieldconfig) and [AxisConfig](#axisconfig).
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisColorMode` | string | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisLabel` | string | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisPlacement` | string | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisSoftMin` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisWidth` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `fillOpacity` | number | No | `0.5` | Constraint: `>=0 & <=1`. |
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | *(Inherited from [HideableFieldConfig](#hideablefieldconfig))*<br/>TODO docs |
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | |
| `label` | string | No | | TODO docs<br/>Possible values are: `auto`, `never`, `always`. |
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
| `lineStyle` | [LineStyle](#linestyle) | No | | TODO docs |
| `lineWidth` | integer | No | | Constraint: `>=0 & <=2147483647`. |
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | |
| `pointSymbol` | [ResourceDimensionConfig](#resourcedimensionconfig) | No | | Links to a resource (image/svg path) |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs |
| `show` | string | No | | Possible values are: `points`, `lines`, `points+lines`. |
### AxisConfig
TODO docs
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|----------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | |
| `axisColorMode` | string | No | | TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | |
| `axisLabel` | string | No | | |
| `axisPlacement` | string | No | | TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | |
| `axisSoftMin` | number | No | | |
| `axisWidth` | number | No | | |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | TODO docs |
### ScaleDistributionConfig
TODO docs
| Property | Type | Required | Default | Description |
|-------------------|--------|----------|---------|--------------------------------------------------------------------------|
| `type` | string | **Yes** | | TODO docs<br/>Possible values are: `linear`, `log`, `ordinal`, `symlog`. |
| `linearThreshold` | number | No | | |
| `log` | number | No | | |
### ColorDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### BaseDimensionConfig
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|-------------------------------------------|
| `field` | string | No | | fixed: T -- will be added by each element |
### HideSeriesConfig
TODO docs
| Property | Type | Required | Default | Description |
|-----------|---------|----------|---------|-------------|
| `legend` | boolean | **Yes** | | |
| `tooltip` | boolean | **Yes** | | |
| `viz` | boolean | **Yes** | | |
### HideableFieldConfig
TODO docs
| Property | Type | Required | Default | Description |
|------------|---------------------------------------|----------|---------|-------------|
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | TODO docs |
### LineStyle
TODO docs
| Property | Type | Required | Default | Description |
|----------|----------|----------|---------|--------------------------------------------------------|
| `dash` | number[] | No | | |
| `fill` | string | No | | Possible values are: `solid`, `dash`, `dot`, `square`. |
### ResourceDimensionConfig
Links to a resource (image/svg path)
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `mode` | string | **Yes** | | Possible values are: `fixed`, `field`, `mapping`. |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### ScaleDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `max` | number | **Yes** | | |
| `min` | number | **Yes** | | |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | number | No | | |
| `mode` | string | No | | Possible values are: `linear`, `quad`. |
### TextDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `mode` | string | **Yes** | | Possible values are: `fixed`, `field`, `template`. |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### Options
It extends [OptionsWithLegend](#optionswithlegend) and [OptionsWithTooltip](#optionswithtooltip).
@@ -77,147 +206,34 @@ TODO docs
### ScatterSeriesConfig
It extends [ScatterFieldConfig](#scatterfieldconfig).
It extends [FieldConfig](#fieldconfig).
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|---------------------------------------------------------------------------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisColorMode` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisLabel` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisPlacement` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisSoftMin` | number | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `axisWidth` | number | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs |
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `label` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `never`, `always`. |
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `lineStyle` | [LineStyle](#linestyle) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs |
| `lineWidth` | integer | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>Constraint: `>=0 & <=2147483647`. |
|---------------------|-----------------------------------------------------|----------|---------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisColorMode` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisLabel` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisPlacement` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisSoftMin` | number | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `axisWidth` | number | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `fillOpacity` | number | No | `0.5` | *(Inherited from [FieldConfig](#fieldconfig))*<br/>Constraint: `>=0 & <=1`. |
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs |
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `label` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `never`, `always`. |
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `lineStyle` | [LineStyle](#linestyle) | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs |
| `lineWidth` | integer | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>Constraint: `>=0 & <=2147483647`. |
| `name` | string | No | | |
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))* |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>TODO docs |
| `show` | string | No | | *(Inherited from [ScatterFieldConfig](#scatterfieldconfig))*<br/>Possible values are: `points`, `lines`, `points+lines`. |
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))* |
| `pointSymbol` | [ResourceDimensionConfig](#resourcedimensionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>Links to a resource (image/svg path) |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>TODO docs |
| `show` | string | No | | *(Inherited from [FieldConfig](#fieldconfig))*<br/>Possible values are: `points`, `lines`, `points+lines`. |
| `x` | string | No | | |
| `y` | string | No | | |
### ColorDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### BaseDimensionConfig
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|-------------------------------------------|
| `field` | string | No | | fixed: T -- will be added by each element |
### HideSeriesConfig
TODO docs
| Property | Type | Required | Default | Description |
|-----------|---------|----------|---------|-------------|
| `legend` | boolean | **Yes** | | |
| `tooltip` | boolean | **Yes** | | |
| `viz` | boolean | **Yes** | | |
### LineStyle
TODO docs
| Property | Type | Required | Default | Description |
|----------|----------|----------|---------|--------------------------------------------------------|
| `dash` | number[] | No | | |
| `fill` | string | No | | Possible values are: `solid`, `dash`, `dot`, `square`. |
### ScaleDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `max` | number | **Yes** | | |
| `min` | number | **Yes** | | |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | number | No | | |
| `mode` | string | No | | Possible values are: `linear`, `quad`. |
### ScaleDistributionConfig
TODO docs
| Property | Type | Required | Default | Description |
|-------------------|--------|----------|---------|--------------------------------------------------------------------------|
| `type` | string | **Yes** | | TODO docs<br/>Possible values are: `linear`, `log`, `ordinal`, `symlog`. |
| `linearThreshold` | number | No | | |
| `log` | number | No | | |
### ScatterFieldConfig
It extends [HideableFieldConfig](#hideablefieldconfig) and [AxisConfig](#axisconfig).
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|-----------------------------------------------------------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisColorMode` | string | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisLabel` | string | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisPlacement` | string | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisSoftMin` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `axisWidth` | number | No | | *(Inherited from [AxisConfig](#axisconfig))* |
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | *(Inherited from [HideableFieldConfig](#hideablefieldconfig))*<br/>TODO docs |
| `labelValue` | [TextDimensionConfig](#textdimensionconfig) | No | | |
| `label` | string | No | | TODO docs<br/>Possible values are: `auto`, `never`, `always`. |
| `lineColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
| `lineStyle` | [LineStyle](#linestyle) | No | | TODO docs |
| `lineWidth` | integer | No | | Constraint: `>=0 & <=2147483647`. |
| `pointColor` | [ColorDimensionConfig](#colordimensionconfig) | No | | |
| `pointSize` | [ScaleDimensionConfig](#scaledimensionconfig) | No | | |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | *(Inherited from [AxisConfig](#axisconfig))*<br/>TODO docs |
| `show` | string | No | | Possible values are: `points`, `lines`, `points+lines`. |
### AxisConfig
TODO docs
| Property | Type | Required | Default | Description |
|---------------------|-----------------------------------------------------|----------|---------|----------------------------------------------------------------------------------------|
| `axisCenteredZero` | boolean | No | | |
| `axisColorMode` | string | No | | TODO docs<br/>Possible values are: `text`, `series`. |
| `axisGridShow` | boolean | No | | |
| `axisLabel` | string | No | | |
| `axisPlacement` | string | No | | TODO docs<br/>Possible values are: `auto`, `top`, `right`, `bottom`, `left`, `hidden`. |
| `axisSoftMax` | number | No | | |
| `axisSoftMin` | number | No | | |
| `axisWidth` | number | No | | |
| `scaleDistribution` | [ScaleDistributionConfig](#scaledistributionconfig) | No | | TODO docs |
### HideableFieldConfig
TODO docs
| Property | Type | Required | Default | Description |
|------------|---------------------------------------|----------|---------|-------------|
| `hideFrom` | [HideSeriesConfig](#hideseriesconfig) | No | | TODO docs |
### TextDimensionConfig
It extends [BaseDimensionConfig](#basedimensionconfig).
| Property | Type | Required | Default | Description |
|----------|--------|----------|---------|--------------------------------------------------------------------------------------------------------------|
| `mode` | string | **Yes** | | Possible values are: `fixed`, `field`, `template`. |
| `field` | string | No | | *(Inherited from [BaseDimensionConfig](#basedimensionconfig))*<br/>fixed: T -- will be added by each element |
| `fixed` | string | No | | |
### XYDimensionConfig
| Property | Type | Required | Default | Description |

View File

@@ -143,6 +143,21 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
settings: config.settings || {},
});
}
addGenericEditor<TSettings = any>(
config: FieldConfigEditorConfig<TOptions, TSettings & any>, // & any... i give up!
editor: (props: StandardEditorProps<TSettings>) => JSX.Element
): this {
return this.addCustomEditor({
...config,
id: config.path,
editor: editor as any,
override: editor as any,
process: identityOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {},
});
}
}
export interface NestedValueAccess {

View File

@@ -34,7 +34,7 @@ export const defaultXYDimensionConfig: Partial<XYDimensionConfig> = {
exclude: [],
};
export interface ScatterFieldConfig extends common.HideableFieldConfig, common.AxisConfig {
export interface FieldConfig extends common.HideableFieldConfig, common.AxisConfig {
label?: common.VisibilityMode;
labelValue?: common.TextDimensionConfig;
lineColor?: common.ColorDimensionConfig;
@@ -45,12 +45,12 @@ export interface ScatterFieldConfig extends common.HideableFieldConfig, common.A
show?: ScatterShow;
}
export const defaultScatterFieldConfig: Partial<ScatterFieldConfig> = {
export const defaultFieldConfig: Partial<FieldConfig> = {
label: common.VisibilityMode.Auto,
show: ScatterShow.Points,
};
export interface ScatterSeriesConfig extends ScatterFieldConfig {
export interface ScatterSeriesConfig extends FieldConfig {
name?: string;
x?: string;
y?: string;

View File

@@ -70,7 +70,7 @@ export const ResourcePicker = (props: Props) => {
<InlineFieldRow>
<InlineField label={null} grow>
<Input
value={name}
value={getDisplayName(src, name)}
placeholder={placeholder}
readOnly={true}
prefix={sanitizedSrc && <SanitizedSVG src={sanitizedSrc} className={styles.icon} style={{ ...colorStyle }} />}
@@ -109,6 +109,17 @@ export const ResourcePicker = (props: Props) => {
);
};
// strip the SVG off icons in the icons folder
function getDisplayName(src?: string, name?: string): string | undefined {
if (src?.startsWith('public/img/icons')) {
const idx = name?.lastIndexOf('.svg') ?? 0;
if (idx > 0) {
return name!.substring(0, idx);
}
}
return name;
}
const getStyles = (theme: GrafanaTheme2) => ({
pointer: css`
cursor: pointer;

View File

@@ -11,7 +11,7 @@ import {
import { Field, IconButton, Select, useStyles2 } from '@grafana/ui';
import { getXYDimensions, isGraphable } from './dims';
import { XYDimensionConfig, XYChartOptions } from './models.gen';
import { XYDimensionConfig, Options } from './panelcfg.gen';
interface XYInfo {
numberFields: Array<SelectableValue<string>>;
@@ -19,11 +19,7 @@ interface XYInfo {
yFields: Array<SelectableValue<boolean>>;
}
export const AutoEditor = ({
value,
onChange,
context,
}: StandardEditorProps<XYDimensionConfig, any, XYChartOptions>) => {
export const AutoEditor = ({ value, onChange, context }: StandardEditorProps<XYDimensionConfig, any, Options>) => {
const frameNames = useMemo(() => {
if (context?.data?.length) {
return context.data.map((f, idx) => ({

View File

@@ -7,7 +7,7 @@ import { FieldNamePicker } from '@grafana/ui/src/components/MatchersUI/FieldName
import { LayerName } from 'app/core/components/Layers/LayerName';
import { ColorDimensionEditor, ScaleDimensionEditor } from 'app/features/dimensions/editors';
import { Options, ScatterSeriesConfig, defaultScatterFieldConfig } from './types';
import { Options, ScatterSeriesConfig, defaultFieldConfig } from './panelcfg.gen';
export const ManualEditor = ({
value,
@@ -33,7 +33,7 @@ export const ManualEditor = ({
...value,
{
pointColor: {} as any,
pointSize: defaultScatterFieldConfig.pointSize,
pointSize: defaultFieldConfig.pointSize,
},
]);
setSelected(value.length);

View File

@@ -0,0 +1,31 @@
import React from 'react';
import { StandardEditorProps } from '@grafana/data';
import { ResourceDimensionConfig, ResourceDimensionMode } from '@grafana/schema';
import { RadioButtonGroup } from '@grafana/ui';
import { ResourceDimensionOptions } from 'app/features/dimensions';
export const SymbolEditor = (
props: StandardEditorProps<ResourceDimensionConfig, ResourceDimensionOptions, unknown>
) => {
const { value } = props;
const basicSymbols = [
{ value: 'img/icons/marker/circle.svg', label: 'Circle' },
{ value: 'img/icons/marker/square.svg', label: 'Square' },
];
const onSymbolChange = (v: string) => {
props.onChange({
fixed: v,
mode: ResourceDimensionMode.Fixed,
});
};
return (
<div>
<RadioButtonGroup options={basicSymbols} value={value.fixed} onChange={onSymbolChange} />
{!basicSymbols.find((v) => v.value === value.fixed) && <div>{value.fixed}</div>}
</div>
);
};

View File

@@ -6,7 +6,7 @@ import { LinkButton, useStyles2, VerticalGroup, VizTooltipOptions } from '@grafa
import { findField } from 'app/features/dimensions';
import { getTitleFromHref } from 'app/features/explore/utils/links';
import { ScatterSeriesConfig, SeriesMapping } from './models.gen';
import { ScatterSeriesConfig, SeriesMapping } from './panelcfg.gen';
import { ScatterSeries } from './types';
interface YValue {

View File

@@ -1,71 +0,0 @@
import React, { useMemo } from 'react';
import { LegendDisplayMode, UPlotChart, useTheme2, VizLayout, VizLegend, VizLegendItem } from '@grafana/ui';
import { PanelProps } from '@grafana/data';
import { XYChartOptions } from './models.gen';
import { prepData, prepScatter } from './scatter';
interface XYChartPanelProps extends PanelProps<XYChartOptions> {}
export const XYChartPanel = ({
data,
width,
height,
options,
fieldConfig,
timeRange,
//onFieldConfigChange,
}: XYChartPanelProps) => {
const theme = useTheme2();
const info = useMemo(() => {
console.log('prepScatter!');
return prepScatter(options, data, theme, () => {});
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [data.structureRev, options]);
// preps data in various shapes...aligned, stacked, merged, interpolated, etc..
const scatterData = useMemo(() => {
console.log('prepData!');
return prepData(info, data.series);
}, [info, data.series]);
const legend = useMemo(() => {
const items: VizLegendItem[] = [];
for (const s of info.series) {
const frame = s.frame(data.series);
if (frame) {
for (const item of s.legend(frame)) {
items.push(item);
}
}
}
return (
<VizLayout.Legend placement="bottom">
<VizLegend placement="bottom" items={items} displayMode={LegendDisplayMode.List} />
</VizLayout.Legend>
);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [info]);
if (info.error) {
return (
<div className="panel-empty">
<p>{info.error}</p>
</div>
);
}
return (
<VizLayout width={width} height={height} legend={legend}>
{(vizWidth: number, vizHeight: number) => (
// <pre style={{ width: vizWidth, height: vizHeight, border: '1px solid green', margin: '0px' }}>
// {JSON.stringify(scatterData, null, 2)}
// </pre>
<UPlotChart config={info.builder!} data={scatterData} width={vizWidth} height={vizHeight} timeRange={timeRange}>
{/*children ? children(config, alignedFrame) : null*/}
</UPlotChart>
)}
</VizLayout>
);
};

View File

@@ -26,9 +26,9 @@ import { FacetedData } from '@grafana/ui/src/components/uPlot/types';
import { CloseButton } from 'app/core/components/CloseButton/CloseButton';
import { TooltipView } from './TooltipView';
import { SeriesMapping } from './models.gen';
import { Options, SeriesMapping } from './panelcfg.gen';
import { prepData, prepScatter, ScatterPanelInfo } from './scatter';
import { Options, ScatterHoverEvent, ScatterSeries } from './types';
import { ScatterHoverEvent, ScatterSeries } from './types';
type Props = PanelProps<Options>;
const TOOLTIP_OFFSET = 10;

View File

@@ -10,11 +10,11 @@ import { commonOptionsBuilder } from '@grafana/ui';
import { LineStyleEditor } from '../timeseries/LineStyleEditor';
import { ScatterFieldConfig, ScatterShow } from './types';
import { FieldConfig, ScatterShow } from './panelcfg.gen';
export const DEFAULT_POINT_SIZE = 5;
export function getScatterFieldConfig(cfg: ScatterFieldConfig): SetFieldConfigOptionsArgs<ScatterFieldConfig> {
export function getScatterFieldConfig(cfg: FieldConfig): SetFieldConfigOptionsArgs<FieldConfig> {
return {
standardOptions: {
[FieldConfigProperty.Min]: {
@@ -71,6 +71,25 @@ export function getScatterFieldConfig(cfg: ScatterFieldConfig): SetFieldConfigOp
],
},
})
// .addGenericEditor(
// {
// path: 'pointSymbol',
// name: 'Point symbol',
// defaultValue: defaultFieldConfig.pointSymbol ?? {
// mode: 'fixed',
// fixed: 'img/icons/marker/circle.svg',
// },
// settings: {
// resourceType: MediaType.Icon,
// folderName: ResourceFolderName.Marker,
// placeholderText: 'Select a symbol',
// placeholderValue: 'img/icons/marker/circle.svg',
// showSourceRadio: false,
// },
// showIf: (c) => c.show !== ScatterShow.Lines,
// },
// SymbolEditor // ResourceDimensionEditor
// )
.addSliderInput({
path: 'pointSize.fixed',
name: 'Point size',
@@ -82,6 +101,17 @@ export function getScatterFieldConfig(cfg: ScatterFieldConfig): SetFieldConfigOp
},
showIf: (c) => c.show !== ScatterShow.Lines,
})
// .addSliderInput({
// path: 'fillOpacity',
// name: 'Fill opacity',
// defaultValue: 0.4, // defaultFieldConfig.fillOpacity,
// settings: {
// min: 0, // hidden? or just outlines?
// max: 1,
// step: 0.05,
// },
// showIf: (c) => c.show !== ScatterShow.Lines,
// })
.addCustomEditor<void, LineStyle>({
id: 'lineStyle',
path: 'lineStyle',

View File

@@ -1,7 +1,7 @@
import { DataFrame, Field, FieldMatcher, FieldType, getFieldDisplayName } from '@grafana/data';
import { XYFieldMatchers } from '@grafana/ui/src/components/GraphNG/types';
import { XYDimensionConfig } from './types';
import { XYDimensionConfig } from './panelcfg.gen';
// TODO: fix import

View File

@@ -1,85 +0,0 @@
import {
OptionsWithTooltip,
OptionsWithLegend,
LineStyle,
VisibilityMode,
HideableFieldConfig,
AxisConfig,
AxisPlacement,
ColorDimensionConfig,
ScaleDimensionConfig,
TextDimensionConfig,
} from '@grafana/schema';
import {
DimensionSupplier,
} from 'app/features/dimensions';
import { DEFAULT_POINT_SIZE } from './config';
// export enum ScatterLineMode {
// None = 'none',
// Linear = 'linear',
// Smooth
// r2, etc
// }
export enum ScatterShow {
Points = 'points',
Lines = 'lines',
PointsAndLines = 'points+lines',
}
export enum SeriesMapping {
Auto = 'auto',
Manual = 'manual',
}
export interface ScatterFieldConfig extends HideableFieldConfig, AxisConfig {
show?: ScatterShow;
lineWidth?: number;
lineStyle?: LineStyle;
lineColor?: ColorDimensionConfig;
pointSize?: ScaleDimensionConfig; // only 'fixed' is exposed in the UI
pointColor?: ColorDimensionConfig;
pointSymbol?: DimensionSupplier<string>;
label?: VisibilityMode;
labelValue?: TextDimensionConfig;
}
/** Configured in the panel level */
export interface ScatterSeriesConfig extends ScatterFieldConfig {
x?: string;
y?: string;
name?: string;
}
export const defaultScatterConfig: ScatterFieldConfig = {
show: ScatterShow.Points,
lineWidth: 1,
lineStyle: {
fill: 'solid',
},
pointSize: {
fixed: DEFAULT_POINT_SIZE,
min: 1,
max: 20,
},
axisPlacement: AxisPlacement.Auto,
};
/** Old config saved with 8.0+ */
export interface XYDimensionConfig {
frame: number;
x?: string; // name | first
exclude?: string[]; // all other numbers except
}
export interface XYChartOptions extends OptionsWithLegend, OptionsWithTooltip {
seriesMapping?: SeriesMapping;
dims: XYDimensionConfig;
series?: ScatterSeriesConfig[];
}

View File

@@ -5,10 +5,10 @@ import { AutoEditor } from './AutoEditor';
import { ManualEditor } from './ManualEditor';
import { XYChartPanel2 } from './XYChartPanel2';
import { getScatterFieldConfig } from './config';
import { defaultScatterFieldConfig, Options, ScatterFieldConfig } from './types';
import { Options, FieldConfig, defaultFieldConfig } from './panelcfg.gen';
export const plugin = new PanelPlugin<Options, ScatterFieldConfig>(XYChartPanel2)
.useFieldConfig(getScatterFieldConfig(defaultScatterFieldConfig))
export const plugin = new PanelPlugin<Options, FieldConfig>(XYChartPanel2)
.useFieldConfig(getScatterFieldConfig(defaultFieldConfig))
.setPanelOptions((builder) => {
builder
.addRadio({

View File

@@ -39,24 +39,27 @@ composableKinds: PanelCfg: {
exclude?: [...string]
} @cuetsy(kind="interface")
ScatterFieldConfig: {
FieldConfig: {
common.HideableFieldConfig
common.AxisConfig
show?: ScatterShow & (*"points" | _)
pointSize?: common.ScaleDimensionConfig
lineColor?: common.ColorDimensionConfig
pointColor?: common.ColorDimensionConfig
labelValue?: common.TextDimensionConfig
// pointSymbol?: common.ResourceDimensionConfig
// fillOpacity?: number & >=0 & <=1 | *0.5
lineColor?: common.ColorDimensionConfig
lineWidth?: int32 & >=0
lineStyle?: common.LineStyle
label?: common.VisibilityMode & (*"auto" | _)
labelValue?: common.TextDimensionConfig
} @cuetsy(kind="interface",TSVeneer="type")
ScatterSeriesConfig: {
ScatterFieldConfig
FieldConfig
x?: string
y?: string
name?: string

View File

@@ -31,7 +31,7 @@ export const defaultXYDimensionConfig: Partial<XYDimensionConfig> = {
exclude: [],
};
export interface ScatterFieldConfig extends common.HideableFieldConfig, common.AxisConfig {
export interface FieldConfig extends common.HideableFieldConfig, common.AxisConfig {
label?: common.VisibilityMode;
labelValue?: common.TextDimensionConfig;
lineColor?: common.ColorDimensionConfig;
@@ -42,12 +42,12 @@ export interface ScatterFieldConfig extends common.HideableFieldConfig, common.A
show?: ScatterShow;
}
export const defaultScatterFieldConfig: Partial<ScatterFieldConfig> = {
export const defaultFieldConfig: Partial<FieldConfig> = {
label: common.VisibilityMode.Auto,
show: ScatterShow.Points,
};
export interface ScatterSeriesConfig extends ScatterFieldConfig {
export interface ScatterSeriesConfig extends FieldConfig {
name?: string;
x?: string;
y?: string;

View File

@@ -30,15 +30,8 @@ import { pointWithin, Quadtree, Rect } from '../barchart/quadtree';
import { DEFAULT_POINT_SIZE } from './config';
import { isGraphable } from './dims';
import {
DimensionValues,
ScatterFieldConfig,
defaultScatterFieldConfig,
ScatterHoverCallback,
ScatterSeries,
Options,
ScatterShow,
} from './types';
import { FieldConfig, defaultFieldConfig, Options, ScatterShow } from './panelcfg.gen';
import { DimensionValues, ScatterHoverCallback, ScatterSeries } from './types';
export interface ScatterPanelInfo {
error?: string;
@@ -111,7 +104,7 @@ function getScatterSeries(
? config.theme2.visualization.getColorByName(dims.pointColorFixed)
: getFieldSeriesColor(y, config.theme2).color;
let pointColor: DimensionValues<string> = () => seriesColor;
const fieldConfig: ScatterFieldConfig = { ...defaultScatterFieldConfig, ...y.config.custom };
const fieldConfig: FieldConfig = { ...defaultFieldConfig, ...y.config.custom };
let pointColorMode = fieldColorModeRegistry.get(FieldColorModeId.PaletteClassic);
if (dims.pointColorIndex) {
const f = frames[frameIndex].fields[dims.pointColorIndex];
@@ -301,7 +294,7 @@ interface DrawBubblesOpts {
};
}
//const prepConfig: UPlotConfigPrepFnXY<XYChartOptions> = ({ frames, series, theme }) => {
//const prepConfig: UPlotConfigPrepFnXY<Options> = ({ frames, series, theme }) => {
const prepConfig = (
getData: () => DataFrame[],
scatterSeries: ScatterSeries[],

View File

@@ -1,14 +1,6 @@
import { DataFrame, Field, FieldColorMode } from '@grafana/data';
import { LineStyle, ScaleDimensionConfig, VisibilityMode } from '@grafana/schema';
import { VizLegendItem } from '@grafana/ui';
import { DimensionSupplier } from 'app/features/dimensions';
import {
ScatterFieldConfig as GeneratedScatterFieldConfig,
ScatterSeriesConfig as GeneratedScatterSeriesConfig,
defaultScatterFieldConfig as generatedDefaultScatterFieldConfig,
Options as GeneratedOptions,
} from './panelcfg.gen';
/**
* @internal
@@ -24,20 +16,6 @@ export interface ScatterHoverEvent {
export type ScatterHoverCallback = (evt?: ScatterHoverEvent) => void;
export interface ScatterFieldConfig extends GeneratedScatterFieldConfig {
pointSymbol?: DimensionSupplier<string>;
}
export const defaultScatterFieldConfig: Partial<ScatterFieldConfig> = {
...generatedDefaultScatterFieldConfig,
};
export interface ScatterSeriesConfig extends ScatterFieldConfig, GeneratedScatterSeriesConfig {}
export interface Options extends Omit<GeneratedOptions, 'series'> {
series: ScatterSeriesConfig[];
}
// Using field where we will need formatting/scale/axis info
// Use raw or DimensionValues when the values can be used directly
export interface ScatterSeries {
@@ -72,5 +50,3 @@ export interface ScatterSeries {
};
};
}
export { ScatterShow, SeriesMapping, XYDimensionConfig } from './panelcfg.gen';

View File

@@ -1 +1,3 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><rect width="85%" height="85%" x="2" y="2" rx="5"/></svg>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<rect width="85%" height="85%" x="2" y="2" rx="0"/>
</svg>

Before

Width:  |  Height:  |  Size: 117 B

After

Width:  |  Height:  |  Size: 119 B