mirror of
https://github.com/grafana/grafana.git
synced 2025-08-03 06:22:13 +08:00
kindsys: Adapt to new PanelCfg schema interface (#65297)
* kindsys: Adapt to new PanelCfg schema interface * building locally * Remove Panel prefix in cue files * Regenerate * Update imports * fixup! Merge branch 'remove-panel-prefix' into sdboyer/redundant-panelcfg-prefixes * Fix formatting --------- Co-authored-by: Ryan McKinley <ryantxu@gmail.com> Co-authored-by: Tania B <yalyna.ts@gmail.com>
This commit is contained in:
@ -23,7 +23,7 @@ import {
|
||||
UPLOT_AXIS_FONT_SIZE,
|
||||
} from '@grafana/ui';
|
||||
|
||||
import { defaultPanelFieldConfig, PanelFieldConfig, PanelOptions } from './panelcfg.gen';
|
||||
import { defaultFieldConfig, FieldConfig, Options } from './panelcfg.gen';
|
||||
|
||||
function incrRoundDn(num: number, incr: number) {
|
||||
return Math.floor(num / incr) * incr;
|
||||
@ -34,7 +34,7 @@ function incrRoundUp(num: number, incr: number) {
|
||||
}
|
||||
|
||||
export interface HistogramProps extends Themeable2 {
|
||||
options: PanelOptions; // used for diff
|
||||
options: Options; // used for diff
|
||||
alignedFrame: DataFrame; // This could take HistogramFields
|
||||
bucketSize: number;
|
||||
width: number;
|
||||
@ -194,7 +194,7 @@ const prepConfig = (frame: DataFrame, theme: GrafanaTheme2) => {
|
||||
field.state = field.state ?? {};
|
||||
field.state.seriesIndex = seriesIndex++;
|
||||
|
||||
const customConfig: PanelFieldConfig = { ...defaultPanelFieldConfig, ...field.config.custom };
|
||||
const customConfig: FieldConfig = { ...defaultFieldConfig, ...field.config.custom };
|
||||
|
||||
const scaleKey = 'y';
|
||||
const colorMode = getFieldColorModeForField(field);
|
||||
|
@ -5,9 +5,9 @@ import { histogramFieldsToFrame } from '@grafana/data/src/transformations/transf
|
||||
import { useTheme2 } from '@grafana/ui';
|
||||
|
||||
import { Histogram, getBucketSize } from './Histogram';
|
||||
import { PanelOptions } from './panelcfg.gen';
|
||||
import { Options } from './panelcfg.gen';
|
||||
|
||||
type Props = PanelProps<PanelOptions>;
|
||||
type Props = PanelProps<Options>;
|
||||
|
||||
export const HistogramPanel = ({ data, options, width, height }: Props) => {
|
||||
const theme = useTheme2();
|
||||
|
@ -3,10 +3,10 @@ import { histogramFieldInfo } from '@grafana/data/src/transformations/transforme
|
||||
import { commonOptionsBuilder, graphFieldOptions } from '@grafana/ui';
|
||||
|
||||
import { HistogramPanel } from './HistogramPanel';
|
||||
import { PanelFieldConfig, PanelOptions, defaultPanelFieldConfig, defaultPanelOptions } from './panelcfg.gen';
|
||||
import { FieldConfig, Options, defaultFieldConfig, defaultOptions } from './panelcfg.gen';
|
||||
import { originalDataHasHistogram } from './utils';
|
||||
|
||||
export const plugin = new PanelPlugin<PanelOptions, PanelFieldConfig>(HistogramPanel)
|
||||
export const plugin = new PanelPlugin<Options, FieldConfig>(HistogramPanel)
|
||||
.setPanelOptions((builder) => {
|
||||
builder
|
||||
.addCustomEditor({
|
||||
@ -25,7 +25,7 @@ export const plugin = new PanelPlugin<PanelOptions, PanelFieldConfig>(HistogramP
|
||||
placeholder: 'Auto',
|
||||
min: 0,
|
||||
},
|
||||
defaultValue: defaultPanelOptions.bucketSize,
|
||||
defaultValue: defaultOptions.bucketSize,
|
||||
showIf: (opts, data) => !originalDataHasHistogram(data),
|
||||
})
|
||||
.addNumberInput({
|
||||
@ -36,14 +36,14 @@ export const plugin = new PanelPlugin<PanelOptions, PanelFieldConfig>(HistogramP
|
||||
placeholder: '0',
|
||||
min: 0,
|
||||
},
|
||||
defaultValue: defaultPanelOptions.bucketOffset,
|
||||
defaultValue: defaultOptions.bucketOffset,
|
||||
showIf: (opts, data) => !originalDataHasHistogram(data),
|
||||
})
|
||||
.addBooleanSwitch({
|
||||
path: 'combine',
|
||||
name: histogramFieldInfo.combine.name,
|
||||
description: histogramFieldInfo.combine.description,
|
||||
defaultValue: defaultPanelOptions.combine,
|
||||
defaultValue: defaultOptions.combine,
|
||||
showIf: (opts, data) => !originalDataHasHistogram(data),
|
||||
});
|
||||
|
||||
@ -62,7 +62,7 @@ export const plugin = new PanelPlugin<PanelOptions, PanelFieldConfig>(HistogramP
|
||||
},
|
||||
},
|
||||
useCustomConfig: (builder) => {
|
||||
const cfg = defaultPanelFieldConfig;
|
||||
const cfg = defaultFieldConfig;
|
||||
|
||||
builder
|
||||
.addSliderInput({
|
||||
|
@ -26,7 +26,7 @@ composableKinds: PanelCfg: {
|
||||
{
|
||||
schemas: [
|
||||
{
|
||||
PanelOptions: {
|
||||
Options: {
|
||||
common.OptionsWithLegend
|
||||
common.OptionsWithTooltip
|
||||
|
||||
@ -38,7 +38,7 @@ composableKinds: PanelCfg: {
|
||||
combine?: bool
|
||||
} @cuetsy(kind="interface")
|
||||
|
||||
PanelFieldConfig: {
|
||||
FieldConfig: {
|
||||
common.AxisConfig
|
||||
common.HideableFieldConfig
|
||||
|
||||
|
@ -12,7 +12,7 @@ import * as common from '@grafana/schema';
|
||||
|
||||
export const PanelCfgModelVersion = Object.freeze([0, 0]);
|
||||
|
||||
export interface PanelOptions extends common.OptionsWithLegend, common.OptionsWithTooltip {
|
||||
export interface Options extends common.OptionsWithLegend, common.OptionsWithTooltip {
|
||||
/**
|
||||
* Offset buckets by this amount
|
||||
*/
|
||||
@ -27,11 +27,11 @@ export interface PanelOptions extends common.OptionsWithLegend, common.OptionsWi
|
||||
combine?: boolean;
|
||||
}
|
||||
|
||||
export const defaultPanelOptions: Partial<PanelOptions> = {
|
||||
export const defaultOptions: Partial<Options> = {
|
||||
bucketOffset: 0,
|
||||
};
|
||||
|
||||
export interface PanelFieldConfig extends common.AxisConfig, common.HideableFieldConfig {
|
||||
export interface FieldConfig extends common.AxisConfig, common.HideableFieldConfig {
|
||||
/**
|
||||
* Controls the fill opacity of the bars.
|
||||
*/
|
||||
@ -47,7 +47,7 @@ export interface PanelFieldConfig extends common.AxisConfig, common.HideableFiel
|
||||
lineWidth?: number;
|
||||
}
|
||||
|
||||
export const defaultPanelFieldConfig: Partial<PanelFieldConfig> = {
|
||||
export const defaultFieldConfig: Partial<FieldConfig> = {
|
||||
fillOpacity: 80,
|
||||
gradientMode: common.GraphGradientMode.None,
|
||||
lineWidth: 1,
|
||||
|
Reference in New Issue
Block a user