Make chart responsive

1,231 views
Skip to first unread message

jo...@connectsb.nl

unread,
Dec 19, 2014, 4:26:42 AM12/19/14
to c3...@googlegroups.com
Hey !

I'm having issues with the charts created by C3 not being responsive. I've tried setting the width to 100% but then I don't even see the graph anymore, then I though to use the onresized function which is available but I can't find a way to dynamically set the width of the graph.

I would like it if it's possible to calculate the width again for the graph, because I don't know the exact width the graph should be at that moment.

Does anyone have an idea ?

diego...@funkroom.net

unread,
Dec 28, 2014, 9:09:50 AM12/28/14
to c3...@googlegroups.com, jo...@connectsb.nl
The reference says:

"If this option is not specified, the height of the chart will be calculated by the size of the parent element it's appended to."

I would solve it by making the div, to which the chart is binded, responsive (with media queries)...? And not specifiy the width/height of the chart itself.

jo...@connectsb.nl

unread,
Dec 29, 2014, 5:24:42 AM12/29/14
to c3...@googlegroups.com, jo...@connectsb.nl, diego...@funkroom.net
Op zondag 28 december 2014 15:09:50 UTC+1 schreef diego...@funkroom.net:
> The reference says:
>
> "If this option is not specified, the height of the chart will be calculated by the size of the parent element it's appended to."
>
> I would solve it by making the div, to which the chart is binded, responsive (with media queries)...? And not specifiy the width/height of the chart itself.

I've done it exactly as you said. I've used bootstrap, a div with class col-md-5 and then another div with width 100%. That last div contains the graph and that solved my issue.

shanmug...@gmail.com

unread,
Feb 5, 2019, 12:17:37 AM2/5/19
to c3js
I am also using C3 Chart Text is not responsive

inex jimenez

unread,
Nov 9, 2021, 4:22:08 AM11/9/21
to c3js
Same issue, chart width apparently can only be a fixed number, not a percentaje or ratio. So if a fixed number defined, not responsive. And it doesn't take parent div width at all
Reply all
Reply to author
Forward
0 new messages