Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

173
Views
I want to add a label (annotation) in my bar chart

Controller

$data = DB::table('buses')
    ->join('bustypes', 'bustypes.id', '=', 'buses.bustype_id')
    ->select(DB::raw('bustypes.name as bustype'), DB::raw('COUNT(buses.id) as count'))
    ->groupBy('bustypes.id')
    ->get();

$array[] = ['Bustype', 'Number'];

foreach ($data as $key => $value) {
    $array[++$key] = [$value->bustype, $value->count];
}

Blade

<div class="panel-body" align="center">
    <div id="pie_chart" style="width:450px; height:450px;">
    </div>
</div>

<script type="text/javascript">
    var analytics = <?php echo $company; ?>

    google.charts.load('current', {'packages': ['corechart']});

    google.charts.setOnLoadCallback(drawChart);

    function drawChart() {
        var data = google.visualization.arrayToDataTable(analytics);
        var view = new google.visualization.DataView(data);
        var options = {
            title: "Car Own List"
        };

        view.setColumns([0, {
            calc: "stringify",
            sourceColumn: 1,
            type: "string",
            role: "annotation"
        }, 1]);

        var chart = new google.visualization.PieChart(
            document.getElementById('pie_chart')
        );
        chart.draw(data, options);
    }
</script>

enter image description here

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!