mirror of
https://github.com/apache/superset.git
synced 2026-04-19 16:14:52 +00:00
feat: Adds Bar chart migration logic (#28602)
This commit is contained in:
committed by
GitHub
parent
8c3250396f
commit
e17724a73a
@@ -109,12 +109,19 @@ class TimeseriesChart(MigrateViz):
|
||||
"show_controls": "show_extra_controls",
|
||||
"x_axis_label": "x_axis_title",
|
||||
"x_axis_format": "x_axis_time_format",
|
||||
"x_axis_showminmax": "truncateXAxis",
|
||||
"x_ticks_layout": "xAxisLabelRotation",
|
||||
"y_axis_label": "y_axis_title",
|
||||
"y_axis_showminmax": "truncateYAxis",
|
||||
"y_log_scale": "logAxis",
|
||||
}
|
||||
remove_keys = {"contribution", "show_brush", "show_markers"}
|
||||
remove_keys = {
|
||||
"contribution",
|
||||
"line_interpolation",
|
||||
"reduce_x_ticks",
|
||||
"show_brush",
|
||||
"show_markers",
|
||||
}
|
||||
|
||||
def _pre_action(self) -> None:
|
||||
self.data["contributionMode"] = "row" if self.data.get("contribution") else None
|
||||
@@ -156,8 +163,6 @@ class MigrateLineChart(TimeseriesChart):
|
||||
def _pre_action(self) -> None:
|
||||
super()._pre_action()
|
||||
|
||||
self.remove_keys.add("line_interpolation")
|
||||
|
||||
line_interpolation = self.data.get("line_interpolation")
|
||||
if line_interpolation == "cardinal":
|
||||
self.target_viz_type = "echarts_timeseries_smooth"
|
||||
@@ -190,6 +195,49 @@ class MigrateAreaChart(TimeseriesChart):
|
||||
self.data["opacity"] = 0.7
|
||||
|
||||
|
||||
class MigrateBarChart(TimeseriesChart):
|
||||
source_viz_type = "bar"
|
||||
target_viz_type = "echarts_timeseries_bar"
|
||||
|
||||
def _pre_action(self) -> None:
|
||||
super()._pre_action()
|
||||
|
||||
self.rename_keys["show_bar_value"] = "show_value"
|
||||
|
||||
self.remove_keys.add("bar_stacked")
|
||||
|
||||
self.data["stack"] = "Stack" if self.data.get("bar_stacked") else None
|
||||
|
||||
|
||||
class MigrateDistBarChart(TimeseriesChart):
|
||||
source_viz_type = "dist_bar"
|
||||
target_viz_type = "echarts_timeseries_bar"
|
||||
has_x_axis_control = False
|
||||
|
||||
def _pre_action(self) -> None:
|
||||
super()._pre_action()
|
||||
|
||||
groupby = self.data.get("groupby") or []
|
||||
columns = self.data.get("columns") or []
|
||||
if len(groupby) > 0:
|
||||
# x-axis supports only one value
|
||||
self.data["x_axis"] = groupby[0]
|
||||
|
||||
self.data["groupby"] = []
|
||||
if len(groupby) > 1:
|
||||
# rest of groupby will go into dimensions
|
||||
self.data["groupby"] += groupby[1:]
|
||||
if len(columns) > 0:
|
||||
self.data["groupby"] += columns
|
||||
|
||||
self.rename_keys["show_bar_value"] = "show_value"
|
||||
|
||||
self.remove_keys.add("columns")
|
||||
self.remove_keys.add("bar_stacked")
|
||||
|
||||
self.data["stack"] = "Stack" if self.data.get("bar_stacked") else None
|
||||
|
||||
|
||||
class MigrateBubbleChart(MigrateViz):
|
||||
source_viz_type = "bubble"
|
||||
target_viz_type = "bubble_v2"
|
||||
|
||||
Reference in New Issue
Block a user