Search code examples
javascriptnvd3.jsangular-nvd3angularjs-nvd3-directives

Line Chart - Y Axis value not showing in tooltip


Hi I am using Angular NVD3 line chart. I am getting decimal value for Y Axis. In tickFormat of Y axis, I am changing it to integer format.

Now, the Y axis value in the tooltip not showing up. if the value is integer then only it's showing up.

I tried to use tooltip valueFormatter like below in my chart option -

tooltip: {
            valueFormatter: function (d, i){
                return d3.format('.02f')(val);
            }
        }

but it's not getting called. Any idea how to show value in tooltip if the tickFormat is different than value.


Solution

  • I fixed my issue by using below option..

    interactiveLayer: {
                tooltip: {
                    valueFormatter:  function (d, i){
                      return d3.format('.02f')(val);
                    }
                }
            }
    

    I am not sure why there are two tooltip options. one inside interactiveLayer and another outside. it's pretty confusing. Anyways, it worked for me.