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 2018/11/19 22:01:22 UTC

[GitHub] mistercrunch closed pull request #6391: Minor improvements to Histogram viz

mistercrunch closed pull request #6391: Minor improvements to Histogram viz
URL: https://github.com/apache/incubator-superset/pull/6391
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/superset/assets/src/explore/controlPanels/Histogram.js b/superset/assets/src/explore/controlPanels/Histogram.js
index 52896149ef..186dda2460 100644
--- a/superset/assets/src/explore/controlPanels/Histogram.js
+++ b/superset/assets/src/explore/controlPanels/Histogram.js
@@ -1,4 +1,5 @@
 import { t } from '@superset-ui/translation';
+import { nonEmpty } from '../validators';
 
 export default {
   controlPanelSections: [
@@ -29,6 +30,7 @@ export default {
       label: t('Numeric Columns'),
       description: t('Select the numeric columns to draw the histogram'),
       multi: true,
+      validators: [nonEmpty],
     },
     link_length: {
       label: t('No of Bins'),
diff --git a/superset/assets/src/visualizations/Histogram/Histogram.css b/superset/assets/src/visualizations/Histogram/Histogram.css
new file mode 100644
index 0000000000..28b7d70e81
--- /dev/null
+++ b/superset/assets/src/visualizations/Histogram/Histogram.css
@@ -0,0 +1,3 @@
+.histogram {
+  overflow: hidden;
+}
diff --git a/superset/assets/src/visualizations/Histogram/Histogram.jsx b/superset/assets/src/visualizations/Histogram/Histogram.jsx
index 8414830a2d..2b5451990c 100644
--- a/superset/assets/src/visualizations/Histogram/Histogram.jsx
+++ b/superset/assets/src/visualizations/Histogram/Histogram.jsx
@@ -6,6 +6,7 @@ import { LegendOrdinal } from '@vx/legend';
 import { scaleOrdinal } from '@vx/scale';
 import { CategoricalColorNamespace } from '@superset-ui/color';
 import WithLegend from '../WithLegend';
+import './Histogram.css';
 
 const propTypes = {
   className: PropTypes.string,
diff --git a/superset/viz.py b/superset/viz.py
index 068a70dcfd..e3e891ac07 100644
--- a/superset/viz.py
+++ b/superset/viz.py
@@ -1467,6 +1467,16 @@ def query_obj(self):
         d['groupby'] = []
         return d
 
+    def labelify(self, keys, column):
+        if isinstance(keys, str):
+            keys = (keys,)
+        # removing undesirable characters
+        labels = [re.sub(r'\W+', r'_', k) for k in keys]
+        if len(self.columns) > 1 or not self.groupby:
+            # Only show numeric column in label if there are many
+            labels = [column] + labels
+        return '__'.join(labels)
+
     def get_data(self, df):
         """Returns the chart data"""
         chart_data = []
@@ -1475,14 +1485,10 @@ def get_data(self, df):
         else:
             groups = [((), df)]
         for keys, data in groups:
-            if isinstance(keys, str):
-                keys = (keys,)
-            # removing undesirable characters
-            keys = [re.sub(r'\W+', r'_', k) for k in keys]
             chart_data.extend([{
-                'key': '__'.join([c] + keys),
-                'values': data[c].tolist()}
-                for c in self.columns])
+                'key': self.labelify(keys, column),
+                'values': data[column].tolist()}
+                for column in self.columns])
         return chart_data
 
 


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services

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