arielmejiadev/larapex-charts

Package to provide easy api to build apex charts on Laravel

8.1.0 2024-02-08 16:17 UTC

README

MadeWithLaravel.com shield

Latest Stable Version

Total Downloads

GitHub Actions

License

A Laravel wrapper for apex charts library Check the documentation on: Larapex Chart Docs.

Installation

Use composer.

composer require arielmejiadev/larapex-charts

Usage

Basic example

In your controller add:

$chart = (new LarapexChart)->setTitle('Posts')
                   ->setDataset([150, 120])
                   ->setLabels(['Published', 'No Published']);

Remember to import the Facade to your controller with

use ArielMejiaDev\LarapexCharts\Facades\LarapexChart;

Or importing the LarapexChart class:

use ArielMejiaDev\LarapexCharts\LarapexChart;

Then in your view (Blade file) add:

 <!doctype html>
 <html lang="en">
 <head>
     <meta charset="UTF-8">
     <meta name="viewport"
           content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
     <meta http-equiv="X-UA-Compatible" content="ie=edge">
     <title>Chart Sample</title>
 </head>
 <body>
 
     {!! $chart->container() !!}
 
     <script src="{{ $chart->cdn() }}"></script>
 
     {{ $chart->script() }}
 </body>
 </html>

More complex example

$chart = (new LarapexChart)->setType('area')
        ->setTitle('Total Users Monthly')
        ->setSubtitle('From January to March')
        ->setXAxis([
            'Jan', 'Feb', 'Mar'
        ])
        ->setDataset([
            [
                'name'  =>  'Active Users',
                'data'  =>  [250, 700, 1200]
            ]
        ]);

You can create a variety of charts including: Line, Area, Bar, Horizontal Bar, Heatmap, pie, donut and Radialbar.

More examples

Check the documentation on: Larapex Chart Docs

Contributing

The author Ariel Mejia Dev.

License

MIT

Support the project

Hey 👋 thanks for considering making a donation, with these donations I can continue working to contribute to opensource projects.

68747470733a2f2f696d672e6275796d6561636f666665652e636f6d2f627574746f6e2d6170692f3f746578743d427579206d65206120636f6666656526656d6f6a693d26736c75673d617269656c6d656a696164657626627574746f6e5f636f6c6f75723d46463546354626666f6e745f636f6c6f75723d66666666666626666f6e745f66616d696c793d436f6f6b6965266f75746c696e655f636f6c6f75723d30303030303026636f666665655f636f6c6f75723d464644443030

Roadmap for future versions

  • Add blade directive @apexchartscdn
  • Add blade directive @script($chart)
  • Add a chain options setter for charts
  • Update Github Actions to run tests
  • Update the package in general for more efficient & modern practices (spatie skeleton package)
  • Add ReactJS + Inertia Support
  • Add More complex charts
  • Add More complex boilerplate code using Laravel/Prompts
  • Add more complex boilerplate code examples using Laravel Trends Package