簡體   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