我正在为我的项目使用NVD3库,我编写了以下代码.
var chart = nv.models.lineChart()
.useInteractiveGuideline(true)
.margin({top: 50, right: 50, bottom: 50, left: 50})
.tooltipContent(function (key, y, e, graph) {
console.log("helo");
return "hello";
});
Run Code Online (Sandbox Code Playgroud)
预期输出应该是鼠标悬停显示问候.但我不明白,相反,我得到默认的工具提示.
请让我知道我正在做的错误.
Pim*_*Pim 13
从版本1.8.1开始,现在可以使用具有交互式指南的自定义内容(https://github.com/novus/nvd3/tree/v1.8.1-alpha).
chart.interactiveLayer.tooltip.contentGenerator(function(data) {
return 'this is my custom content';
});
Run Code Online (Sandbox Code Playgroud)
你能为它创建一个 fiddle 或 plunkr 吗?下面是我们项目代码的实现,它返回一个 html 元素并且运行良好:
.tooltipContent(function (key, x, y, e) {
if (e.value >= 0) {
return '<h3>' + key + '</h3>' +
'<p>' + y + ' at ' + x + '</p>';
} else {
return '';
}
});
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
9933 次 |
最近记录: |