Skip to content

Commit ec516d0

Browse files
committed
2.0.0
1 parent 05fd92d commit ec516d0

10 files changed

+543
-148
lines changed

composer.json

+12-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,21 @@
1010
"email": "reza.wikrama3@gmail.com"
1111
}
1212
],
13-
"minimum-stability": "stable",
13+
"minimum-stability": "dev-master",
1414
"require": {},
1515
"autoload": {
1616
"psr-4": {
17-
"Oblagio\\Highcharts\\": "src/"
17+
"RezaAr\\Highcharts\\": "src/"
18+
}
19+
},
20+
"extra": {
21+
"laravel": {
22+
"providers": [
23+
"RezaAr\\Highcharts\\Provider"
24+
],
25+
"aliases": {
26+
"Chart": "RezaAr\\Highcharts\\Facade"
27+
}
1828
}
1929
}
2030
}

readme.md

+118-32
Original file line numberDiff line numberDiff line change
@@ -5,70 +5,156 @@
55
[![License](https://poser.pugx.org/muhamadrezaar/highcharts/license.svg)](https://packagist.org/packages/muhamadrezaar/highcharts)
66

77

8-
Package Highcharts untuk Laravel 5
8+
Package Highcharts for Laravel 5
99

10-
### Installasi
10+
### Installations
11+
12+
Add Package to composer.json
1113

12-
Tambahkan Package pada composer.json
1314
```sh
1415
composer require muhamadrezaar/highcharts
1516
```
16-
setelah package terdownload , register provider dan facade nya
17+
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:
1718

1819
Provider :
1920
```sh
20-
Oblagio\Highcharts\Provider::class
21+
RezaAr\Highcharts\Provider::class,
2122
```
2223
Facade :
2324
```sh
24-
'Chart' => Oblagio\Highcharts\Facade::class,
25+
'Chart' => RezaAr\Highcharts\Facade::class,
26+
```
27+
28+
then publish the config
29+
30+
``` sh
31+
php artisan vendor:publish
2532
```
2633

27-
### Cara penggunaaan
34+
### Basic Usage
35+
36+
In Controller or Other Class
2837

2938
```sh
3039

3140
<?php
32-
$charts = [
33-
34-
'chart' => ['type' => 'column'],
35-
'title' => ['text' => 'fruit Consumption'],
36-
'xAxis' => [
37-
'categories' => ['apples' , 'bananas'],
38-
],
39-
'yAxis' => [
40-
'title' => [
41-
'text' => 'Fruit Eaten'
42-
]
43-
],
44-
'series' => [
41+
$legend = [
42+
'layout' => 'vertikal',
43+
'align' => 'right',
44+
'verticalAlign' => 'middle',
45+
];
46+
47+
$series = [
4548
[
46-
'name' => 'Reza',
47-
'data' => [1,2]
49+
'name' => 'Voting',
50+
'data' => [43934, 52503, 57177, 69658],
51+
// 'color' => '#0c2959',
4852
],
49-
[
50-
'name' => 'Kika',
51-
'data' => [2,4]
53+
];
54+
55+
$chart1 = \Chart::title([
56+
'text' => 'Voting ballon d`or 2018',
57+
])
58+
->chart([
59+
'type' => 'line', // pie , columnt ect
60+
'renderTo' => 'chart1', // render the chart into your div with id
61+
])
62+
->subtitle([
63+
'text' => 'This Subtitle',
64+
])
65+
->colors([
66+
'#0c2959'
67+
])
68+
->xaxis([
69+
'categories' => [
70+
'Messi',
71+
'CR7',
72+
'Bambang Pamungkas',
73+
'Del Piero',
5274
],
53-
]
54-
];
55-
56-
echo Chart::display("id-highchartsnya", $charts);
75+
'labels' => [
76+
'rotation' => 15,
77+
'align' => 'top',
78+
'formatter' => 'startJs:function(){return this.value + " (Footbal Player)"}:endJs', // use 'startJs:yourjavasscripthere:endJs'
79+
],
80+
])
81+
->yaxis([
82+
'text' => 'This Y Axis',
83+
])
84+
->legend([
85+
'layout' => 'vertikal',
86+
'align' => 'right',
87+
'verticalAlign' => 'middle',
88+
])
89+
->series($series)
90+
->display();
91+
92+
return view('welcome', [
93+
'chart1' => $chart1,
94+
]);
5795

5896

5997
?>
6098
```
61-
Versi Blade
99+
In Blade
62100

63101
```sh
64102

65-
{!! Chart::display("id-highchartsnya", $charts) !!}
103+
<div id="chart1"></div>
104+
105+
{!! $chart1 !!}
66106

