C3: Axis label formatting

Created on 31 Jan 2014  路  8Comments  路  Source: c3js/c3

Hello,

I have a couple questions about formatting the axes.

For X axis, is there a way to display arbitrary category tick labels? For instance, I would like to display text instead of number for categories (like 'America' 'Europe' 'Afria' etc. rather than 1, 2, 3.

For Y axis, how can I format the ticks as currency, for example?

I like the simplicity of the library and the output. Thanks for writing it!

Most helpful comment

Would be nice to have the font size as a property for axes objects.

All 8 comments

Hello,

For X axis, you can use axis.x.categories option to change text for each category.
I updated the sample, so please check this: http://c3js.org/samples/categorized.html

For Y axis, you can use axis.y.tick.format option to format value displayed as tick text.
I added a sample for this option, so please check this: http://c3js.org/samples/axes_y_tick_format.html

Thank you for using this library :)

Great, thanks!

One more question: how do I increase font-size of the labels?

@ntquyen Please use c3-text class to specify css style.

I modified the font of my x-axis with this css tag:

.c3 svg g g.c3-axis.c3-axis-x {
font: 20px sans-serif;
}

if i only want to increase font size of bar chart? what would be the class?

Would be nice to have the font size as a property for axes objects.

I modified the font of my x-axis with this css tag:

.c3 svg g g.c3-axis.c3-axis-x {
font: 20px sans-serif;
}

This modifies the tick fonts too :(

Was this page helpful?
0 / 5 - 0 ratings