Import latest app updates from streamline

An updated set of source files and initialization was provided by streamline to
address issues observed during initial testing. These files have been updated in
order to generate a new set of app images.
This commit is contained in:
2024-04-11 11:16:51 -07:00
parent cb4c6b4c1a
commit 4a89356390
10435 changed files with 107737 additions and 1220538 deletions
@@ -1,221 +0,0 @@
# laravel-chartjs - Chart.js v2 wrapper for Laravel 5.x
*No Longer Maintained*. This lib is basically a bridge to Chartjs so it is very likely that some problem or issue is better resolved in the Chartjs repository itself.
Simple package to facilitate and automate the use of charts in Laravel 5.x
using the [Chart.js](http://www.chartjs.org/) v2 library from Nick Downie.
# Setup:
```
composer require fx3costa/laravelchartjs
```
And add the Service Provider in your file config/app.php:
```php
Fx3costa\LaravelChartJs\Providers\ChartjsServiceProvider::class
```
Finally, for now, you must install and add to your layouts / templates the Chartjs library that can be easily
found for download at: http://www.chartjs.org. This setting will also be improved.
# Usage:
You can request to Service Container the service responsible for building the charts
and passing through fluent interface the chart settings.
```php
$service = app()->chartjs
->name()
->type()
->size()
->labels()
->datasets()
->options();
```
For now the builder needs the name of the chart, the type of chart that can be anything that is supported by chartjs and the other custom configurations like labels, datasets, size and options.
In the dataset interface you can pass any configuration and option to your chart.
All options available in chartjs documentation are supported.
Just write the configuration with php array notations and its work!
# Advanced chartjs options
Since the current version allows it to add simple json string based options, it is not possible to generate options like:
```php
options: {
scales: {
xAxes: [{
type: 'time',
time: {
displayFormats: {
quarter: 'MMM YYYY'
}
}
}]
}
}
```
Using the method optionsRaw(string) its possible to add a the options in raw format:
Passing string format like a json
```php
$chart->optionsRaw("{
legend: {
display:false
},
scales: {
xAxes: [{
gridLines: {
display:false
}
}]
}
}");
```
Or, if you prefer, you can pass a php array format
```php
$chart->optionsRaw([
'legend' => [
'display' => true,
'labels' => [
'fontColor' => '#000'
]
],
'scales' => [
'xAxes' => [
[
'stacked' => true,
'gridLines' => [
'display' => true
]
]
]
]
]);
```
# Examples
1 - Line Chart / Radar Chart:
```php
// ExampleController.php
$chartjs = app()->chartjs
->name('lineChartTest')
->type('line')
->size(['width' => 400, 'height' => 200])
->labels(['January', 'February', 'March', 'April', 'May', 'June', 'July'])
->datasets([
[
"label" => "My First dataset",
'backgroundColor' => "rgba(38, 185, 154, 0.31)",
'borderColor' => "rgba(38, 185, 154, 0.7)",
"pointBorderColor" => "rgba(38, 185, 154, 0.7)",
"pointBackgroundColor" => "rgba(38, 185, 154, 0.7)",
"pointHoverBackgroundColor" => "#fff",
"pointHoverBorderColor" => "rgba(220,220,220,1)",
'data' => [65, 59, 80, 81, 56, 55, 40],
],
[
"label" => "My Second dataset",
'backgroundColor' => "rgba(38, 185, 154, 0.31)",
'borderColor' => "rgba(38, 185, 154, 0.7)",
"pointBorderColor" => "rgba(38, 185, 154, 0.7)",
"pointBackgroundColor" => "rgba(38, 185, 154, 0.7)",
"pointHoverBackgroundColor" => "#fff",
"pointHoverBorderColor" => "rgba(220,220,220,1)",
'data' => [12, 33, 44, 44, 55, 23, 40],
]
])
->options([]);
return view('example', compact('chartjs'));
// example.blade.php
<div style="width:75%;">
{!! $chartjs->render() !!}
</div>
```
2 - Bar Chart:
```php
// ExampleController.php
$chartjs = app()->chartjs
->name('barChartTest')
->type('bar')
->size(['width' => 400, 'height' => 200])
->labels(['Label x', 'Label y'])
->datasets([
[
"label" => "My First dataset",
'backgroundColor' => ['rgba(255, 99, 132, 0.2)', 'rgba(54, 162, 235, 0.2)'],
'data' => [69, 59]
],
[
"label" => "My First dataset",
'backgroundColor' => ['rgba(255, 99, 132, 0.3)', 'rgba(54, 162, 235, 0.3)'],
'data' => [65, 12]
]
])
->options([]);
return view('example', compact('chartjs'));
// example.blade.php
<div style="width:75%;">
{!! $chartjs->render() !!}
</div>
```
3 - Pie Chart / Doughnut Chart:
```php
// ExampleController.php
$chartjs = app()->chartjs
->name('pieChartTest')
->type('pie')
->size(['width' => 400, 'height' => 200])
->labels(['Label x', 'Label y'])
->datasets([
[
'backgroundColor' => ['#FF6384', '#36A2EB'],
'hoverBackgroundColor' => ['#FF6384', '#36A2EB'],
'data' => [69, 59]
]
])
->options([]);
return view('example', compact('chartjs'));
// example.blade.php
<div style="width:75%;">
{!! $chartjs->render() !!}
</div>
```
# OBS:
This README, as well as the package, is in development, but will be constantly updated and I will keep you informed as soon as
it is ready for production. Thank you for understanding.
Any questions or suggestions preferably open a issue!
# License
LaravelChartJs is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT).
@@ -1,32 +0,0 @@
{
"name": "fx3costa/laravelchartjs",
"description": "Simple package to facilitate and automate the use of charts in Laravel 5.x using Chartjs v2 library",
"keywords": [
"chartjs","laravel5","chart","reports","graphics", "fx3costa"
],
"license": "MIT",
"authors": [
{
"name": "Felix",
"email": "fx3costa@gmail.com"
}
],
"require": {
"php": ">=5.6.4",
"illuminate/support": "^5.1|^6.0|^7.0|^8.0|^9.0|^10.0"
},
"autoload": {
"psr-4": {
"Fx3costa\\LaravelChartJs\\" : "src/"
}
},
"extra": {
"laravel": {
"providers": [
"Fx3costa\\LaravelChartJs\\Providers\\ChartjsServiceProvider"
]
}
}
}
@@ -1,183 +0,0 @@
<?php
/*
* This file is inspired by Builder from Laravel ChartJS - Brian Faust
*/
namespace Fx3costa\LaravelChartJs;
use Illuminate\Support\Arr;
class Builder
{
/**
* @var array
*/
private $charts = [];
/**
* @var string
*/
private $name;
/**
* @var array
*/
private $defaults = [
'datasets' => [],
'labels' => [],
'type' => 'line',
'options' => [],
'size' => ['width' => null, 'height' => null]
];
/**
* @var array
*/
private $types = [
'bar',
'horizontalBar',
'bubble',
'scatter',
'doughnut',
'line',
'pie',
'polarArea',
'radar'
];
/**
* @param $name
*
* @return $this|Builder
*/
public function name($name)
{
$this->name = $name;
$this->charts[$name] = $this->defaults;
return $this;
}
/**
* @param $element
*
* @return Builder
*/
public function element($element)
{
return $this->set('element', $element);
}
/**
* @param array $labels
*
* @return Builder
*/
public function labels(array $labels)
{
return $this->set('labels', $labels);
}
/**
* @param array $datasets
*
* @return Builder
*/
public function datasets(array $datasets)
{
return $this->set('datasets', $datasets);
}
/**
* @param $type
*
* @return Builder
*/
public function type($type)
{
if (!in_array($type, $this->types)) {
throw new \InvalidArgumentException('Invalid Chart type.');
}
return $this->set('type', $type);
}
/**
* @param array $size
*
* @return Builder
*/
public function size($size)
{
return $this->set('size', $size);
}
/**
* @param array $options
*
* @return $this|Builder
*/
public function options(array $options)
{
foreach ($options as $key => $value) {
$this->set('options.' . $key, $value);
}
return $this;
}
/**
*
* @param string|array $optionsRaw
* @return \self
*/
public function optionsRaw($optionsRaw)
{
if (is_array($optionsRaw)) {
$this->set('optionsRaw', json_encode($optionsRaw, true));
return $this;
}
$this->set('optionsRaw', $optionsRaw);
return $this;
}
/**
* @return mixed
*/
public function render()
{
$chart = $this->charts[$this->name];
return view('chart-template::chart-template')
->with('datasets', $chart['datasets'])
->with('element', $this->name)
->with('labels', $chart['labels'])
->with('options', isset($chart['options']) ? $chart['options'] : '')
->with('optionsRaw', isset($chart['optionsRaw']) ? $chart['optionsRaw'] : '')
->with('type', $chart['type'])
->with('size', $chart['size']);
}
/**
* @param $key
*
* @return mixed
*/
private function get($key)
{
return Arr::get($this->charts[$this->name], $key);
}
/**
* @param $key
* @param $value
*
* @return $this|Builder
*/
private function set($key, $value)
{
Arr::set($this->charts[$this->name], $key, $value);
return $this;
}
}
@@ -1,37 +0,0 @@
<?php namespace Fx3costa\LaravelChartJs\Providers;
use Fx3costa\LaravelChartJs\Builder;
use Fx3costa\LaravelChartJs\ChartBar;
use Fx3costa\LaravelChartJs\ChartLine;
use Fx3costa\LaravelChartJs\ChartPieAndDoughnut;
use Fx3costa\LaravelChartJs\ChartRadar;
use Illuminate\Support\ServiceProvider;
class ChartjsServiceProvider extends ServiceProvider
{
/**
* Array with colours configuration of the chartjs config file
* @var array
*/
protected $colours = [];
public function boot()
{
$this->loadViewsFrom(__DIR__.'/../resources/views', 'chart-template');
$this->colours = config('chartjs.colours');
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->bind('chartjs', function() {
return new Builder();
});
}
}
@@ -1,22 +0,0 @@
<canvas id="{!! $element !!}" width="{!! $size['width'] !!}" height="{!! $size['height'] !!}">
<script>
document.addEventListener("DOMContentLoaded", function(event) {
(function() {
"use strict";
var ctx = document.getElementById("{!! $element !!}");
window.{!! $element !!} = new Chart(ctx, {
type: '{!! $type !!}',
data: {
labels: {!! json_encode($labels) !!},
datasets: {!! json_encode($datasets) !!}
},
@if(!empty($optionsRaw))
options: {!! $optionsRaw !!}
@elseif(!empty($options))
options: {!! json_encode($options) !!}
@endif
});
})();
});
</script>
</canvas>