score:3

Based off of this example:

Rails Controller should render JSON data like this:

render json: { 'data1' => [30, 200, 100, 400, 150, 250] }

Javascript should look like this:

<script type="text/javascript"> var chart = c3.generate({ bindto: '#yourchartid', data: { url: '/controller/action.json', mimeType: 'json' }, }); </script>

I was missing the mimeType in the javascript. Hope this is helpful to someone starting out with C3.js and Rails!


Related Query

More Query from same tag