You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@superset.apache.org by gi...@git.apache.org on 2017/10/02 18:49:00 UTC

[GitHub] fabianmenges commented on a change in pull request #3566: [Fix]: Label generation for `grouped by`, `single metric` time series charts

fabianmenges commented on a change in pull request #3566: [Fix]: Label generation for `grouped by`, `single metric` time series charts
URL: https://github.com/apache/incubator-superset/pull/3566#discussion_r142223252
 
 

 ##########
 File path: superset/assets/visualizations/nvd3_vis.js
 ##########
 @@ -97,9 +100,22 @@ function nvd3Vis(slice, payload) {
   const isExplore = $('#explore-container').length === 1;
 
   let data;
+  // Get the most significant part of the series name (key)
+  const mostSignificant = payload.data
+    .filter(x => Array.isArray(x.key) && x.key.length > 1)
+    .map(x => x.key[0]);
+  // # of distinct most significant keys
+  const distinctMostSignificant = mostSignificant
+    .reduce((distinct, v) => distinct.add(v), new Set()).size;
+  // remove the msg key from the label if these conditions are true
+  const removeMostSignificant = mostSignificant.length === payload.data.length &&
+    distinctMostSignificant === 1;
 
 Review comment:
   instead of this (complicated) logic we could simplify  how we set the `removeMostSignificant` flag to:
   ```
   const removeMostSignificant = slice.formData.metrics.length === 1;
   ```
   However that would make the label generation depend on the fromData and it would therefore be less generic.
 
----------------------------------------------------------------
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