This is an automated email from the ASF dual-hosted git repository.
michaelsmolina pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/superset.git
The following commit(s) were added to refs/heads/master by this push:
new 0c083bdc1a feat: Adds Sunburst chart migration logic (#25343)
0c083bdc1a is described below
commit 0c083bdc1af4e6a3e17155246a3134cb5cb5887d
Author: Michael S. Molina <[email protected]>
AuthorDate: Fri Sep 22 09:44:40 2023 -0300
feat: Adds Sunburst chart migration logic (#25343)
---
.../plugins/legacy-plugin-chart-sunburst/src/Sunburst.js | 3 ++-
.../plugins/plugin-chart-echarts/src/Sunburst/transformProps.ts | 7 +++++--
superset/cli/viz_migrations.py | 3 +++
superset/migrations/shared/migrate_viz/processors.py | 6 ++++++
4 files changed, 16 insertions(+), 3 deletions(-)
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 dd70afad3b..138788495c 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 a3a9b8777f..d0b2d079cd 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}"
>`,
`<div style="font-weight: ${theme.typography.weights.bold}">
- ${node.name}
+ ${(node.name || NULL_STRING)
+ .toString()
+ .replaceAll('<', '<')
+ .replaceAll('>', '>')}
</div>`,
`<div">
${absolutePercentage} of total
diff --git a/superset/cli/viz_migrations.py b/superset/cli/viz_migrations.py
index 5d2ee4ae5d..9e69135aea 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 d1978f33e1..4ff6b2a934 100644
--- a/superset/migrations/shared/migrate_viz/processors.py
+++ b/superset/migrations/shared/migrate_viz/processors.py
@@ -125,3 +125,9 @@ class MigrateDualLine(MigrateViz):
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"}