-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4eb38e3
commit 4a3bc4f
Showing
6 changed files
with
296 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
@extends('chartio::layout') | ||
|
||
@section('chart') | ||
<figure id="chart-wrapper" class="highcharts-figure management-chart-item-box"> | ||
<div class="chart-item-title"> | ||
<h2>{{$title}}</h2> | ||
</div> | ||
<div id="chart"></div> | ||
|
||
<p class="description"> | ||
* {{$description}} | ||
</p> | ||
</figure> | ||
@push('scripts') | ||
<script> | ||
let jsonData = @json($data); | ||
jsonData = jsonData.map(item => { | ||
return {name: item['{{$xAxis}}'], y: item['{{$yAxis}}']} | ||
}); | ||
Highcharts.chart('chart', { | ||
backgroundColor: 'transparent', | ||
colors: ["#009299", "#1AD7DB", "#589DFB", "#5EDFFF", "#B7E778"], | ||
credits: { | ||
enabled: false | ||
}, | ||
exporting: { | ||
enabled: false, | ||
}, | ||
chart: { | ||
height: "250", | ||
backgroundColor: 'transparent', | ||
plotBackgroundColor: 'transparent', | ||
plotBorderWidth: 0, | ||
plotShadow: false, | ||
type: 'pie', | ||
style: { | ||
fontFamily: 'BNazanin' | ||
} | ||
}, | ||
title: { | ||
style: { | ||
display: 'none' | ||
}, | ||
}, | ||
tooltip: { | ||
formatter: function () { | ||
return '<span style="font-size: 10px;text-align: left">' + Highcharts.localizationNumber(this.key) + ' - %' + Highcharts.localizationNumber(this.y) + '</span>'; | ||
}, | ||
// pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' | ||
}, | ||
accessibility: { | ||
point: { | ||
valueSuffix: '%' | ||
} | ||
}, | ||
plotOptions: { | ||
pie: { | ||
// allowPointSelect: true, | ||
allowPointSelect: true, | ||
cursor: 'pointer', | ||
dataLabels: { | ||
enabled: false | ||
}, | ||
showInLegend: true, | ||
} | ||
}, | ||
series: [{ | ||
name: 'Brands', | ||
colorByPoint: true, | ||
innerSize:'45%', | ||
data: jsonData | ||
}] | ||
}); | ||
</script> | ||
@endpush | ||
@stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
@extends('chartio::layout') | ||
|
||
@section('chart') | ||
<figure id="chart-wrapper" class="highcharts-figure management-chart-item-box"> | ||
<div class="chart-item-title"> | ||
<h2>{{$title}}</h2> | ||
</div> | ||
<div id="chart"></div> | ||
|
||
<p class="description"> | ||
* {{$description}} | ||
</p> | ||
</figure> | ||
@push('scripts') | ||
<script> | ||
let jsonData = @json($data); | ||
jsonData = jsonData.map(item => { | ||
return {name: item['{{$xAxis}}'], y: item['{{$yAxis}}']} | ||
}); | ||
Highcharts.chart('chart', { | ||
backgroundColor: 'transparent', | ||
colors: ["#009299", "#1AD7DB", "#589DFB", "#5EDFFF", "#B7E778"], | ||
credits: { | ||
enabled: false | ||
}, | ||
exporting: { | ||
enabled: false, | ||
}, | ||
chart: { | ||
height: "250", | ||
backgroundColor: 'transparent', | ||
plotBackgroundColor: 'transparent', | ||
plotBorderWidth: 0, | ||
plotShadow: false, | ||
type: 'pie', | ||
style: { | ||
fontFamily: 'BNazanin' | ||
} | ||
}, | ||
title: { | ||
style: { | ||
display: 'none' | ||
}, | ||
}, | ||
tooltip: { | ||
formatter: function () { | ||
return '<span style="font-size: 10px;text-align: left">' + Highcharts.localizationNumber(this.key) + ' - %' + Highcharts.localizationNumber(this.y) + '</span>'; | ||
}, | ||
// pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>' | ||
}, | ||
accessibility: { | ||
point: { | ||
valueSuffix: '%' | ||
} | ||
}, | ||
plotOptions: { | ||
pie: { | ||
// allowPointSelect: true, | ||
allowPointSelect: true, | ||
cursor: 'pointer', | ||
dataLabels: { | ||
enabled: false | ||
}, | ||
showInLegend: true, | ||
} | ||
}, | ||
series: [{ | ||
name: 'Brands', | ||
colorByPoint: true, | ||
data: jsonData | ||
}] | ||
}); | ||
</script> | ||
@endpush | ||
@stop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
|
||
namespace FarshidRezaei\Chartio\Services\Charts; | ||
|
||
|
||
use JetBrains\PhpStorm\Pure; | ||
use FarshidRezaei\Chartio\Services\ChartExporter; | ||
use Spatie\Browsershot\Browsershot; | ||
|
||
|
||
class DonutChart extends AbstractChart | ||
{ | ||
|
||
protected string $type = 'donut'; | ||
|
||
protected string $bladeTemplate = 'chartio::charts.donut'; | ||
|
||
#[Pure] | ||
public static function new(): self | ||
{ | ||
return new self(); | ||
} | ||
|
||
|
||
/** | ||
* | ||
* @return ChartExporter | ||
*/ | ||
public function generate(): ChartExporter | ||
{ | ||
$template = trim( | ||
view( $this->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); | ||
} | ||
|
||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
|
||
namespace FarshidRezaei\Chartio\Services\Charts; | ||
|
||
|
||
use JetBrains\PhpStorm\Pure; | ||
use FarshidRezaei\Chartio\Services\ChartExporter; | ||
use Spatie\Browsershot\Browsershot; | ||
|
||
|
||
class PieChart extends AbstractChart | ||
{ | ||
|
||
protected string $type = 'pie'; | ||
|
||
protected string $bladeTemplate = 'chartio::charts.pie'; | ||
|
||
#[Pure] | ||
public static function new(): self | ||
{ | ||
return new self(); | ||
} | ||
|
||
|
||
/** | ||
* | ||
* @return ChartExporter | ||
*/ | ||
public function generate(): ChartExporter | ||
{ | ||
$template = trim( | ||
view( $this->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); | ||
} | ||
|
||
|
||
|
||
|
||
} |