suggestions.ts 967 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { VisualizationSuggestionsBuilder } from '@grafana/data';
  2. import { config } from '@grafana/runtime';
  3. import { prepareHeatmapData } from './fields';
  4. import { PanelOptions, defaultPanelOptions } from './models.gen';
  5. export class HeatmapSuggestionsSupplier {
  6. getSuggestionsForData(builder: VisualizationSuggestionsBuilder) {
  7. const { dataSummary } = builder;
  8. if (
  9. !builder.data?.series ||
  10. !dataSummary.hasData ||
  11. dataSummary.timeFieldCount < 1 ||
  12. dataSummary.numberFieldCount < 2 ||
  13. dataSummary.numberFieldCount > 10
  14. ) {
  15. return;
  16. }
  17. const info = prepareHeatmapData(builder.data, defaultPanelOptions, config.theme2);
  18. if (!info || info.warning) {
  19. return;
  20. }
  21. builder.getListAppender<PanelOptions, {}>({
  22. name: '',
  23. pluginId: 'heatmap-new',
  24. options: {},
  25. fieldConfig: {
  26. defaults: {
  27. custom: {},
  28. },
  29. overrides: [],
  30. },
  31. });
  32. }
  33. }