diff --git a/README.md b/README.md index 20a3a0d..5a14b0e 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,33 @@ export example: ![exported chart image](https://s4.uupload.ir/files/line_y6mz.png) + +### pie: +```php + $data = [ + ['title'=>'foo','count'=>1234], + ['title'=>'bar','count'=>125], + ['title'=>'baz','count'=>564], + ]; +``` +export example: + +![exported chart image](https://s4.uupload.ir/files/pie_qrst.png) + +### donut: +```php + $data = [ + ['title'=>'foo','count'=>1234], + ['title'=>'bar','count'=>125], + ['title'=>'baz','count'=>564], + ]; +``` +export example: + +![exported chart image](https://s4.uupload.ir/files/donut_m42h.png) + + + ### cloud: ```php $data = [ diff --git a/src/Resources/views/charts/donut.blade.php b/src/Resources/views/charts/donut.blade.php new file mode 100644 index 0000000..1f51e9e --- /dev/null +++ b/src/Resources/views/charts/donut.blade.php @@ -0,0 +1,77 @@ +@extends('chartio::layout') + +@section('chart') +
+
+

{{$title}}

+
+
+ +

+ * {{$description}} +

+
+ @push('scripts') + + @endpush +@stop \ No newline at end of file diff --git a/src/Resources/views/charts/pie.blade.php b/src/Resources/views/charts/pie.blade.php new file mode 100644 index 0000000..959f081 --- /dev/null +++ b/src/Resources/views/charts/pie.blade.php @@ -0,0 +1,76 @@ +@extends('chartio::layout') + +@section('chart') +
+
+

{{$title}}

+
+
+ +

+ * {{$description}} +

+
+ @push('scripts') + + @endpush +@stop \ No newline at end of file diff --git a/src/Services/Chartio.php b/src/Services/Chartio.php index 67e8133..f0fe6b4 100644 --- a/src/Services/Chartio.php +++ b/src/Services/Chartio.php @@ -7,8 +7,10 @@ use FarshidRezaei\Chartio\Services\Charts\AbstractChart; use FarshidRezaei\Chartio\Services\Charts\CloudChart; use FarshidRezaei\Chartio\Services\Charts\ColumnChart; +use FarshidRezaei\Chartio\Services\Charts\DonutChart; use FarshidRezaei\Chartio\Services\Charts\LineChart; use FarshidRezaei\Chartio\Services\Charts\BarChart; +use FarshidRezaei\Chartio\Services\Charts\PieChart; use Intervention\Image\Exception\NotFoundException; class Chartio @@ -24,6 +26,8 @@ class Chartio 'line' => LineChart::class, 'column' =>ColumnChart::class, 'bar' =>BarChart::class, + 'donut' =>DonutChart::class, + 'pie' =>PieChart::class, ]; diff --git a/src/Services/Charts/DonutChart.php b/src/Services/Charts/DonutChart.php new file mode 100644 index 0000000..28c38e9 --- /dev/null +++ b/src/Services/Charts/DonutChart.php @@ -0,0 +1,56 @@ +bladeTemplate ) + ->with( + [ + 'xAxis' => $this->xAxisField, + 'yAxis' => $this->yAxisField, + 'title' => $this->title, + 'description' => $this->description, + 'data' => $this->data, + ] + ) + ->render() + ); + $tempDir = sys_get_temp_dir(); + $tempName = time().'_'.\Str::random( 6 ).'.html'; + $this->htmlPath = "$tempDir/$tempName"; + + file_put_contents( $this->htmlPath, $template ); + return new ChartExporter($this->htmlPath); + } + + + + +} diff --git a/src/Services/Charts/PieChart.php b/src/Services/Charts/PieChart.php new file mode 100644 index 0000000..56f0d2e --- /dev/null +++ b/src/Services/Charts/PieChart.php @@ -0,0 +1,56 @@ +bladeTemplate ) + ->with( + [ + 'xAxis' => $this->xAxisField, + 'yAxis' => $this->yAxisField, + 'title' => $this->title, + 'description' => $this->description, + 'data' => $this->data, + ] + ) + ->render() + ); + $tempDir = sys_get_temp_dir(); + $tempName = time().'_'.\Str::random( 6 ).'.html'; + $this->htmlPath = "$tempDir/$tempName"; + + file_put_contents( $this->htmlPath, $template ); + return new ChartExporter($this->htmlPath); + } + + + + +}