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

[incubator-superset] branch master updated: [bug fix] Fixed forced percentage format on tooltips and bubble chart tooltips format. (#5631)

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

johnbodley 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 2171ffb  [bug fix] Fixed forced percentage format on tooltips and bubble chart tooltips format. (#5631)
2171ffb is described below

commit 2171ffb630873a6cc31173aa5f7971aaf21c0c03
Author: Conglei <sh...@gmail.com>
AuthorDate: Tue Aug 14 16:04:24 2018 -0700

    [bug fix] Fixed forced percentage format on tooltips and bubble chart tooltips format. (#5631)
    
    * fixed forced percentage format on tooltip and correct reflection on bubble chart tooltip format
    
    * re-trigger build
---
 superset/assets/src/visualizations/nvd3_vis.js | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/superset/assets/src/visualizations/nvd3_vis.js b/superset/assets/src/visualizations/nvd3_vis.js
index 4dcdb40..33694dd 100644
--- a/superset/assets/src/visualizations/nvd3_vis.js
+++ b/superset/assets/src/visualizations/nvd3_vis.js
@@ -324,13 +324,15 @@ export default function nvd3Vis(slice, payload) {
         chart.showDistY(true);
         chart.tooltip.contentGenerator(function (obj) {
           const p = obj.point;
+          const yAxisFormatter = d3FormatPreset(fd.y_axis_format);
+          const xAxisFormatter = d3FormatPreset(fd.x_axis_format);
           let s = '<table>';
           s += (
             `<tr><td style="color: ${p.color};">` +
               `<strong>${p[fd.entity]}</strong> (${p.group})` +
             '</td></tr>');
-          s += row(fd.x, formatter(p.x));
-          s += row(fd.y, formatter(p.y));
+          s += row(fd.x, xAxisFormatter(p.x));
+          s += row(fd.y, yAxisFormatter(p.y));
           s += row(fd.size, formatter(p.size));
           s += '</table>';
           return s;
@@ -412,15 +414,13 @@ export default function nvd3Vis(slice, payload) {
       chart.xAxis.tickFormat(xAxisFormatter);
     }
 
-    const yAxisFormatter = d3FormatPreset(fd.y_axis_format);
+    let yAxisFormatter = d3FormatPreset(fd.y_axis_format);
     if (chart.yAxis && chart.yAxis.tickFormat) {
       if (fd.contribution || fd.comparison_type === 'percentage') {
         // When computing a "Percentage" or "Contribution" selected, we force a percentage format
-        const percentageFormat = d3.format('.1%');
-        chart.yAxis.tickFormat(percentageFormat);
-      } else {
-        chart.yAxis.tickFormat(yAxisFormatter);
+        yAxisFormatter = d3.format('.1%');
       }
+      chart.yAxis.tickFormat(yAxisFormatter);
     }
     if (chart.y2Axis && chart.y2Axis.tickFormat) {
       chart.y2Axis.tickFormat(yAxisFormatter);