2016-11-17 75 views
0

我在角度nv3d中使用了有力图形。我想定制节点上的文本颜色以及修改工具提示。我也一直试图找出如何强制节点更稀疏。这是我的图表对象:如何在角度nvd3中为forceDirectedGraph自定义工具提示

chart: { 
     type: 'forceDirectedGraph', 
     height: 450, 
     color: function(d) { 
     return color(d.Name); 
     }, 
     tooltipContent: function (key) { 
     return '<h3>' + key + '</h3>'; 
     }, 
     margin: {top: 20, right: 20, bottom: 20, left: 20}, 
     nodeExtras: function(node) { 
     node && node 
      .append('text') 
      .attr('dx', 15) 
      .attr('dy', '.35em') 
      .text(function(d) { 
      return d.Name; 
      }) 
      .style('font-size', '25px'); 
     }, 
    }, 
    }; 

正如您所看到的,我尝试将tooltipContent属性添加到图表对象中无济于事。任何帮助将不胜感激,谢谢!

回答

0

要自定义工具提示执行以下操作

chart: { 
     type: 'forceDirectedGraph', 
     ... /* All properties */ 
     height : 400, 
     tooltip : { 
      contentGenerator : function (obj) { return "<div> **custom formating** </div>"}    
     } 
    }