Skip to content

Commit b9d2211

Browse files
committed
Minor improvements and PHP7.3 support
1 parent 787579a commit b9d2211

File tree

11 files changed

+250
-129
lines changed

11 files changed

+250
-129
lines changed

.editorconfig

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
indent_style = space
8+
indent_size = 4
9+
trim_trailing_whitespace = true
10+
11+
[*.md]
12+
trim_trailing_whitespace = false

.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:

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1-
/vendor/
2-
.idea
1+
/vendor
2+
/.idea
3+
composer.phar
4+
.DS_Store
5+
Thumbs.db

.travis.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1-
install: composer install
21
language: php
2+
33
php:
44
- '7.1'
55
- '7.2'
6-
- nightly
6+
- '7.3'
7+
8+
install: travis_retry composer install --no-interaction --prefer-dist --no-suggest
9+
10+
script: vendor/bin/phpunit --verbose

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2017 Anatoliy Babushka
3+
Copyright (c) 2019 Anatoliy Babushka
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

README.md

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

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
],
88
"homepage": "https://github.com/bbsnly/chartjs-php",
99
"type": "package",
10-
"version": "1.2.1",
10+
"version": "1.2.2",
1111
"license": "MIT",
1212
"authors": [
1313
{
@@ -19,7 +19,7 @@
1919
"php": ">=7.1"
2020
},
2121
"require-dev": {
22-
"phpunit/phpunit": "^6.2"
22+
"phpunit/phpunit": "^7.5"
2323
},
2424
"autoload": {
2525
"psr-4": {
@@ -39,4 +39,4 @@
3939
"config": {
4040
"sort-packages": true
4141
}
42-
}
42+
}

docs/examples.md

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# Examples
2+
3+
## Table of Contents
4+
- [Std Chart](#std-chart)
5+
- [Helper class](#helper-class)
6+
- [Begin At Zero](#begin-at-zero)
7+
- [Mixed Chart Type](#mixed-chart-type)
8+
9+
10+
#### Std Chart
11+
```php
12+
$chart = app(Bbsnly\ChartJs\Chart::class);
13+
14+
$chart->type = 'bar';
15+
16+
$data = new Data;
17+
18+
$datasets = [
19+
(new Dataset)->data([10, 20, 30, 40])->label('Bar Dataset'),
20+
(new Dataset)->data([50, 50, 50, 50])->label('Line Dataset'),
21+
];
22+
23+
$data->datasets($datasets)->labels(['January', 'February', 'March', 'April']);
24+
25+
$chart->data($data);
26+
```
27+
28+
29+
#### Helper class
30+
```php
31+
$chart = new Bbsnly\ChartJs\BarChart;
32+
33+
$data = new Data;
34+
35+
$datasets = [
36+
(new Dataset)->data([10, 20, 30, 40])->label('Bar Dataset'),
37+
(new Dataset)->data([50, 50, 50, 50])->label('Line Dataset'),
38+
];
39+
40+
$data->datasets($datasets)->labels(['January', 'February', 'March', 'April']);
41+
42+
$chart->data($data);
43+
```
44+
45+
46+
#### Begin At Zero
47+
```php
48+
$chart = app(Bbsnly\ChartJs\Chart::class);
49+
50+
$chart->type = 'bar';
51+
52+
$data = new Data;
53+
54+
$datasets = [
55+
(new Dataset)->data([10, 20, 30, 40])->label('Bar Dataset'),
56+
(new Dataset)->data([50, 50, 50, 50])->label('Line Dataset'),
57+
];
58+
59+
$data->datasets($datasets)->labels(['January', 'February', 'March', 'April']);
60+
61+
$chart->data($data);
62+
63+
$chart->beginAtZero();
64+
```
65+
66+
67+
#### Mixed Chart Type
68+
```php
69+
$chart = new app(Bbsnly\ChartJs\Chart::class);
70+
71+
$chart->type = 'bar';
72+
73+
$data = new Data;
74+
75+
$datasets = [
76+
(new Dataset)->data([10, 20, 30, 40])->label('Bar Dataset'),
77+
(new Dataset)->data([50, 50, 50, 50])->label('Line Dataset')->type('line'),
78+
];
79+
80+
$data->datasets($datasets)->labels(['January', 'February', 'March', 'April']);
81+
82+
$chart->data($data);
83+
84+
$chart->get();
85+
```

docs/extend.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Extend
2+
To configure your chart you can use the `Config` class directly or helpers
3+
like `Dataset` or `Options`.
4+
5+
You can extend it and add a helper you need (ex. `Scales`).
6+
7+
You should implement the `ConfigInterface` when creating a new config helper.

docs/readme.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# ChartJS-PHP
2+
3+
<p align="center">
4+
<a href="https://packagist.org/packages/bbsnly/chartjs-php"><img src="https://poser.pugx.org/bbsnly/chartjs-php/d/total.svg" alt="Total Downloads"></a>
5+
<a href="https://packagist.org/packages/bbsnly/chartjs-php"><img src="https://poser.pugx.org/bbsnly/chartjs-php/v/stable.svg" alt="Latest Stable Version"></a>
6+
<a href="https://travis-ci.org/bbsnly/chartjs-php"><img src="https://travis-ci.org/bbsnly/chartjs-php.svg?branch=master" alt="License"></a>
7+
<a href="https://packagist.org/packages/bbsnly/chartjs-php"><img src="https://poser.pugx.org/bbsnly/chartjs-php/license.svg" alt="License"></a>
8+
</p>
9+
10+
This package helps you to generate [ChartJS](http://www.chartjs.org/ "ChartJS") element directly in PHP.
11+
12+
13+
## Table of Contents
14+
- [Install](#install)
15+
- [Requirements](#requirements)
16+
- [Charts](#charts)
17+
- [Usage](usage.md)
18+
- [Examples](examples.md)
19+
- [Extend](extend.md)
20+
- [Contributing](#contributing)
21+
- [License](#license)
22+
23+
24+
## Install
25+
Require this package with composer.
26+
```shell
27+
composer require bbsnly/chartjs-php
28+
```
29+
30+
31+
## Requirements
32+
* `php >= 7.1`
33+
* `ChartJS >= 2.0`
34+
35+
36+
## Charts
37+
* [Line](http://www.chartjs.org/docs/latest/charts/line.html)
38+
* [Bar](http://www.chartjs.org/docs/latest/charts/bar.html)
39+
* [Radar](http://www.chartjs.org/docs/latest/charts/radar.html)
40+
* [Doughnut](http://www.chartjs.org/docs/latest/charts/doughnut.html)
41+
* [Pie](http://www.chartjs.org/docs/latest/charts/doughnut.html)
42+
* [Polar Area](http://www.chartjs.org/docs/latest/charts/polar.html)
43+
* [Bubble](http://www.chartjs.org/docs/latest/charts/bubble.html)
44+
* [Scatter](http://www.chartjs.org/docs/latest/charts/scatter.html)
45+
* [Mixed](http://www.chartjs.org/docs/latest/charts/mixed.html)
46+
47+
Also it is possible to use the package with [New Charts](http://www.chartjs.org/docs/latest/developers/charts.html)
48+
using the `Chart` class
49+
50+
51+
## Contributing
52+
Thank you for considering contributing to the ChartJS PHP!
53+
54+
55+
## License
56+
The ChartJS PHP is open-sourced software licensed under the
57+
[MIT license](http://opensource.org/licenses/MIT).

0 commit comments

Comments
 (0)