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


##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -184,3 +184,32 @@ def _pre_action(self) -> None:
         )
 
         self.data["opacity"] = 0.7
+
+
+class MigrateBubbleChart(MigrateViz):
+    source_viz_type = "bubble"
+    target_viz_type = "bubble_v2"
+    rename_keys = {
+        "bottom_margin": "x_axis_title_margin",

Review Comment:
   Unrelated, but what's the reason we have a mix of snake- and camel-case in 
the chart properties?



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -184,3 +184,32 @@ def _pre_action(self) -> None:
         )
 
         self.data["opacity"] = 0.7
+
+
+class MigrateBubbleChart(MigrateViz):
+    source_viz_type = "bubble"
+    target_viz_type = "bubble_v2"
+    rename_keys = {
+        "bottom_margin": "x_axis_title_margin",
+        "left_margin": "y_axis_title_margin",
+        "limit": "row_limit",
+        "x_axis_format": "xAxisFormat",
+        "x_log_scale": "logXAxis",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "y_axis_showminmax": "truncateYAxis",
+        "y_log_scale": "logYAxis",
+    }
+    remove_keys = {"x_axis_showminmax"}
+
+    def _pre_action(self) -> None:
+        bottom_margin = self.data.get("bottom_margin")
+        if self.data.get("x_axis_label") and (
+            not bottom_margin or bottom_margin == "auto"
+        ):
+            self.data["bottom_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
+
+        # Truncate Y-axis by default to preserve layout
+        self.data["y_axis_showminmax"] = True

Review Comment:
   Just to confirm, this occurs prior to the renaming of the keys?



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -184,3 +184,32 @@ def _pre_action(self) -> None:
         )
 
         self.data["opacity"] = 0.7
+
+
+class MigrateBubbleChart(MigrateViz):
+    source_viz_type = "bubble"
+    target_viz_type = "bubble_v2"
+    rename_keys = {
+        "bottom_margin": "x_axis_title_margin",
+        "left_margin": "y_axis_title_margin",
+        "limit": "row_limit",
+        "x_axis_format": "xAxisFormat",
+        "x_log_scale": "logXAxis",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "y_axis_showminmax": "truncateYAxis",
+        "y_log_scale": "logYAxis",
+    }
+    remove_keys = {"x_axis_showminmax"}
+
+    def _pre_action(self) -> None:
+        bottom_margin = self.data.get("bottom_margin")
+        if self.data.get("x_axis_label") and (
+            not bottom_margin or bottom_margin == "auto"
+        ):
+            self.data["bottom_margin"] = 30

Review Comment:
   Any reason the bottom margin is now fix to 30 (pixels?) as opposed to being 
automatic?



##########
superset/migrations/shared/migrate_viz/processors.py:
##########
@@ -184,3 +184,32 @@ def _pre_action(self) -> None:
         )
 
         self.data["opacity"] = 0.7
+
+
+class MigrateBubbleChart(MigrateViz):
+    source_viz_type = "bubble"
+    target_viz_type = "bubble_v2"
+    rename_keys = {
+        "bottom_margin": "x_axis_title_margin",
+        "left_margin": "y_axis_title_margin",
+        "limit": "row_limit",
+        "x_axis_format": "xAxisFormat",
+        "x_log_scale": "logXAxis",
+        "x_ticks_layout": "xAxisLabelRotation",
+        "y_axis_showminmax": "truncateYAxis",
+        "y_log_scale": "logYAxis",
+    }
+    remove_keys = {"x_axis_showminmax"}
+
+    def _pre_action(self) -> None:
+        bottom_margin = self.data.get("bottom_margin")
+        if self.data.get("x_axis_label") and (
+            not bottom_margin or bottom_margin == "auto"
+        ):
+            self.data["bottom_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
+
+        # Truncate Y-axis by default to preserve layout

Review Comment:
   ```suggestion
           # Truncate y-axis by default to preserve layout
   ```



-- 
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