Add a value from a json file in the tooltip with NVD3

122 views Asked by At

I'm quite new with the NVD3 library. I have a linechart with a simple tooltip. I activated the footer and I would like to load in the footer a different value for every couple (x,y).

What is the best solution in NVD3?

I was trying to insert in the json file another attribute with the z value.

Json:

[
  {
    "key": "Marketable",
    "color": "#A09FA2",
    "area" : "false",
    "values": [
      {
        "x": 1,
        "y": 5220593,
        "z": 5220593
      },
      {
        "x": 2,
        "y": 5220593,
        "z": 5220593
      },
...

And in the library I would like to use the z value, is it possible ?

Below here the code:

       var contentGenerator = function(d) {
            if (content != null) {
                return content;
            }

            if (d == null) {
                return '';
            }

            var table = d3.select(document.createElement("table"));
            var theadEnter = table.selectAll("thead")
                .data([d])
                .enter().append("thead");
            theadEnter.append("tr")
                .append("td")
                .attr("colspan",3)
                .append("strong")
                .classed("x-value",true)
                .html(headerFormatter("Round "+d.value+", ratio "+{***here I would like to take the z value***}.value+"%"));
0

There are 0 answers