john-bodley commented on code in PR #23870:
URL: https://github.com/apache/superset/pull/23870#discussion_r1201269114


##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -34,20 +34,50 @@ def _pre_action(self) -> None:
 class MigrateAreaChart(MigrateViz):
     source_viz_type = "area"
     target_viz_type = "echarts_area"
+    has_x_axis_control = True
     remove_keys = {"contribution", "stacked_style", "x_axis_label"}
+    rename_keys = {
+        "x_axis_label": "x_axis_title",
+        "x_axis_format": "x_axis_time_format",

Review Comment:
   I'm surprised this has the term `time` in it given that I thought part of 
the broader EChart migration was to support time agnostic, i.e., generic, 
charts.



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -34,20 +34,50 @@ def _pre_action(self) -> None:
 class MigrateAreaChart(MigrateViz):
     source_viz_type = "area"
     target_viz_type = "echarts_area"
+    has_x_axis_control = True
     remove_keys = {"contribution", "stacked_style", "x_axis_label"}
+    rename_keys = {
+        "x_axis_label": "x_axis_title",
+        "x_axis_format": "x_axis_time_format",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "bottom_margin": "x_axis_title_margin",
+        "y_log_scale": "logAxis",
+    }
 
     def _pre_action(self) -> None:
-        if self.data.get("contribution"):
-            self.data["contributionMode"] = "row"
+        if contribution := self.data.get("contribution"):
+            self.data["contributionMode"] = "row" if contribution else None

Review Comment:
   Given, per line #48, `contribution` is truthy this should reduce to:
   
   ```python
   if self.data.get("contribution"):
       self.data["contributionMode"] = "row"
   ```



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -34,20 +34,50 @@ def _pre_action(self) -> None:
 class MigrateAreaChart(MigrateViz):
     source_viz_type = "area"
     target_viz_type = "echarts_area"
+    has_x_axis_control = True
     remove_keys = {"contribution", "stacked_style", "x_axis_label"}
+    rename_keys = {
+        "x_axis_label": "x_axis_title",
+        "x_axis_format": "x_axis_time_format",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "bottom_margin": "x_axis_title_margin",
+        "y_log_scale": "logAxis",
+    }
 
     def _pre_action(self) -> None:
-        if self.data.get("contribution"):
-            self.data["contributionMode"] = "row"
+        if contribution := self.data.get("contribution"):
+            self.data["contributionMode"] = "row" if contribution else None
+
+        show_brush = self.data.get("show_brush")
+        self.data["zoomable"] = False if show_brush == "no" else True
+        self.data["y_axis_showminmax"] = True
 
         if stacked := self.data.get("stacked_style"):
             stacked_map = {
                 "expand": "Expand",
                 "stack": "Stack",
+                "stream": "Stream",
             }
             self.data["show_extra_controls"] = True
             self.data["stack"] = stacked_map.get(stacked)
 
-        if x_axis_label := self.data.get("x_axis_label"):
-            self.data["x_axis_title"] = x_axis_label
-            self.data["x_axis_title_margin"] = 30
+        if x_ticks_layout := self.data.get("x_ticks_layout"):
+            self.data["x_ticks_layout"] = 45 if x_ticks_layout == "45°" else 0
+
+        x_axis_label = self.data.get("x_axis_label")
+        bottom_margin = self.data.get("bottom_margin")
+        if x_axis_label and (not bottom_margin or bottom_margin == "auto"):

Review Comment:
   See https://github.com/apache/superset/pull/23973/files#r1201279048.



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -34,20 +34,50 @@ def _pre_action(self) -> None:
 class MigrateAreaChart(MigrateViz):
     source_viz_type = "area"
     target_viz_type = "echarts_area"
+    has_x_axis_control = True
     remove_keys = {"contribution", "stacked_style", "x_axis_label"}
+    rename_keys = {
+        "x_axis_label": "x_axis_title",
+        "x_axis_format": "x_axis_time_format",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "bottom_margin": "x_axis_title_margin",
+        "y_log_scale": "logAxis",
+    }
 
     def _pre_action(self) -> None:
-        if self.data.get("contribution"):
-            self.data["contributionMode"] = "row"
+        if contribution := self.data.get("contribution"):
+            self.data["contributionMode"] = "row" if contribution else None
+
+        show_brush = self.data.get("show_brush")
+        self.data["zoomable"] = False if show_brush == "no" else True
+        self.data["y_axis_showminmax"] = True
 
         if stacked := self.data.get("stacked_style"):
             stacked_map = {
                 "expand": "Expand",
                 "stack": "Stack",
+                "stream": "Stream",
             }
             self.data["show_extra_controls"] = True
             self.data["stack"] = stacked_map.get(stacked)
 
-        if x_axis_label := self.data.get("x_axis_label"):
-            self.data["x_axis_title"] = x_axis_label
-            self.data["x_axis_title_margin"] = 30
+        if x_ticks_layout := self.data.get("x_ticks_layout"):
+            self.data["x_ticks_layout"] = 45 if x_ticks_layout == "45°" else 0
+
+        x_axis_label = self.data.get("x_axis_label")
+        bottom_margin = self.data.get("bottom_margin")
+        if x_axis_label and (not bottom_margin or bottom_margin == "auto"):
+            self.data["bottom_margin"] = 30
+
+        self.data["opacity"] = 0.7
+
+        if rolling_type := self.data.get("rolling_type"):
+            self.data["rolling_type"] = None if rolling_type == "None" else 
rolling_type

Review Comment:
   See https://github.com/apache/superset/pull/23973/files#r1201214384.



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -34,20 +34,50 @@ def _pre_action(self) -> None:
 class MigrateAreaChart(MigrateViz):
     source_viz_type = "area"
     target_viz_type = "echarts_area"
+    has_x_axis_control = True
     remove_keys = {"contribution", "stacked_style", "x_axis_label"}
+    rename_keys = {
+        "x_axis_label": "x_axis_title",
+        "x_axis_format": "x_axis_time_format",
+        "x_ticks_layout": "xAxisLabelRotation",

Review Comment:
   Why is there a mix of snake- and camel-case keys?



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -34,20 +34,50 @@ def _pre_action(self) -> None:
 class MigrateAreaChart(MigrateViz):
     source_viz_type = "area"
     target_viz_type = "echarts_area"
+    has_x_axis_control = True
     remove_keys = {"contribution", "stacked_style", "x_axis_label"}
+    rename_keys = {
+        "x_axis_label": "x_axis_title",
+        "x_axis_format": "x_axis_time_format",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "bottom_margin": "x_axis_title_margin",
+        "y_log_scale": "logAxis",
+    }
 
     def _pre_action(self) -> None:
-        if self.data.get("contribution"):
-            self.data["contributionMode"] = "row"
+        if contribution := self.data.get("contribution"):
+            self.data["contributionMode"] = "row" if contribution else None
+
+        show_brush = self.data.get("show_brush")
+        self.data["zoomable"] = False if show_brush == "no" else True

Review Comment:
   ```suggestion
           self.data["zoomable"] = not self.data.get("show_brush") == "no"
   ```



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -34,20 +34,50 @@ def _pre_action(self) -> None:
 class MigrateAreaChart(MigrateViz):
     source_viz_type = "area"
     target_viz_type = "echarts_area"
+    has_x_axis_control = True
     remove_keys = {"contribution", "stacked_style", "x_axis_label"}
+    rename_keys = {
+        "x_axis_label": "x_axis_title",
+        "x_axis_format": "x_axis_time_format",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "bottom_margin": "x_axis_title_margin",
+        "y_log_scale": "logAxis",
+    }
 
     def _pre_action(self) -> None:
-        if self.data.get("contribution"):
-            self.data["contributionMode"] = "row"
+        if contribution := self.data.get("contribution"):
+            self.data["contributionMode"] = "row" if contribution else None
+
+        show_brush = self.data.get("show_brush")
+        self.data["zoomable"] = False if show_brush == "no" else True
+        self.data["y_axis_showminmax"] = True
 
         if stacked := self.data.get("stacked_style"):
             stacked_map = {
                 "expand": "Expand",
                 "stack": "Stack",
+                "stream": "Stream",
             }
             self.data["show_extra_controls"] = True
             self.data["stack"] = stacked_map.get(stacked)
 
-        if x_axis_label := self.data.get("x_axis_label"):
-            self.data["x_axis_title"] = x_axis_label
-            self.data["x_axis_title_margin"] = 30
+        if x_ticks_layout := self.data.get("x_ticks_layout"):
+            self.data["x_ticks_layout"] = 45 if x_ticks_layout == "45°" else 0
+
+        x_axis_label = self.data.get("x_axis_label")
+        bottom_margin = self.data.get("bottom_margin")
+        if x_axis_label and (not bottom_margin or bottom_margin == "auto"):
+            self.data["bottom_margin"] = 30

Review Comment:
   It's interesting we're switching from an auto margin to an explicit.



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -34,20 +34,50 @@ def _pre_action(self) -> None:
 class MigrateAreaChart(MigrateViz):
     source_viz_type = "area"
     target_viz_type = "echarts_area"
+    has_x_axis_control = True
     remove_keys = {"contribution", "stacked_style", "x_axis_label"}
+    rename_keys = {
+        "x_axis_label": "x_axis_title",
+        "x_axis_format": "x_axis_time_format",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "bottom_margin": "x_axis_title_margin",
+        "y_log_scale": "logAxis",
+    }
 
     def _pre_action(self) -> None:
-        if self.data.get("contribution"):
-            self.data["contributionMode"] = "row"
+        if contribution := self.data.get("contribution"):
+            self.data["contributionMode"] = "row" if contribution else None
+
+        show_brush = self.data.get("show_brush")
+        self.data["zoomable"] = False if show_brush == "no" else True
+        self.data["y_axis_showminmax"] = True
 
         if stacked := self.data.get("stacked_style"):
             stacked_map = {
                 "expand": "Expand",
                 "stack": "Stack",
+                "stream": "Stream",
             }
             self.data["show_extra_controls"] = True
             self.data["stack"] = stacked_map.get(stacked)
 
-        if x_axis_label := self.data.get("x_axis_label"):
-            self.data["x_axis_title"] = x_axis_label
-            self.data["x_axis_title_margin"] = 30
+        if x_ticks_layout := self.data.get("x_ticks_layout"):
+            self.data["x_ticks_layout"] = 45 if x_ticks_layout == "45°" else 0

Review Comment:
   Is `0` akin to `None` or undefined? If so there's probably no need to set it.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to