Server-side Chart.js rendering with Cloudflare Workers
composer require giobi/quickchart-laravel
<?php
use GiobiQuickChartFacadesChart;
Chart::bar([10, 20, 30, 25])
->labels(['Q1', 'Q2', 'Q3', 'Q4'])
->title('Quarterly Sales')
->render();
<?php
Chart::line([5, 10, 15, 10, 20, 25, 30])
->labels(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'])
->title('Weekly Traffic')
->render();
<?php
Chart::pie([30, 50, 20])
->labels(['Product A', 'Product B', 'Product C'])
->title('Market Share')
->size(500, 500)
->render();
<?php
Chart::bar([100, 150, 120, 200, 180])
->labels(['Jan', 'Feb', 'Mar', 'Apr', 'May'])
->title('Revenue (Blue)')
->backgroundColor('rgba(54, 162, 235, 0.8)')
->borderColor('rgba(54, 162, 235, 1)')
->render();
<?php
Chart::bar([50, 80, 60, 90, 70])
->labels(['Week 1', 'Week 2', 'Week 3', 'Week 4', 'Week 5'])
->title('Growth (Green)')
->backgroundColor('rgba(75, 192, 192, 0.8)')
->borderColor('rgba(75, 192, 192, 1)')
->render();
<?php
Chart::line([30, 45, 35, 50, 40, 55, 48])
->labels(['Day 1', 'Day 2', 'Day 3', 'Day 4', 'Day 5', 'Day 6', 'Day 7'])
->title('Alerts (Red)')
->backgroundColor('rgba(255, 99, 132, 0.8)')
->borderColor('rgba(255, 99, 132, 1)')
->render();
Chart::bar([12, 19, 15, 25, 22])
->labels(['A','B','C','D','E'])
->render();
Chart::line([12, 19, 15, 25, 22])
->labels(['A','B','C','D','E'])
->render();
Chart::pie([30, 50, 20])
->labels(['Red','Blue','Yellow'])
->size(350, 350)
->render();
Chart::doughnut([40, 60])
->labels(['Done','Todo'])
->size(350, 350)
->render();
Chart::radar([80, 90, 70, 85, 75])
->labels(['Speed','Quality','Cost',
'Reliability','Support'])
->size(400, 400)
->render();
->size(400, 300)
->size(600, 400)
->size(800, 500)
<?php
namespace AppHttpControllers;
use GiobiQuickChartFacadesChart;
use IlluminateViewView;
class DashboardController extends Controller
{
public function index(): View
{
// Sales chart
$salesChart = Chart::bar([100, 150, 120, 200])
->labels(['Q1', 'Q2', 'Q3', 'Q4'])
->title('Quarterly Sales')
->backgroundColor('rgba(54, 162, 235, 0.8)')
->size(800, 400);
// Traffic chart
$trafficChart = Chart::line([1200, 1900, 3000, 5000])
->labels(['Week 1', 'Week 2', 'Week 3', 'Week 4'])
->title('Weekly Traffic')
->backgroundColor('rgba(75, 192, 192, 0.8)');
// Market share
$marketChart = Chart::pie([30, 50, 20])
->labels(['Product A', 'Product B', 'Product C'])
->title('Market Share')
->size(500, 500);
return view('dashboard', compact(
'salesChart',
'trafficChart',
'marketChart'
));
}
}
{{-- resources/views/dashboard.blade.php --}}
@extends('layouts.app')
@section('content')
Dashboard
Sales Overview
{!! $salesChart->render(['class' => 'img-fluid']) !!}
Market Share
{!! $marketChart->render() !!}
Traffic Growth
{!! $trafficChart->render(['class' => 'img-fluid', 'loading' => 'lazy']) !!}
@endsection
| Color | Preview | RGBA (Background) | RGBA (Border) |
|---|---|---|---|
| Blue | rgba(54, 162, 235, 0.8) |
rgba(54, 162, 235, 1) |
|
| Green | rgba(75, 192, 192, 0.8) |
rgba(75, 192, 192, 1) |
|
| Red | rgba(255, 99, 132, 0.8) |
rgba(255, 99, 132, 1) |
|
| Yellow | rgba(255, 206, 86, 0.8) |
rgba(255, 206, 86, 1) |
|
| Purple | rgba(153, 102, 255, 0.8) |
rgba(153, 102, 255, 1) |
|
| Orange | rgba(255, 159, 64, 0.8) |
rgba(255, 159, 64, 1) |
Chart::bar(array $data)Chart::line(array $data)Chart::pie(array $data)Chart::doughnut(array $data)Chart::radar(array $data)->labels(array $labels)->title(string $title)->size(int $width, int $height)->width(int $width)->height(int $height)->backgroundColor(string $color)->borderColor(string $color)->render(array $attributes = [])->toHtml()->url()->__toString()Cache Hit
Cache Miss
Cache TTL