jivanf / larapex-charts
Package to provide easy api to build apex charts on Laravel
0.0.12
2024-11-11 20:43 UTC
Requires
- php: ^8.1|^8.2
- ext-json: *
- illuminate/support: ^8.0|^9.0|^10.0
Requires (Dev)
- nunomaduro/collision: ^7.5
- orchestra/testbench: ^6.0|^7.0|^8.0
- phpunit/phpunit: ^9.0|^10.0
- dev-master
- 0.0.12
- 0.0.10
- 0.0.9
- 0.0.8
- 0.0.7
- 0.0.6
- 0.0.5
- 0.0.4
- 0.0.3
- 0.0.2
- 0.0.1
- 0.0.0
- dev-develop
- dev-add-callback-handling
- dev-add-markers
- dev-apex-charts-version
- dev-update-to-8.1
- dev-use-blade-stack
- dev-set-dataset-type
- dev-support-multiple-stroke-widths
- dev-remove-php-7.4
- dev-add-setter-defaults
- dev-decode-json-in-getters
- dev-add-array-options-builder
- dev-improve-has-options-trait
- dev-fix-font-family-option
- dev-use-json-blade-directive
This package is auto-updated.
Last update: 2025-01-11 20:58:12 UTC
README
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, Horizantal Bar, Heatmap, pie, donut and Radialbar.
More examples
Check the documentation on: Larapex Chart Docs
Contributing
The author Ariel Mejia Dev.
License
Support the project
Hey 👋 thanks for considering making a donation, with these donations I can continue working to contribute to opensource projects.
To do for version 4
- Add blade directive
@apexchartscdn
- Add blade directive
@script($chart)
- Add a command to generate a blade component with the boilerplate directives just to include it on any blade file.
- Add a command to generate a vue component with all the boilerplate to just pass a
chart
prop and include the component on any vue component.