UNPKG

@grafana/ui

Version:
65 lines (62 loc) 1.79 kB
import { standardEditorsRegistry } from '@grafana/data'; import { LegendDisplayMode } from '@grafana/schema'; function addLegendOptions(builder, includeLegendCalcs = true, showLegend = true) { builder.addBooleanSwitch({ path: "legend.showLegend", name: "Visibility", category: ["Legend"], description: "", defaultValue: showLegend }).addRadio({ path: "legend.displayMode", name: "Mode", category: ["Legend"], description: "", defaultValue: LegendDisplayMode.List, settings: { options: [ { value: LegendDisplayMode.List, label: "List" }, { value: LegendDisplayMode.Table, label: "Table" } ] }, showIf: (c) => c.legend.showLegend }).addRadio({ path: "legend.placement", name: "Placement", category: ["Legend"], description: "", defaultValue: "bottom", settings: { options: [ { value: "bottom", label: "Bottom" }, { value: "right", label: "Right" } ] }, showIf: (c) => c.legend.showLegend }).addNumberInput({ path: "legend.width", name: "Width", category: ["Legend"], settings: { placeholder: "Auto" }, showIf: (c) => c.legend.showLegend && c.legend.placement === "right" }); if (includeLegendCalcs) { builder.addCustomEditor({ id: "legend.calcs", path: "legend.calcs", name: "Values", category: ["Legend"], description: "Select values or calculations to show in legend", editor: standardEditorsRegistry.get("stats-picker").editor, defaultValue: [], settings: { allowMultiple: true }, showIf: (currentConfig) => currentConfig.legend.showLegend !== false }); } } export { addLegendOptions }; //# sourceMappingURL=legend.mjs.map