Package Data | |
---|---|
Maintainer Username: | julles |
Maintainer Contact: | reza.wikrama3@gmail.com (Muhamad Reza Abdul Rohim) |
Package Create Date: | 2016-01-17 |
Package Last Update: | 2023-04-23 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:05:25 |
Package Statistics | |
---|---|
Total Downloads: | 42,949 |
Monthly Downloads: | 294 |
Daily Downloads: | 20 |
Total Stars: | 31 |
Total Watchers: | 8 |
Total Forks: | 15 |
Total Open Issues: | 11 |
Package Highcharts for Laravel 5
Add Package to composer.json
composer require muhamadrezaar/highcharts:dev-master
In Laravel 5.5 the service provider will automatically get registered. In older versions of the framework just add the service provider and facade in config/app.php file:
Provider :
RezaAr\Highcharts\Provider::class,
Facade :
'Chart' => RezaAr\Highcharts\Facade::class,
then publish the config
php artisan vendor:publish
In Controller or Other Class
<?php
$chart1 = \Chart::title([
'text' => 'Voting ballon d`or 2018',
])
->chart([
'type' => 'line', // pie , columnt ect
'renderTo' => 'chart1', // render the chart into your div with id
])
->subtitle([
'text' => 'This Subtitle',
])
->colors([
'#0c2959'
])
->xaxis([
'categories' => [
'Alex Turner',
'Julian Casablancas',
'Bambang Pamungkas',
'Mbah Surip',
],
'labels' => [
'rotation' => 15,
'align' => 'top',
'formatter' => 'startJs:function(){return this.value + " (Footbal Player)"}:endJs',
// use 'startJs:yourjavasscripthere:endJs'
],
])
->yaxis([
'text' => 'This Y Axis',
])
->legend([
'layout' => 'vertikal',
'align' => 'right',
'verticalAlign' => 'middle',
])
->series(
[
[
'name' => 'Voting',
'data' => [43934, 52503, 57177, 69658],
// 'color' => '#0c2959',
],
]
)
->display();
return view('welcome', [
'chart1' => $chart1,
]);
?>
In Blade
<div id="chart1"></div>
{!! $chart1 !!}
Output :
the package will generate this code in yout view :
<script src="//code.highcharts.com/highcharts.js"></script>
<script src="//code.highcharts.com/modules/series-label.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/modules/export-data.js"></script>
<script type="text/javascript">
Highcharts.chart( {
title: {
"text": "Voting ballon d`or 2018"
}
, subtitle: {
"text": "This Subtitle"
}
, yAxis: {
"text": "This Y Axis"
}
, xAxis: {
"categories":["Messi", "CR7", "Bambang Pamungkas", "Del Piero"], "labels": {
"rotation":15, "align":"top", "formatter":function() {
return this.value + " (Footbal Player)"
}
}
}
, legend: {
"layout": "vertikal", "align": "right", "verticalAlign": "middle"
}
, series: [ {
"name": "Voting", "data": [43934, 52503, 57177, 69658]
}
], chart: {
"type": "line", "renderTo": "chart1"
}
, colors: ["#0c2959"], credits:false
}
);
</script>
cdn highcharts.js and others js only generated one time
https://reza.mit-license.org/