{
baseNameMode: FieldNamePickerBaseNameMode;
+ frameFilter?: number;
}
-export const ScatterSeriesEditor = ({ value, onChange, context, baseNameMode }: Props) => {
+export const ScatterSeriesEditor = ({ value, onChange, context, baseNameMode, frameFilter = -1 }: Props) => {
const onFieldChange = (val: unknown | undefined, field: string) => {
onChange({ ...value, [field]: val });
};
+ const frame = context.data && frameFilter > -1 ? context.data[frameFilter] : undefined;
+
return (
@@ -27,7 +30,10 @@ export const ScatterSeriesEditor = ({ value, onChange, context, baseNameMode }:
id: 'x',
name: 'x',
settings: {
+ filter: (field) =>
+ frame?.fields.some((obj) => obj.state?.displayName === field.state?.displayName) ?? true,
baseNameMode,
+ placeholderText: 'select X field',
},
}}
/>
@@ -38,10 +44,13 @@ export const ScatterSeriesEditor = ({ value, onChange, context, baseNameMode }:
context={context}
onChange={(field) => onFieldChange(field, 'y')}
item={{
- id: 'x',
- name: 'x',
+ id: 'y',
+ name: 'y',
settings: {
+ filter: (field) =>
+ frame?.fields.some((obj) => obj.state?.displayName === field.state?.displayName) ?? true,
baseNameMode,
+ placeholderText: 'select Y field',
},
}}
/>
diff --git a/public/app/plugins/panel/xychart/panelcfg.cue b/public/app/plugins/panel/xychart/panelcfg.cue
index 25177f0e66e..6e7012c2402 100644
--- a/public/app/plugins/panel/xychart/panelcfg.cue
+++ b/public/app/plugins/panel/xychart/panelcfg.cue
@@ -57,9 +57,10 @@ composableKinds: PanelCfg: {
ScatterSeriesConfig: {
FieldConfig
- x?: string
- y?: string
- name?: string
+ x?: string
+ y?: string
+ name?: string
+ frame?: number
} @cuetsy(kind="interface")
Options: {
diff --git a/public/app/plugins/panel/xychart/panelcfg.gen.ts b/public/app/plugins/panel/xychart/panelcfg.gen.ts
index 5c3fb0f4847..52f8a1ae2ea 100644
--- a/public/app/plugins/panel/xychart/panelcfg.gen.ts
+++ b/public/app/plugins/panel/xychart/panelcfg.gen.ts
@@ -54,6 +54,7 @@ export const defaultFieldConfig: Partial = {
};
export interface ScatterSeriesConfig extends FieldConfig {
+ frame?: number;
name?: string;
x?: string;
y?: string;
diff --git a/public/app/plugins/panel/xychart/scatter.ts b/public/app/plugins/panel/xychart/scatter.ts
index 4655834ca4b..e4bd1946707 100644
--- a/public/app/plugins/panel/xychart/scatter.ts
+++ b/public/app/plugins/panel/xychart/scatter.ts
@@ -224,6 +224,10 @@ function prepSeries(options: Options, frames: DataFrame[]): ScatterSeries[] {
}
for (let frameIndex = 0; frameIndex < frames.length; frameIndex++) {
+ // When a frame filter is applied, only include matching frame index
+ if (series.frame !== undefined && series.frame !== frameIndex) {
+ continue;
+ }
const frame = frames[frameIndex];
const xIndex = findFieldIndex(series.x, frame, frames);
diff --git a/public/app/plugins/panel/xychart/types.ts b/public/app/plugins/panel/xychart/types.ts
index bbaf107d4d2..ca9d9ddfb1d 100644
--- a/public/app/plugins/panel/xychart/types.ts
+++ b/public/app/plugins/panel/xychart/types.ts
@@ -64,3 +64,7 @@ export interface ExtraFacets {
colorFacetValue: number;
sizeFacetValue: number;
}
+
+export interface DataFilterBySeries {
+ frame: number;
+}