Skip to content

Commit

Permalink
Minor improvements and PHP7.3 support
Browse files Browse the repository at this point in the history
  • Loading branch information
bbsnly committed Mar 12, 2019
1 parent 787579a commit b9d2211
Show file tree
Hide file tree
Showing 11 changed files with 250 additions and 129 deletions.
12 changes: 12 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
root = true

[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
indent_style = space
indent_size = 4
trim_trailing_whitespace = true

[*.md]
trim_trailing_whitespace = false
8 changes: 8 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
* PHP: v7.0.0
* Laravel: v5.5.0


### Description:


### Steps To Reproduce:
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
/vendor/
.idea
/vendor
/.idea
composer.phar
.DS_Store
Thumbs.db
8 changes: 6 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
install: composer install
language: php

php:
- '7.1'
- '7.2'
- nightly
- '7.3'

install: travis_retry composer install --no-interaction --prefer-dist --no-suggest

script: vendor/bin/phpunit --verbose
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2017 Anatoliy Babushka
Copyright (c) 2019 Anatoliy Babushka

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
121 changes: 0 additions & 121 deletions README.md

This file was deleted.

6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"homepage": "https://github.com/bbsnly/chartjs-php",
"type": "package",
"version": "1.2.1",
"version": "1.2.2",
"license": "MIT",
"authors": [
{
Expand All @@ -19,7 +19,7 @@
"php": ">=7.1"
},
"require-dev": {
"phpunit/phpunit": "^6.2"
"phpunit/phpunit": "^7.5"
},
"autoload": {
"psr-4": {
Expand All @@ -39,4 +39,4 @@
"config": {
"sort-packages": true
}
}
}
85 changes: 85 additions & 0 deletions docs/examples.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
# Examples

## Table of Contents
- [Std Chart](#std-chart)
- [Helper class](#helper-class)
- [Begin At Zero](#begin-at-zero)
- [Mixed Chart Type](#mixed-chart-type)


#### Std Chart
```php
$chart = app(Bbsnly\ChartJs\Chart::class);

$chart->type = 'bar';

$data = new Data;

$datasets = [
(new Dataset)->data([10, 20, 30, 40])->label('Bar Dataset'),
(new Dataset)->data([50, 50, 50, 50])->label('Line Dataset'),
];

$data->datasets($datasets)->labels(['January', 'February', 'March', 'April']);

$chart->data($data);
```


#### Helper class
```php
$chart = new Bbsnly\ChartJs\BarChart;

$data = new Data;

$datasets = [
(new Dataset)->data([10, 20, 30, 40])->label('Bar Dataset'),
(new Dataset)->data([50, 50, 50, 50])->label('Line Dataset'),
];

$data->datasets($datasets)->labels(['January', 'February', 'March', 'April']);

$chart->data($data);
```


#### Begin At Zero
```php
$chart = app(Bbsnly\ChartJs\Chart::class);

$chart->type = 'bar';

$data = new Data;

$datasets = [
(new Dataset)->data([10, 20, 30, 40])->label('Bar Dataset'),
(new Dataset)->data([50, 50, 50, 50])->label('Line Dataset'),
];

$data->datasets($datasets)->labels(['January', 'February', 'March', 'April']);

$chart->data($data);

$chart->beginAtZero();
```


#### Mixed Chart Type
```php
$chart = new app(Bbsnly\ChartJs\Chart::class);

$chart->type = 'bar';

$data = new Data;

$datasets = [
(new Dataset)->data([10, 20, 30, 40])->label('Bar Dataset'),
(new Dataset)->data([50, 50, 50, 50])->label('Line Dataset')->type('line'),
];

$data->datasets($datasets)->labels(['January', 'February', 'March', 'April']);

$chart->data($data);

$chart->get();
```
7 changes: 7 additions & 0 deletions docs/extend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Extend
To configure your chart you can use the `Config` class directly or helpers
like `Dataset` or `Options`.

You can extend it and add a helper you need (ex. `Scales`).

You should implement the `ConfigInterface` when creating a new config helper.
57 changes: 57 additions & 0 deletions docs/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# ChartJS-PHP

<p align="center">
<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>
<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>
<a href="https://travis-ci.org/bbsnly/chartjs-php"><img src="https://travis-ci.org/bbsnly/chartjs-php.svg?branch=master" alt="License"></a>
<a href="https://packagist.org/packages/bbsnly/chartjs-php"><img src="https://poser.pugx.org/bbsnly/chartjs-php/license.svg" alt="License"></a>
</p>

This package helps you to generate [ChartJS](http://www.chartjs.org/ "ChartJS") element directly in PHP.


## Table of Contents
- [Install](#install)
- [Requirements](#requirements)
- [Charts](#charts)
- [Usage](usage.md)
- [Examples](examples.md)
- [Extend](extend.md)
- [Contributing](#contributing)
- [License](#license)


## Install
Require this package with composer.
```shell
composer require bbsnly/chartjs-php
```


## Requirements
* `php >= 7.1`
* `ChartJS >= 2.0`


## Charts
* [Line](http://www.chartjs.org/docs/latest/charts/line.html)
* [Bar](http://www.chartjs.org/docs/latest/charts/bar.html)
* [Radar](http://www.chartjs.org/docs/latest/charts/radar.html)
* [Doughnut](http://www.chartjs.org/docs/latest/charts/doughnut.html)
* [Pie](http://www.chartjs.org/docs/latest/charts/doughnut.html)
* [Polar Area](http://www.chartjs.org/docs/latest/charts/polar.html)
* [Bubble](http://www.chartjs.org/docs/latest/charts/bubble.html)
* [Scatter](http://www.chartjs.org/docs/latest/charts/scatter.html)
* [Mixed](http://www.chartjs.org/docs/latest/charts/mixed.html)

Also it is possible to use the package with [New Charts](http://www.chartjs.org/docs/latest/developers/charts.html)
using the `Chart` class


## Contributing
Thank you for considering contributing to the ChartJS PHP!


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

0 comments on commit b9d2211

Please # to comment.