nvd3中的cumulativeLineChart上的自定义工具提示 [英] custom tooltip on cumulativeLineChart in nvd3

查看:214
本文介绍了nvd3中的cumulativeLineChart上的自定义工具提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我在累积线性图上的线上徘徊时,我在某些y时间获得工具提示消息x值。

When I hover on the lines on the cumulative line chart I get a tooltip message x value at some y time. I want to edit this message and add more content.

因为在我的values数组中,我有json包含{X:x,Y:y,Z:z,Dt:日期}我希望在日期显示一个自定义消息列出X / Y / Z。

Since in my values array I have json containing {X:x, Y:y, Z:z, Dt:date} I wish to show a custom message listing X/Y/Z at date.

推荐答案

我使用nvd3 veraion 1.1 .15b。

I'm using nvd3 veraion 1.1.15b.

调用 .tooltip()没有为我工作,但调用 .tooltipContent(),如下面的代码所示:

Calling .tooltip() didn't work for me, but calling .tooltipContent() did, as in the following code:

        var chart = nv.models.pieChart()
            .x(function (d) { return d.file; })
            .y(function (d) { return d.size; })
            .tooltipContent(function (key, y, e, graph) {
                return '<h3>' + key + '</h3>' +
                    '<p>' + e.value.toSizeFmt() + '</p>';
            })

http://stackoverflow.com/users/2718/andrei\">Andrei 指出, e 参数提供对原始值的访问,因此您可以格式化而不是使用已经格式化的文本的 y 。希望这有助于!

As Andrei points out above, the e parameter provides access to the raw values so you can format them, rather than working with y which is already formatted text. Hope this helps!

这篇关于nvd3中的cumulativeLineChart上的自定义工具提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