Chartjs-Draw data in graphics generated by Chart JS

1👍

After reading a bit about Laravel documentation and Javascript, I found a solution to draw the data on the graph.

In the script I structured the foreach based on the documentation on loops at https://laravel.com/docs/5.7/blade#if-statements.

<script>        
  //console.log(datacount);

  // Bar chart
  new Chart(document.getElementById("bar-chart"), {
      type: 'bar',
      data: {
      labels: [
          @foreach($datacount as $dt)
              "{{ $dt->tpname }}",
          @endforeach
      ],
      datasets: [
          {
          label: "Cantidad generada",
          backgroundColor: ["#3e95cd", "#8e5ea2","#3cba9f","#e8c3b9","#c45850","#ffc344","#ff8e17", "#ff4cd8","#ffea4c","#b7ff4c"],
              data: [
                  @foreach($datacount as $dt)
                      {!! $dt->total !!},
                  @endforeach
              ],
           }
      ]
      },
      options: {
      legend: { display: false },
      title: {
          display: true,
          text: 'Ejes temáticos por cantidad de propuestas.'
      }
      }
    });
</script>

Also seeing some examples at: https://quickadminpanel.com/pages/reports-generator-module

enter image description here

0👍

You can put the data from your PHP script in your data fields with:

Leave a comment