nvd3 piechart.js - How to edit the tooltip?

前端 未结 9 1611
别那么骄傲
别那么骄傲 2020-11-27 06:09

I\'m using nvd3\'s piechart.js component to generate a piechart on my site. The provided .js file includes several var\'s, as follows:

var margin = {top: 30,         


        
相关标签:
9条回答
  • 2020-11-27 06:49

    Just override in this way it will work definitely

    function tooltipContent(key, y, e, graph) {
                return '<h3>' + key + '</h3>' +'<p>' + y + '</p>' ;
            }
    

    Or

    tooltipContent(function(key, y, e, graph) { return 'Some String' })
    
    0 讨论(0)
  • 2020-11-27 06:52

    Customized tooltip can not exist with "useInteractiveGuideline".

    0 讨论(0)
  • 2020-11-27 06:54

    If you happen to use the Angular NVD3 wrapper, the way to set the custom message is through chart options, simply:

    $scope.options = {
      chart: {
      ...
      tooltip: {
          contentGenerator: function(d) {
              return d.series[0].key + ' ' + d.series[0].value;
          }
      },
      ...
      }
    };
    
    0 讨论(0)
提交回复
热议问题