diff --git a/packages/grafana-data/src/types/panel.ts b/packages/grafana-data/src/types/panel.ts index ad51625f04c..1c1ca6aa821 100644 --- a/packages/grafana-data/src/types/panel.ts +++ b/packages/grafana-data/src/types/panel.ts @@ -69,6 +69,8 @@ export interface PanelProps { onChangeTimeRange: (timeRange: AbsoluteTimeRange) => void; /** @internal */ renderCounter: number; + /** Panel title */ + title: string; } export interface PanelEditorProps { diff --git a/public/app/features/dashboard/dashgrid/PanelChrome.tsx b/public/app/features/dashboard/dashgrid/PanelChrome.tsx index 667c3c78630..a0a385cf3f2 100644 --- a/public/app/features/dashboard/dashgrid/PanelChrome.tsx +++ b/public/app/features/dashboard/dashgrid/PanelChrome.tsx @@ -273,6 +273,7 @@ export class PanelChrome extends PureComponent { {}} onOptionsChange={() => {}} diff --git a/public/app/plugins/panel/stat/StatPanel.tsx b/public/app/plugins/panel/stat/StatPanel.tsx index 3b750e658b3..6eb9470e1dc 100644 --- a/public/app/plugins/panel/stat/StatPanel.tsx +++ b/public/app/plugins/panel/stat/StatPanel.tsx @@ -6,6 +6,7 @@ import { DataLinksContextMenu, VizRepeater, VizRepeaterRenderValueProps, + BigValueTextMode, } from '@grafana/ui'; import { DisplayValueAlignmentFactors, @@ -53,7 +54,7 @@ export class StatPanel extends PureComponent> { colorMode={options.colorMode} graphMode={options.graphMode} justifyMode={options.justifyMode} - textMode={options.textMode} + textMode={this.getTextMode()} alignmentFactors={alignmentFactors} width={width} height={height} @@ -63,6 +64,18 @@ export class StatPanel extends PureComponent> { /> ); }; + + getTextMode() { + const { options, fieldConfig, title } = this.props; + + // If we have manually set displayName or panel title switch text mode to value and name + if (options.textMode === BigValueTextMode.Auto && (fieldConfig.defaults.displayName || !title)) { + return BigValueTextMode.ValueAndName; + } + + return options.textMode; + } + renderValue = (valueProps: VizRepeaterRenderValueProps): JSX.Element => { const { value } = valueProps; const { getLinks, hasLinks } = value;