diff --git a/superset-frontend/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js b/superset-frontend/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js index dd70afad3b36c..138788495c894 100644 --- a/superset-frontend/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js +++ b/superset-frontend/plugins/legacy-plugin-chart-sunburst/src/Sunburst.js @@ -82,7 +82,8 @@ function buildHierarchy(rows) { let currentNode = root; for (let level = 0; level < levels.length; level += 1) { const children = currentNode.children || []; - const nodeName = levels[level].toString(); + const node = levels[level]; + const nodeName = node ? node.toString() : t('N/A'); // If the next node has the name '0', it will const isLeafNode = level >= levels.length - 1 || levels[level + 1] === 0; let childNode; diff --git a/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts b/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts index a3a9b8777f440..d0b2d079cd25e 100644 --- a/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts +++ b/superset-frontend/plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts @@ -32,7 +32,7 @@ import { } from '@superset-ui/core'; import { EChartsCoreOption } from 'echarts'; import { CallbackDataParams } from 'echarts/types/src/util/types'; -import { OpacityEnum } from '../constants'; +import { NULL_STRING, OpacityEnum } from '../constants'; import { defaultGrid } from '../defaults'; import { Refs } from '../types'; import { formatSeriesName, getColtypesMapping } from '../utils/series'; @@ -138,7 +138,10 @@ export function formatTooltip({ color: ${theme.colors.grayscale.base}" >`, `
- ${node.name} + ${(node.name || NULL_STRING) + .toString() + .replaceAll('<', '<') + .replaceAll('>', '>')}
`, ` ${absolutePercentage} of total diff --git a/superset/cli/viz_migrations.py b/superset/cli/viz_migrations.py index 5d2ee4ae5d95b..9e69135aea386 100644 --- a/superset/cli/viz_migrations.py +++ b/superset/cli/viz_migrations.py @@ -28,6 +28,7 @@ class VizType(str, Enum): DUAL_LINE = "dual_line" AREA = "area" PIVOT_TABLE = "pivot_table" + SUNBURST = "sunburst" @click.group() @@ -76,6 +77,7 @@ def migrate(viz_type: VizType, is_downgrade: bool = False) -> None: MigrateAreaChart, MigrateDualLine, MigratePivotTable, + MigrateSunburst, MigrateTreeMap, ) @@ -84,6 +86,7 @@ def migrate(viz_type: VizType, is_downgrade: bool = False) -> None: VizType.DUAL_LINE: MigrateDualLine, VizType.AREA: MigrateAreaChart, VizType.PIVOT_TABLE: MigratePivotTable, + VizType.SUNBURST: MigrateSunburst, } if is_downgrade: migrations[viz_type].downgrade(db.session) diff --git a/superset/migrations/shared/migrate_viz/processors.py b/superset/migrations/shared/migrate_viz/processors.py index d1978f33e1ebd..4ff6b2a93467e 100644 --- a/superset/migrations/shared/migrate_viz/processors.py +++ b/superset/migrations/shared/migrate_viz/processors.py @@ -125,3 +125,9 @@ def _pre_action(self) -> None: def _migrate_temporal_filter(self, rv_data: dict[str, Any]) -> None: super()._migrate_temporal_filter(rv_data) rv_data["adhoc_filters_b"] = rv_data.get("adhoc_filters") or [] + + +class MigrateSunburst(MigrateViz): + source_viz_type = "sunburst" + target_viz_type = "sunburst_v2" + rename_keys = {"groupby": "columns"}