wuxuedaifu commented on a change in pull request #5144: Adding a new viz 
line-bar chart
URL: 
https://github.com/apache/incubator-superset/pull/5144#discussion_r371588770
 
 

 ##########
 File path: superset/viz.py
 ##########
 @@ -2623,6 +2623,80 @@ def get_data(self, df):
         return self.nest_values(levels)
 
 
+class LineBarViz(NVD3Viz):
+
+    """A simple line bar chart with dual axis"""
+
+    viz_type = 'line_bar'
+    verbose_name = _('Time Series - Line Bar Chart')
+    sort_series = False
+    is_timeseries = True
+
+    def query_obj(self):
+        d = super(LineBarViz, self).query_obj()
+        m1 = self.form_data.get('metric')
+        m2 = self.form_data.get('metric_2')
+        d['metrics'] = [m1, m2]
+        if not m1:
+            raise Exception(_('Pick a metric for left(bar) axis!'))
+        if not m2:
+            raise Exception(_('Pick a metric for right(line) axis!'))
+        if m1 == m2:
+            raise Exception(_('Please choose different metrics'
+                            ' on left and right axis'))
+        return d
+
+    def to_series(self, df, classed=''):
+        cols = []
+        for col in df.columns:
+            if col == '':
+                cols.append('N/A')
+            elif col is None:
+                cols.append('NULL')
+            else:
+                cols.append(col)
+        df.columns = cols
+        series = df.to_dict('series')
+        chart_data = []
+        metrics = [
+            self.form_data.get('metric'),
+            self.form_data.get('metric_2'),
+        ]
+        for i, m in enumerate(metrics):
+            ys = series[m]
 
 Review comment:
   this line execution returns a error: can not hash a dict

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

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

Reply via email to