QuickChart Laravel Package

Server-side Chart.js rendering with Cloudflare Workers

10-day cache ~30ms cache hit Global edge

Installation

composer require giobi/quickchart-laravel

Basic Examples

Bar Chart - Sales Report

Bar Chart
<?php
use GiobiQuickChartFacadesChart;

Chart::bar([10, 20, 30, 25])
    ->labels(['Q1', 'Q2', 'Q3', 'Q4'])
    ->title('Quarterly Sales')
    ->render();

Line Chart - Traffic Growth

Line Chart
<?php
Chart::line([5, 10, 15, 10, 20, 25, 30])
    ->labels(['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'])
    ->title('Weekly Traffic')
    ->render();

Pie Chart - Market Share

Pie Chart
<?php
Chart::pie([30, 50, 20])
    ->labels(['Product A', 'Product B', 'Product C'])
    ->title('Market Share')
    ->size(500, 500)
    ->render();

Custom Colors & Styling

Blue Theme

Blue Chart
<?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();

Green Theme

Green Chart
<?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();

Red Theme

Red Chart
<?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();

All Chart Types

Bar
Bar
Chart::bar([12, 19, 15, 25, 22])
    ->labels(['A','B','C','D','E'])
    ->render();
Line
Line
Chart::line([12, 19, 15, 25, 22])
    ->labels(['A','B','C','D','E'])
    ->render();
Pie
Pie
Chart::pie([30, 50, 20])
    ->labels(['Red','Blue','Yellow'])
    ->size(350, 350)
    ->render();
Doughnut
Doughnut
Chart::doughnut([40, 60])
    ->labels(['Done','Todo'])
    ->size(350, 350)
    ->render();
Radar
Radar
Chart::radar([80, 90, 70, 85, 75])
    ->labels(['Speed','Quality','Cost',
              'Reliability','Support'])
    ->size(400, 400)
    ->render();

Custom Sizes

Small (400x300)
Small
->size(400, 300)
Medium (600x400)
Medium
->size(600, 400)
Large (800x500)
Large
->size(800, 500)

Laravel Integration Examples

Controller Example
<?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'
        ));
    }
}
Blade Template Example
{{-- 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

Common Color Palettes

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)

Available Methods

Static Constructors
  • Chart::bar(array $data)
  • Chart::line(array $data)
  • Chart::pie(array $data)
  • Chart::doughnut(array $data)
  • Chart::radar(array $data)
Configuration Methods
  • ->labels(array $labels)
  • ->title(string $title)
  • ->size(int $width, int $height)
  • ->width(int $width)
  • ->height(int $height)
  • ->backgroundColor(string $color)
  • ->borderColor(string $color)
Output Methods
  • ->render(array $attributes = [])
  • ->toHtml()
  • ->url()
  • ->__toString()

Performance

~30ms

Cache Hit

~450ms

Cache Miss

10 days

Cache TTL

Cache Strategy: Charts are cached globally via Cloudflare KV. Same configuration = same cached image served from 300+ edge locations worldwide.