fxcosta / laravel-chartjs

Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library
486 stars 112 forks source link

multiple draw chart in one page #13

Closed afshmini closed 7 years ago

afshmini commented 8 years ago

Hello friends I want to draw two chart in one page with this package but just one of them worked

my code is :

                      <?php
                      $data = array(
                              'ta1' => array($modAttendance),
                              'ta2' => array($modGrade),
                      );
                      ?>

                      {!! app()->chartbar->render("BarChart", $data) !!}
                      <?php
                      $data = array(
                              't1' => array(20,27),
                              't2' => array(25, 100),
                      );
                      ?>

                      {!! app()->chartline->render("LineChart", $data) !!}
zekaroz commented 7 years ago

If you check your Developer tools you should see an error there. Aparently the function that this component generates tries to place the Legened inside this div:

<div id="js-legend-bar" class="chart-legend"></div>

If you place this div for the first chart the second one should draw just fine. But this is not correct yet, since if you have 2 diferent Bar graphs the provider always tries to place the legend inside the div with the id of 'js-legend-bar'. And this way have only one legend for 2 or more graphs if they have the same type.

This should be easy to fix in this component.