mirror of
https://github.com/grafana/grafana.git
synced 2025-08-01 23:43:26 +08:00

* fix some anys * some canvas/geomap improvements * some more panel type fixes * just omit the type in TagOption
41 lines
1.2 KiB
TypeScript
41 lines
1.2 KiB
TypeScript
import { VisualizationSuggestionsBuilder } from '@grafana/data';
|
|
import { GraphDrawStyle, GraphFieldConfig, VizLegendOptions } from '@grafana/schema';
|
|
import { SuggestionName } from 'app/types/suggestions';
|
|
|
|
import { Options } from './panelcfg.gen';
|
|
|
|
export class TrendSuggestionsSupplier {
|
|
getSuggestionsForData(builder: VisualizationSuggestionsBuilder) {
|
|
const { dataSummary } = builder;
|
|
|
|
if (dataSummary.numberFieldCount < 2 || dataSummary.rowCountTotal < 2 || dataSummary.rowCountTotal < 2) {
|
|
return;
|
|
}
|
|
|
|
// Super basic
|
|
const list = builder.getListAppender<Options, GraphFieldConfig>({
|
|
name: SuggestionName.LineChart,
|
|
pluginId: 'trend',
|
|
options: {
|
|
legend: {} as VizLegendOptions,
|
|
},
|
|
fieldConfig: {
|
|
defaults: {
|
|
custom: {},
|
|
},
|
|
overrides: [],
|
|
},
|
|
cardOptions: {
|
|
previewModifier: (s) => {
|
|
s.options!.legend.showLegend = false;
|
|
|
|
if (s.fieldConfig?.defaults.custom?.drawStyle !== GraphDrawStyle.Bars) {
|
|
s.fieldConfig!.defaults.custom!.lineWidth = Math.max(s.fieldConfig!.defaults.custom!.lineWidth ?? 1, 2);
|
|
}
|
|
},
|
|
},
|
|
});
|
|
return list;
|
|
}
|
|
}
|