mistercrunch closed pull request #4866: [axis formatting] Override the 
valueformat to be percentage when contribution is selected
URL: https://github.com/apache/incubator-superset/pull/4866
 
 
   

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/visualizations/nvd3_vis.js 
b/superset/assets/src/visualizations/nvd3_vis.js
index 4a3faba240..4088676dfb 100644
--- a/superset/assets/src/visualizations/nvd3_vis.js
+++ b/superset/assets/src/visualizations/nvd3_vis.js
@@ -252,7 +252,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);
         }
@@ -385,9 +385,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);
       }


 

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


With regards,
Apache Git Services

Reply via email to