2016-01-21 75 views
1

我不能讓這一個多梳圖表如何將自定義工具提示添加到angular-nvd3多條形圖表?

$scope.countsChart.options = { 
    deepWatchData: false, 
    chart: { 
    type: 'multiBarChart', 
    margin: { 
     top: 20, 
     right: 20, 
     bottom: 45, 
     left: 45 
    }, 
    clipEdge: true, 
    duration: 500, 
    stacked: true, 
    showControls: false, 
    xAxis: { 
     showMaxMin: false, 
     tickFormat: d => $scope.countsChart.selectedGranularity().tickFormat(d) 
    }, 
    yAxis: { 
     axisLabelDistance: -20, 
     tickFormat: d => parseInt(d).toLocaleString() 
    }, 
    useInteractiveGuideline: false, 
    interactive: true, 
    tooltips: true, 
    tooltipContent: (key, x, y, e, graph) => '<h1>Test</h1>' 
    } 
}; 

而是我的自定義工具提示的工作,默認的提示仍然顯示。

image

人有成功製作一個自定義的工具提示?

回答

6

你要使用chart.tooltip.contentGenerator方法(ES6相當於我在this plunker嘲笑):

$scope.countsChart.options = { 
    chart: { 
    ..., 
    tooltip: { 
     contentGenerator: function (key, x, y, e, graph) { 
     return '<h1>Test</h1>'; 
     } 
    // or if you're writing ES6: 
    // contentGenerator: (key, x, y, e, graph) => '<h1>Test</h1>'; 
    } 
    } 
} 
+0

輝煌!謝謝! –

+0

注意:您可能需要將此放在'chart.interactiveLayer.tooltip'而不是'chart.tooltip'中,具體取決於圖表的其他選項。 –

+0

您能否詳細說明「取決於其他選項」的含義? –

相關問題