There is any way to use in the received data (from data source) to build the panel options?
For example, create select editor based on the data and not hardcoded options.
Are you talking about building a plugin?
Out of the box, the Grafana UI does not change based on data sent from a data source.
AFAIK you’d have to build a custom options editor for this.
Here’s an example from one of my plugins:
import React from 'react';
import { StandardEditorProps, FieldType } from '@grafana/data';
import { Select } from '@grafana/ui';
interface Settings {
filterByType: FieldType;
}
interface Props extends StandardEditorProps<string, Settings> {}
export const FieldSelectEditor: React.FC<Props> = ({ item, value, onChange, context }) => {
if (context.data && context.data.length > 0) {
const options = context.data
.flatMap(frame => frame.fields)
.filter(field => (item.settings?.filterByType ? field.type === item.settings?.filterByType : true))
.map(field => ({
label: field.name,
value: field.name,
}));
This file has been truncated. show original
StandardEditorProps
contains a context
prop that contains the query result from the data source.