You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@superset.apache.org by ru...@apache.org on 2021/12/02 07:24:35 UTC

[superset] branch master updated: feat(legacy-preset-chart-nvd3): add richtooltip in nvd3 bar chart (#17615)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 72f3215  feat(legacy-preset-chart-nvd3): add richtooltip in nvd3 bar chart (#17615)
72f3215 is described below

commit 72f3215ffc74ead33dba57196aeaf4e1db63fd6c
Author: Stephen Liu <75...@qq.com>
AuthorDate: Thu Dec 2 15:23:31 2021 +0800

    feat(legacy-preset-chart-nvd3): add richtooltip in nvd3 bar chart (#17615)
    
    * feat(legacy-preset-chart-nvd3): add richtooltip in nvd3 bar chart
    
    * add richtooltip in nvd3 bar chart
---
 .../plugins/legacy-preset-chart-nvd3/src/DistBar/controlPanel.ts  | 2 ++
 superset-frontend/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js | 8 ++++++--
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/DistBar/controlPanel.ts b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/DistBar/controlPanel.ts
index d0f83dd..b1459dd 100644
--- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/DistBar/controlPanel.ts
+++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/DistBar/controlPanel.ts
@@ -35,6 +35,7 @@ import {
   yAxisLabel,
   yAxisShowMinmax,
   yAxisBounds,
+  richTooltip,
 } from '../NVD3Controls';
 
 const config: ControlPanelConfig = {
@@ -81,6 +82,7 @@ const config: ControlPanelConfig = {
         ['color_scheme'],
         [showLegend],
         [showBarValue],
+        [richTooltip],
         [barStacked],
         [
           {
diff --git a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js
index 66bf932..7f3d4d0 100644
--- a/superset-frontend/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js
+++ b/superset-frontend/plugins/legacy-preset-chart-nvd3/src/NVD3Vis.js
@@ -673,9 +673,9 @@ function nvd3Vis(element, props) {
       chart.color(d => d.color || colorFn(cleanColorInput(d[colorKey])));
     }
 
-    if (isVizTypes(['line', 'area']) && useRichTooltip) {
+    if (isVizTypes(['line', 'area', 'bar', 'dist_bar']) && useRichTooltip) {
       chart.useInteractiveGuideline(true);
-      if (vizType === 'line') {
+      if (vizType === 'line' || vizType === 'bar') {
         chart.interactiveLayer.tooltip.contentGenerator(d =>
           generateRichLineTooltipContent(
             d,
@@ -683,6 +683,10 @@ function nvd3Vis(element, props) {
             yAxisFormatter,
           ),
         );
+      } else if (vizType === 'dist_bar') {
+        chart.interactiveLayer.tooltip.contentGenerator(d =>
+          generateCompareTooltipContent(d, yAxisFormatter),
+        );
       } else {
         // area chart
         chart.interactiveLayer.tooltip.contentGenerator(d =>