繁体   English   中英

如何在NVD3离散条形图的工具提示中添加一些文本?

[英]How can I add some text to the tooltip of NVD3 discreteBarChart?

我试图将一些文本添加到我的nvd3离散BarChart的工具提示中,但是它不起作用,我也不知道为什么。 当我超过工具提示时,它总是显示以下内容: [object Object] undefined cal 你有个主意吗?

historicalBarChart = [
            {
                key: "Notenvergabe",
                values: [
                    {
                        "label" : "1" ,
                        "value" : <?php echo $sel_an_datas["note_1"]; ?>
                    } ,
                    {
                        "label" : "1,3" ,
                        "value" : <?php echo $sel_an_datas["note_2"]; ?>
                    }
                ]
            }
        ];



        nv.addGraph(function() {
            var chart = nv.models.discreteBarChart()
                .x(function(d) { return d.label })
                .y(function(d) { return d.value })
                .staggerLabels(false)
                .showValues(true)
                .duration(250);

                chart.height(250)
                chart.tooltipContent(function(key, y, e, graph) {
                    var x = String(key);
                    var y =  String(y);
                    tooltip_str = '<center><b>'+x+'</b></center>' + y;
                    return tooltip_str;
                });


            d3.select('#chart1 svg')
                .datum(historicalBarChart)
                .call(chart);

            nv.utils.windowResize(chart.update);
            return chart;
        });

这显然是这样做的方法:

tooltipContent(function(key, y, e, graph) { return 'Some String' })

参考

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM