Compare commits

...

1 Commits

Author SHA1 Message Date
Evan Rusackas
950d922cac feat(translations): make Radar chart label positions translatable
This enables label position options in the Radar chart control panel to
be translated by wrapping them with the t() function. The LABEL_POSITION
constant is removed from constants.ts and replaced with a local function
getLabelPositionOptions() that returns translatable label strings.

Fixes: https://github.com/apache/superset/issues/29479

Originally by @rusackas in https://github.com/apache/superset/pull/33940

Co-Authored-By: Evan Rusackas <evan@rusackas.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-02-05 16:49:55 -08:00
2 changed files with 18 additions and 19 deletions

View File

@@ -35,7 +35,7 @@ import {
getStandardizedControls,
} from '@superset-ui/chart-controls';
import { DEFAULT_FORM_DATA } from './types';
import { LABEL_POSITION } from '../constants';
import { LabelPositionEnum } from '../types';
import { legendSection } from '../controls';
const { labelType, labelPosition, numberFormat, showLabels, isCircle } =
@@ -72,6 +72,22 @@ const radarMetricMinValue: { name: string; config: ControlFormItemSpec } = {
},
};
const getLabelPositionOptions = (): [LabelPositionEnum, string][] => [
[LabelPositionEnum.Top, t('Top')],
[LabelPositionEnum.Left, t('Left')],
[LabelPositionEnum.Right, t('Right')],
[LabelPositionEnum.Bottom, t('Bottom')],
[LabelPositionEnum.Inside, t('Inside')],
[LabelPositionEnum.InsideLeft, t('Inside left')],
[LabelPositionEnum.InsideRight, t('Inside right')],
[LabelPositionEnum.InsideTop, t('Inside top')],
[LabelPositionEnum.InsideBottom, t('Inside bottom')],
[LabelPositionEnum.InsideTopLeft, t('Inside top left')],
[LabelPositionEnum.InsideBottomLeft, t('Inside bottom left')],
[LabelPositionEnum.InsideTopRight, t('Inside top right')],
[LabelPositionEnum.InsideBottomRight, t('Inside bottom right')],
];
const config: ControlPanelConfig = {
controlPanelSections: [
{
@@ -136,7 +152,7 @@ const config: ControlPanelConfig = {
freeForm: false,
label: t('Label position'),
renderTrigger: true,
choices: LABEL_POSITION,
choices: getLabelPositionOptions(),
default: labelPosition,
description: D3_FORMAT_DOCS,
},

View File

@@ -21,7 +21,6 @@ import { t } from '@apache-superset/core';
import { JsonValue, TimeGranularity } from '@superset-ui/core';
import { ReactNode } from 'react';
import {
LabelPositionEnum,
LegendFormData,
LegendOrientation,
LegendType,
@@ -50,22 +49,6 @@ export const TIMESERIES_CONSTANTS = {
horizontalBarLabelRightPadding: 70,
};
export const LABEL_POSITION: [LabelPositionEnum, string][] = [
[LabelPositionEnum.Top, 'Top'],
[LabelPositionEnum.Left, 'Left'],
[LabelPositionEnum.Right, 'Right'],
[LabelPositionEnum.Bottom, 'Bottom'],
[LabelPositionEnum.Inside, 'Inside'],
[LabelPositionEnum.InsideLeft, 'Inside left'],
[LabelPositionEnum.InsideRight, 'Inside right'],
[LabelPositionEnum.InsideTop, 'Inside top'],
[LabelPositionEnum.InsideBottom, 'Inside bottom'],
[LabelPositionEnum.InsideTopLeft, 'Inside top left'],
[LabelPositionEnum.InsideBottomLeft, 'Inside bottom left'],
[LabelPositionEnum.InsideTopRight, 'Inside top right'],
[LabelPositionEnum.InsideBottomRight, 'Inside bottom right'],
];
export enum OpacityEnum {
Transparent = 0,
SemiTransparent = 0.3,