Skip to content

Commit 4de857e

Browse files
committed
Documentation
1 parent 9ea2747 commit 4de857e

6 files changed

Lines changed: 45 additions & 143 deletions

File tree

.github/ISSUE_TEMPLATE.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
* PHP: v7.0.0
2+
* Laravel: v5.5.0
3+
4+
5+
### Description:
6+
7+
8+
### Steps To Reproduce:

docs/readme.md

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,23 @@
77
<a href="https://packagist.org/packages/bbsnly/chartjs-php"><img src="https://poser.pugx.org/bbsnly/chartjs-php/license.svg" alt="License"></a>
88
</p>
99

10-
The package helps you to generate [ChartJS](http://www.chartjs.org/ "ChartJS")
11-
element directly in PHP and translate it to JSON.
10+
11+
**For non Laravel projects, please use the [1.2](https://github.com/bbsnly/chartjs-php/tree/1.2) branch**
12+
13+
This package helps you to generate [ChartJS](http://www.chartjs.org/ "ChartJS") element directly in PHP and translate it to JSON.
1214

1315
## Install
14-
`composer require bbsnly/chartjs-php`
16+
Require this package with composer.
17+
```shell
18+
composer require bbsnly/chartjs-php
19+
```
1520

16-
## Test
17-
`composer test`
21+
Laravel 5.5 uses Package Auto-Discovery, so doesn't require you to manually add the ServiceProvider.
22+
23+
If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php
24+
```php
25+
Bbsnly\ChartJs\ChartServiceProvider::class,
26+
```
1827

1928
## Requirements
2029
* `php >= 7.0`
@@ -34,44 +43,37 @@ element directly in PHP and translate it to JSON.
3443
Also it is possible to use the package with [New Charts](http://www.chartjs.org/docs/latest/developers/charts.html)
3544
using the `Chart` class
3645

37-
## How To
38-
### Create
39-
```
40-
$chart = new Chart;
41-
$chart->type = 'line';
42-
$chart->toJson();
43-
```
44-
and
45-
```
46-
$chart = new LineChart;
47-
$chart->toJson();
48-
```
49-
provides the same result.
50-
51-
### Usage
46+
## Usage
5247
To personalize your chart you have three options:
5348
* Using arrays
5449
* Using attributes
5550
* Using methods
5651

57-
#### Examples
52+
### Examples
5853
Using arrays
59-
```
54+
```php
55+
$chart = app(Bbsnly\ChartJs\Chart::class);
56+
6057
$chart->data([
6158
'labels' => ['Red', 'Green', 'Blue'],
62-
'datasets' => [{
63-
'data' => [5, 10, 20]
64-
}]
59+
'datasets' => [
60+
[
61+
'data' => [5, 10, 20]
62+
]
63+
]
6564
]);
6665

6766
$chart->options([
6867
'responsive' => true
6968
]);
69+
70+
$chart->toJson();
7071
```
7172
Using attributes
72-
```
73-
$data = new Data();
73+
```php
74+
$chart = app(Bbsnly\ChartJs\Chart::class);
7475

76+
$data = new Data();
7577
$data->labels = ['Red', 'Green', 'Blue'];
7678

7779
$dataset = new Dataset();
@@ -83,9 +85,13 @@ $chart->data($data);
8385
$options = new Options();
8486
$options->responsive = true;
8587
$chart->options($options);
88+
89+
$chart->toJson();
8690
```
8791
Using methods
88-
```
92+
```php
93+
$chart = app(Bbsnly\ChartJs\Chart::class);
94+
8995
$data = new Data;
9096

9197
$data->datasets([
@@ -97,25 +103,22 @@ $chart->data($data);
97103
$options = new Options();
98104
$options->responsive(true);
99105
$chart->options($options);
106+
107+
$chart->toJson();
100108
```
101109
### Config class
102110
To configure your chart you can use the `Config` class directly or helpers
103111
like `Dataset` or `Options`.
104112

105-
You can extend it and add a helper for wherever you need (ex. `Scales`).
113+
You can extend it and add a helper you need (ex. `Scales`).
106114

107115
If you decide to override the `Config` class you should implement
108116
the `ConfigInterface` to be sure about the compatibility.
109117

110-
## Code Examples
111-
You can find some examples
112-
[here](https://github.com/bbsnly/chartjs-php/tree/master/tests/examples "ChartJS PHP Examples")
113118

114119
## Contributing
115-
116120
Thank you for considering contributing to the ChartJS PHP!
117121

118122
## License
119-
120123
The ChartJS PHP is open-sourced software licensed under the
121124
[MIT license](http://opensource.org/licenses/MIT).

tests/examples/bar.php

Lines changed: 0 additions & 28 deletions
This file was deleted.

tests/examples/base.php

Lines changed: 0 additions & 22 deletions
This file was deleted.

tests/examples/line.php

Lines changed: 0 additions & 30 deletions
This file was deleted.

tests/examples/pie.php

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)