簡體   English   中英

在NVD3.js中翻譯鼠標懸停文字

[英]Translating mouse-over text in NVD3.js

我正在使用一些堆疊的條形圖和出色的nvd3庫(這些文件: http ://nvd3.org/examples/multiBar.html)

我有一個問題。 我想保持鼠標懸停工具提示不變,但是我需要將單詞“ on”翻譯成另一種語言。 我找不到有關如何執行此操作的任何文檔,而且似乎也無法在源代碼中找到它。

有人知道嗎?

在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>'
});

請參見此示例: 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>'
});

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM