David542
David542

Reputation: 110382

How to format the values of c3.js y-axis?

Is there a way in c3.js to format the axis to give it 'nice' values. Such as the X-axis starts at 0 and goes by 500 increments to the max value of 2000?

enter image description here

Upvotes: 0

Views: 3718

Answers (2)

heksemann
heksemann

Reputation: 446

let categories = ['none', 'small', 'medium', 'large', 'huge'];

....

tick: {
   values: [0, 500, 1000, 1500, 2000],
   format: function (d) { return categories[d/500]; }
}

Upvotes: 0

potatopeelings
potatopeelings

Reputation: 41075

You could use axis.x.tick.values (http://c3js.org/reference.html#axis-x-tick-values)

...
axis: {
  x: {
    tick: {
      values: [0, 500, 1500, 2000]
    }
  }
}
...

Upvotes: 2

Related Questions