0

I tried to add some text to my tooltip of my nvd3 discreteBarChart, but it doesnt work and i dont know why. It shows me always when I go above the tooltip the following: [object Object] undefined cal . Do you have a idea for me?

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;
        });
johny
  • 159
  • 1
  • 13
  • possible duplicate of [nvd3 piechart.js - How to edit the tooltip?](http://stackoverflow.com/questions/12416508/nvd3-piechart-js-how-to-edit-the-tooltip) – shabeer90 Jul 29 '15 at 08:33
  • nothing of it works...im rly frustrated now :/ i dont know where the problem is... – johny Jul 29 '15 at 11:13

1 Answers1

0

this is apparently the way to do it:

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

Reference

Community
  • 1
  • 1
Rachel Gallen
  • 27,943
  • 21
  • 72
  • 81
  • thank you, but i have the same problem. "Some string" will be displayed, but when i want to display "key" or "y" then i get the `[object Object]` again :/ – johny Jul 29 '15 at 00:51
  • please refer to the reference question. also key, y e a nd graph are parameters - what exactly is your syntax? – Rachel Gallen Jul 29 '15 at 03:29
  • sry, but i am rly a beginner in this topic. :/ do you mean with syntax maybe `d.label` and `d.value` ? – johny Jul 29 '15 at 09:59