0

Am using angular2 nvd3 charts. I have an issue with scaling on y-axis. I have y values like 623.10, 631.60, 629.10, 633.50, 631.80, 623.40 etc.,

and in options am doing something like

yAxis: {
    tickFormat: function(d) {
      return d3.format('f')(d);
    }
  }

which is showing in the graph like 623, 624, 625, 626 etc... I want my y-axis values to be shown in chart like 620, 630, 640... Am new to this. Can somebody tell me how to achieve this?

Esco
  • 387
  • 2
  • 3
  • 16

1 Answers1

0

use toFixed(0) to format your data:

function format(d) {
  return d.toFixed(0);
}

console.log(format(631.60));
// expected output: "631"