airblade / chartjs-ror

[Not supported - see #53] Simplifies using Chart.js in Rails
MIT License
184 stars 57 forks source link

Multiple chart in one page? #15

Closed cahitceren closed 9 years ago

cahitceren commented 9 years ago

I want to show multiple chart in one page, for example using this:

<%= chartjs_line_chart @data, @options %> <%= chartjs_pie_chart @datastaffcount %>

but when its rendered it only show first chart and the other is blank.

Did you ever see a problem like this?

airblade commented 9 years ago

That's odd. I have three charts on one page in one of my projects.

Does it work if you specify an explicit id for each chart?

What error do you see in the browser's javascript console?

I'll be able to look into this more when I get back from holiday.

cahitceren commented 9 years ago

thanks airblade for your help.

If i add two chart in same div tag it ok. its rendered. But when I add two chart under different divs, it isnt rendered.

Then i apply you suggestion and i specify an explicit id for each chart and ta taa.

Now two charts are rendered under different divs without any problem.

Again thanks for your help airblade.

airblade commented 9 years ago

I'm glad it works when you specify an explicit id for each chart...but it should work without you having to do that. I have a page in my app with three charts and it renders without my having to specify the ids.

What does the HTML generated look like when you don't specify ids?

airblade commented 9 years ago

I can't reproduce this and it's gone quiet, so I'm closing this. I'm happy to re-open it if you're still having problems.