You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ma...@apache.org on 2018/04/23 17:05:32 UTC

[incubator-superset] branch master updated: [axis formatting] Override the valueformat to be percentage when contribution is selected (#4866)

This is an automated email from the ASF dual-hosted git repository.

maximebeauchemin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-superset.git


The following commit(s) were added to refs/heads/master by this push:
     new 2cd016f  [axis formatting] Override the valueformat to be percentage when contribution is selected (#4866)
2cd016f is described below

commit 2cd016f11ce306fb0cdb6b1276ab034592f254ec
Author: Conglei <sh...@gmail.com>
AuthorDate: Mon Apr 23 10:05:29 2018 -0700

    [axis formatting] Override the valueformat to be percentage when contribution is selected (#4866)
    
    * force the valueformat to be percentage when contribution is selected
    
    * remove extra empty lines
    
    * simplied the logic by reusing some existing code
---
 superset/assets/src/visualizations/nvd3_vis.js | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/superset/assets/src/visualizations/nvd3_vis.js b/superset/assets/src/visualizations/nvd3_vis.js
index 6a115f0..68fe69f 100644
--- a/superset/assets/src/visualizations/nvd3_vis.js
+++ b/superset/assets/src/visualizations/nvd3_vis.js
@@ -253,7 +253,7 @@ export default function nvd3Vis(slice, payload) {
       case 'pie':
         chart = nv.models.pieChart();
         colorKey = 'x';
-        chart.valueFormat(f);
+        chart.valueFormat(formatter);
         if (fd.donut) {
           chart.donut(true);
         }
@@ -386,9 +386,10 @@ export default function nvd3Vis(slice, payload) {
 
     const yAxisFormatter = d3FormatPreset(fd.y_axis_format);
     if (chart.yAxis && chart.yAxis.tickFormat) {
-      if (fd.num_period_compare) {
-        // When computing a "Period Ratio", we force a percentage format
-        chart.yAxis.tickFormat(d3.format('.1%'));
+      if (fd.num_period_compare || fd.contribution) {
+        // When computing a "Period Ratio" or "Contribution" selected, we force a percentage format
+        const percentageFormat = d3.format('.1%');
+        chart.yAxis.tickFormat(percentageFormat);
       } else {
         chart.yAxis.tickFormat(yAxisFormatter);
       }

-- 
To stop receiving notification emails like this one, please contact
maximebeauchemin@apache.org.