Skip to content

Conversation

@abelyakin
Copy link
Contributor

Description

following issue #501
Implements Grafana's text mode feature to provide users with explicit control over what's displayed in stat panels. Previously, users were confused about when to use metricLabel vs legendFormat, and there was no way to show series names alongside values.

legendFormat: Template for formatting series names (e.g., {{instance}} - {{job}}). Applied to all series for display purposes.
metricLabel: Selects which label's value to display instead of the calculated number (e.g., show the "status" label value like "healthy" or "degraded" rather than a numeric metric).
textMode: Controls what to show - the calculated value, series name, both, or neither.

Updated and simplified the migration logic to map textMode from panel options and handle various display scenarios.
Grafana's textMode values pass through directly without conversion. Existing panels default to auto for backward compatibility.

Screenshots

text mode = name

Screenshot 2026-01-16 at 03 29 07

text mode = value

Screenshot 2026-01-16 at 03 29 18

text mode = value and name

Screenshot 2026-01-16 at 03 29 40

Checklist

  • Pull request has a descriptive title and context useful to a reviewer.
  • Pull request title follows the [<catalog_entry>] <commit message> naming convention using one of the
    following catalog_entry values: FEATURE, ENHANCEMENT, BUGFIX, BREAKINGCHANGE, DOC,IGNORE.
  • All commits have DCO signoffs.

UI Changes

  • Changes that impact the UI include screenshots and/or screencasts of the relevant changes.
  • Code follows the UI guidelines.

…ogic

- Introduced a new  property in the StatChart schema to control how values and names are displayed.
- Updated the migration logic to map  from panel options and handle various display scenarios.
- Refactored the StatChartBase component to utilize  for determining what to display (value, name, both, or none).
- Adjusted tests and expected outputs to reflect changes in text mode handling.
- Enhanced the StatChartOptionsEditorSettings to allow users to select the desired text mode.

Signed-off-by: Alexander Belyakin <21216343+abelyakin@users.noreply.github.com>
@abelyakin abelyakin requested review from a team and AntoineThebaud as code owners January 16, 2026 00:58
@abelyakin abelyakin requested review from Gladorme and removed request for a team January 16, 2026 00:58
Copy link
Contributor

@AntoineThebaud AntoineThebaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your PR 🙏 LGTM except the comment below; please also deal with the conflict and we shall get this merged quickly :)

Comment on lines +40 to +43
#grafanaTextMode: *#panel.options.textMode | "auto"
if #grafanaTextMode != null {
textMode: #grafanaTextMode
}
Copy link
Contributor

@AntoineThebaud AntoineThebaud Jan 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if is always mached in the current case as #grafanaTextMod falls back to "auto" (never null), so you should either change to

Suggested change
#grafanaTextMode: *#panel.options.textMode | "auto"
if #grafanaTextMode != null {
textMode: #grafanaTextMode
}
#grafanaTextMode: *#panel.options.textMode | null
if #grafanaTextMode != null {
textMode: #grafanaTextMode
}

or

Suggested change
#grafanaTextMode: *#panel.options.textMode | "auto"
if #grafanaTextMode != null {
textMode: #grafanaTextMode
}
textMode: *#panel.options.textMode | "auto"

since textMode is an optional attribute I guess the first suggestion makes more sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants