javascriptcssd3.jscharc3.js

How to coustomise the Y-axis grid line css properties in c3js


I have created a line chart with time series data. I used custom X-axis grid lines and increased their spacing by editing their CSS. I would like to increase the spacing between the grid lines on the Yaxis. Here's what I did:

`// to increase the X grid line spacing
.c3-xgrid-line{
    stroke-dasharray: 10,5;
    }
// to increase the Y grig line spacing
.c3-ygrid-line {
    stroke-dasharray: 10,5;``
}`

The X grid line property was the only one I could change with the above

This is how the graph looks now


Solution

  • Custom grid lines end up with the class .c3-(x or y)grid-lines which is why it works for x

    If they're just standard i.e. set with grid: { y: { show: true }} then they're in a different group element and given the .c3(x or y)grid class

    Long story short: change .c3-ygrid-line to .c3-ygrid in your css