You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by GitBox <gi...@apache.org> on 2021/01/22 10:35:14 UTC

[GitHub] [superset] villebro commented on a change in pull request #12660: fix(multiline): return all chart data on initial request

villebro commented on a change in pull request #12660:
URL: https://github.com/apache/superset/pull/12660#discussion_r562540388



##########
File path: superset/viz.py
##########
@@ -1405,21 +1405,55 @@ def query_obj(self) -> QueryObjectDict:
         return {}
 
     def get_data(self, df: pd.DataFrame) -> VizData:
-        fd = self.form_data
-        # Late imports to avoid circular import issues
-        from superset import db
-        from superset.models.slice import Slice
-
-        slice_ids1 = fd.get("line_charts")
-        slices1 = db.session.query(Slice).filter(Slice.id.in_(slice_ids1)).all()
-        slice_ids2 = fd.get("line_charts_2")
-        slices2 = db.session.query(Slice).filter(Slice.id.in_(slice_ids2)).all()
-        return {
-            "slices": {
-                "axis1": [slc.data for slc in slices1],
-                "axis2": [slc.data for slc in slices2],
-            }
-        }
+        multiline_fd = self.form_data
+        # Late import to avoid circular import issues
+        from superset.charts.dao import ChartDAO
+
+        axis1_charts = ChartDAO.find_by_ids(multiline_fd.get("line_charts", []))
+        axis2_charts = ChartDAO.find_by_ids(multiline_fd.get("line_charts_2", []))

Review comment:
       I did a slight variation of this to that doesn't fail if there are duplicates (shouldn't be the case, but you never know).




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org