Charts
Server-side data builder for charts.
This package can work independently of the Enso ecosystem.
The front end implementation that utilizes this api is present in the enso-ui/charts package.
For live examples and demos, you may visit laravel-enso.com
click on the photo to view a short demo in compatible browsers
Installation
Comes pre-installed in Enso.
To install outside of Enso:
composer require laravel-enso/charts
publish the config with
php artisan vendor:publish --tag=charts-config
and customize as neededinstall the api implementation for the front end:
yarn add @enso-ui/charts
Features
- it supports Bar, Bubble, Line, Pie, Doughnut, Polar Area and Radar chart types
- it creates properly formatted data structures, specific for each supported type of chart from a given data-set
- the used colors are configurable through the publishable config file
- can translate labels, legends and data series
- can download the graphical representation of the graph, as a
PNG
file
Usage
- In your controller, add a method that will return the data for each chart:
public function line()
{
return (new LineChart())
->title('Income')
->labels(['January', 'February', 'March', 'April', 'May', 'June', 'July'])
->datasets([
'Sales' => [65, 59, 80, 81, 26, 25, 10],
'Revenue' => [15, 29, 60, 31, 56, 65, 44],
])->fill()
->get();
}
create a route for each chart dataset, add permissions if needed, etc.
add the front end components to your pages. For more information about the front end, see enso-ui/charts.
Configuration
The package's configuration file offers a few options for customization:
fillBackgroundOpacity
- number, the chart background's opacity, default is0.25
colors
- array, the list of colors used when drawing the various chart types
Note
The Chart builder will use the colors from app/config/enso/charts.php
(in that order) for the given data-sets.
Publishes
php artisan vendor:publish --tag=charts-config
- the configuration filephp artisan vendor:publish --tag=enso-config
- a common alias for when wanting to update the config, once a newer version is released, usually used with the--force
flag
Contributions
are welcome. Pull requests are great, but issues are good too.
License
This package is released under the MIT license.