diff --git a/public/app/core/components/TimelineChart/TimelineChart.tsx b/public/app/core/components/TimelineChart/TimelineChart.tsx index f4317a127b7..df200bc1d27 100644 --- a/public/app/core/components/TimelineChart/TimelineChart.tsx +++ b/public/app/core/components/TimelineChart/TimelineChart.tsx @@ -16,6 +16,7 @@ export interface TimelineProps extends Omit { getValueColor = (frameIdx: number, fieldIdx: number, value: unknown) => { diff --git a/public/app/core/components/TimelineChart/utils.ts b/public/app/core/components/TimelineChart/utils.ts index 1b233d4a3ad..a793f6795ef 100644 --- a/public/app/core/components/TimelineChart/utils.ts +++ b/public/app/core/components/TimelineChart/utils.ts @@ -50,6 +50,7 @@ interface UPlotConfigOptions { colWidth?: number; showValue: VisibilityMode; alignValue?: TimelineValueAlignment; + seriesNameAlignment?: 'left' | 'right'; mergeValues?: boolean; getValueColor: (frameIdx: number, fieldIdx: number, value: unknown) => string; hoverMulti: boolean; @@ -90,6 +91,7 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn = ( colWidth, showValue, alignValue, + seriesNameAlignment, mergeValues, getValueColor, hoverMulti, @@ -181,11 +183,12 @@ export const preparePlotConfigBuilder: UPlotConfigPrepFn = ( const yCustomConfig = frame.fields[1].config.custom; const yAxisWidth = yCustomConfig.axisWidth; const yAxisHidden = yCustomConfig.axisPlacement === AxisPlacement.Hidden; + const yAxisPlacement = seriesNameAlignment === 'right' ? AxisPlacement.Right : AxisPlacement.Left; builder.addAxis({ scaleKey: FIXED_UNIT, // y isTime: false, - placement: AxisPlacement.Left, + placement: yAxisPlacement, splits: coreConfig.ySplits, values: yAxisHidden ? (u, splits) => splits.map((v) => null) : coreConfig.yValues, grid: { show: false }, diff --git a/public/app/plugins/panel/state-timeline/module.tsx b/public/app/plugins/panel/state-timeline/module.tsx index 61053b28090..aa81a82868f 100644 --- a/public/app/plugins/panel/state-timeline/module.tsx +++ b/public/app/plugins/panel/state-timeline/module.tsx @@ -132,6 +132,18 @@ export const plugin = new PanelPlugin(StateTimelinePanel) }, defaultValue: defaultOptions.alignValue, }) + .addRadio({ + path: 'seriesNameAlignment', + name: t('state-timeline.name-align-series-names', 'Align series names'), + category, + settings: { + options: [ + { value: 'left', label: t('state-timeline.align-series-names-options.label-left', 'Left') }, + { value: 'right', label: t('state-timeline.align-series-names-options.label-right', 'Right') }, + ], + }, + defaultValue: 'left', + }) .addSliderInput({ path: 'rowHeight', name: t('state-timeline.name-row-height', 'Row height'), diff --git a/public/app/plugins/panel/state-timeline/panelcfg.cue b/public/app/plugins/panel/state-timeline/panelcfg.cue index 5a9c34e2a28..124ff2ffff5 100644 --- a/public/app/plugins/panel/state-timeline/panelcfg.cue +++ b/public/app/plugins/panel/state-timeline/panelcfg.cue @@ -37,6 +37,8 @@ composableKinds: PanelCfg: { mergeValues?: bool | *true //Controls value alignment on the timelines alignValue?: ui.TimelineValueAlignment & (*"left" | _) + //Controls series name alignment on the y-axis + seriesNameAlignment?: ("left" | "right") & (*"left" | _) //Enables pagination when > 0 perPage?: number & >=1 | *20 } @cuetsy(kind="interface") diff --git a/public/app/plugins/panel/state-timeline/panelcfg.gen.ts b/public/app/plugins/panel/state-timeline/panelcfg.gen.ts index 5ea1b58af54..e3a4abd5df5 100644 --- a/public/app/plugins/panel/state-timeline/panelcfg.gen.ts +++ b/public/app/plugins/panel/state-timeline/panelcfg.gen.ts @@ -27,6 +27,10 @@ export interface Options extends ui.OptionsWithLegend, ui.OptionsWithTooltip, ui * Controls the row height */ rowHeight: number; + /** + * Controls series name alignment on the y-axis + */ + seriesNameAlignment?: 'left' | 'right'; /** * Show timeline values on chart */ @@ -38,6 +42,7 @@ export const defaultOptions: Partial = { mergeValues: true, perPage: 20, rowHeight: 0.9, + seriesNameAlignment: 'left', showValue: ui.VisibilityMode.Auto, };