mirror of
https://github.com/grafana/grafana.git
synced 2025-02-20 11:48:34 -06:00
* StatPanel: Option showing name instead of value and more * rename option to textMode * Move the logic of only showing name if more than one value to gauge and bar gauge panels * Got tooltip working * Updated devenv test dashboard * Added docs for text mode * Added migration logic * Update docs/sources/panels/visualizations/stat-panel.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/panels/visualizations/stat-panel.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/panels/visualizations/stat-panel.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/panels/visualizations/stat-panel.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/panels/visualizations/stat-panel.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/panels/visualizations/stat-panel.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/panels/visualizations/stat-panel.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * docs fix * Fixed ts issue * review changes Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
import { sharedSingleStatPanelChangedHandler, BigValueGraphMode, BigValueColorMode } from '@grafana/ui';
|
|
import { PanelModel } from '@grafana/data';
|
|
import { StatPanelOptions } from './types';
|
|
import { BigValueTextMode } from '@grafana/ui/src/components/BigValue/BigValue';
|
|
|
|
// This is called when the panel changes from another panel
|
|
export const statPanelChangedHandler = (
|
|
panel: PanelModel<Partial<StatPanelOptions>> | any,
|
|
prevPluginId: string,
|
|
prevOptions: any
|
|
) => {
|
|
// This handles most config changes
|
|
const options = sharedSingleStatPanelChangedHandler(panel, prevPluginId, prevOptions) as StatPanelOptions;
|
|
|
|
// Changing from angular singlestat
|
|
if (prevPluginId === 'singlestat' && prevOptions.angular) {
|
|
const oldOptions = prevOptions.angular;
|
|
|
|
options.graphMode =
|
|
oldOptions.sparkline && oldOptions.sparkline.show === true ? BigValueGraphMode.Area : BigValueGraphMode.None;
|
|
|
|
if (oldOptions.colorBackground) {
|
|
options.colorMode = BigValueColorMode.Background;
|
|
} else {
|
|
options.colorMode = BigValueColorMode.Value;
|
|
}
|
|
|
|
if (oldOptions.valueName === 'name') {
|
|
options.textMode = BigValueTextMode.Name;
|
|
}
|
|
}
|
|
|
|
return options;
|
|
};
|