67107
```
68108
Output :
69109

70-
![alt tag](http://s17.postimg.org/uig89a9xr/chart.png)
110+
![alt tag](https://preview.ibb.co/cz8SqJ/chart1.png)
111+
112+
113+
the package will generate this code in yout view :
114+
115+
``` sh
116+
117+
<script src="//code.highcharts.com/highcharts.js"></script>
118+
<script src="//code.highcharts.com/modules/series-label.js"></script>
119+
<script src="https://code.highcharts.com/modules/exporting.js"></script>
120+
<script src="https://code.highcharts.com/modules/export-data.js"></script>
121+
<script type="text/javascript">
122+
Highcharts.chart( {
123+
title: {
124+
"text": "Voting ballon d`or 2018"
125+
}
126+
, subtitle: {
127+
"text": "This Subtitle"
128+
}
129+
, yAxis: {
130+
"text": "This Y Axis"
131+
}
132+
, xAxis: {
133+
"categories":["Messi", "CR7", "Bambang Pamungkas", "Del Piero"], "labels": {
134+
"rotation":15, "align":"top", "formatter":function() {
135+
return this.value + " (Footbal Player)"
136+
}
137+
}
138+
}
139+
, legend: {
140+
"layout": "vertikal", "align": "right", "verticalAlign": "middle"
141+
}
142+
, series: [ {
143+
"name": "Voting", "data": [43934, 52503, 57177, 69658]
144+
}
145+
], chart: {
146+
"type": "line", "renderTo": "chart1"
147+
}
148+
, colors: ["#0c2959"], credits:false
149+
}
150+
151+
);
152+
</script>
153+
154+
155+
```
71156
157+
cdn highcharts.js and others js only generated one time
72158
73159
## License
74160
+151
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,151 @@
1+
<?php namespace RezaAr\Highcharts\Classes\Presenters;
2+
3+
use RezaAr\Highcharts\Classes\Presenters\ContainerPresenter;
4+
use RezaAr\Highcharts\Classes\Presenters\InitJsPresenter;
5+
use RezaAr\Highcharts\Classes\Presenters\JsTransformerPresenter;
6+
7+
class ChartPresenter
8+
{
9+
public $display;
10+
public $initJs;
11+
public $title;
12+
13+
public function __construct()
14+
{
15+
$this->display = "";
16+
$this->js = new InitJsPresenter();
17+
$this->js->highchart = config('highchart.series_label_js');
18+
$this->js->seriesLabel = config('highchart.highchart_js');
19+
$this->js->exporting = config('highchart.exporting_js');
20+
$this->js->exportData = config('highchart.export_data_js');
21+
$this->container = new ContainerPresenter();
22+
$this->transform = new JsTransformerPresenter();
23+
$this->title = [];
24+
}
25+
26+
public function highcart_js($bool = true)
27+
{
28+
$this->js->highchart = $bool;
29+
return $this;
30+
}
31+
32+
public function series_label_js($bool = true)
33+
{
34+
$this->js->seriesLabel = $bool;
35+
36+
return $this;
37+
}
38+
39+
public function exporting_js($bool = true)
40+
{
41+
$this->js->exporting = $bool;
42+
43+
return $this;
44+
}
45+
46+
public function export_data_js($bool = true)
47+
{
48+
$this->js->exportData = $bool;
49+
50+
return $this;
51+
}
52+
53+
public function getInitJs()
54+
{
55+
56+
$this->display .= $this->js->generate();
57+
$this->js->init = false;
58+
return $this;
59+
}
60+
61+
public function container($container = 'container')
62+
{
63+
$this->transform->container = $container;
64+
65+
return $this;
66+
}
67+
68+
public function title($title = [])
69+
{
70+
$this->transform->title = $title;
71+
return $this;
72+
}
73+
74+
public function subtitle($subtitle = [])
75+
{
76+
$this->transform->subtitle = $subtitle;
77+
return $this;
78+
}
79+
80+
public function yaxis($data = [])
81+
{
82+
$this->transform->yAxis = $data;
83+
return $this;
84+
}
85+
86+
public function xaxis($data = [])
87+
{
88+
$this->transform->xAxis = $data;
89+
return $this;
90+
}
91+
92+
public function legend($legend = [])
93+
{
94+
$this->transform->legend = $legend;
95+
return $this;
96+
}
97+
98+
public function plotOptions($plotOptions = [])
99+
{
100+
$this->transform->plotOptions = $plotOptions;
101+
return $this;
102+
}
103+
104+
public function series($series = [])
105+
{
106+
$this->transform->series = $series;
107+
return $this;
108+
}
109+
110+
public function chart($series = [])
111+
{
112+
$this->transform->chart = $series;
113+
return $this;
114+
}
115+
116+
public function colors($series = [])
117+
{
118+
$this->transform->colors = $series;
119+
return $this;
120+
}
121+
122+
public function credits($credits = 'false')
123+
{
124+
// $this->transform->credits = $credits;
125+
return $this;
126+
}
127+
128+
public function getTransform()
129+
{
130+
$this->display .= $this->transform->transform();
131+
132+
return $this;
133+
}
134+
135+
public function tes($tes)
136+
{
137+
$this->display .= $tes;
138+
139+
return $this;
140+
}
141+
142+
public function display()
143+
{
144+
$this->getInitJs();
145+
$this->getTransform();
146+
$display = $this->display;
147+
$this->display = null;
148+
return $display;
149+
}
150+
151+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php namespace RezaAr\Highcharts\Classes\Presenters;
2+
3+
class ContainerPresenter
4+
{
5+
public $container;
6+
7+
public function __construct()
8+
{
9+
$this->container = "";
10+
}
11+
12+
public function container($id = "container")
13+
{
14+
$this->container = '<div id="'.$id.'"></div>';
15+
16+
return $this->container;
17+
}
18+
}

0 commit comments

Comments
 (0)