Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Y axis label not displaying large numbers - Multi-Bar Chart

Tags:

d3.js

nvd3.js

In my Multi-Bar Chart, I need to show larger numbers on the Y axis labels. Currently it's not showing more than seven characters:

enter image description here

How can I do it?

like image 659
Wellington Zanelli Avatar asked Mar 23 '23 10:03

Wellington Zanelli


1 Answers

Set chart.margin().left = 120 This will give you plenty of space to display 10,000,000.

nv.addGraph(function() {
  var chart = nv.models.discreteBarChart()
      .x(function(d) { return d.label })
      .y(function(d) { return d.value })
      .staggerLabels(true)
      .tooltips(false)
      .showValues(true)

  chart.forceY([10000000]);
  chart.margin().left = 120
  d3.select('#chart svg')
      .datum(data)
    .transition().duration(500)
      .call(chart);


  nv.utils.windowResize(chart.update);

  return chart;
});

JSFiddle: http://jsfiddle.net/marrok/Ev3UN/1/

like image 198
WolfgangCodes Avatar answered Apr 28 '23 13:04

WolfgangCodes