0

我正在使用一些带有优秀 nvd3 库的堆叠条形图(这些:http ://nvd3.org/examples/multiBar.html )

我有一个问题。我想要鼠标悬停的工具提示,但我需要将“on”这个词翻译成另一种语言。我找不到任何有关如何执行此操作的文档,而且我似乎无法在源代码中找到它。

有人有线索吗?

4

1 回答 1

1

在 1.7.1 及以下版本(我假设您正在使用)中,您可以使用chart.tooltipContent().

// If you want to change the tooltip format you could edit this function
chart.tooltipContent(function (key, x, y, e, graph) {
    return '<h3>' + key + '</h3>' +
        '<p>' +  y + ' en ' + x + '</p>'
});

有关示例,请参见此 plunk:http ://plnkr.co/edit/YxZKDBqVWhtxryUSMwjk?p=preview

如果你使用 1.8.1,同样可以这样完成:

// If you want to change the tooltip format you could edit this function
chart.tooltip.contentGenerator(function (d) {
    return '<h3>' + d.data.key + '</h3>' +
        '<p>' +  d.data.display.y + ' en ' + new Date(d.data.x).toLocaleDateString() + '</p>'
});

如本plunk所示:http ://plnkr.co/edit/ZYsjygDJkHSit50Rh3sZ?p=preview

于 2015-08-11T21:58:53.887 回答