xref: /plugin/statdisplay/vendor/szymach/c-pchart/README.md (revision 03cdebb71906645bc452782ad23f052261c2cb18)
1Table of contents:
2==================
3* [Support](#support)
4* [Code quality](#code-quality)
5* [About](#about)
6* [License](#license)
7* [Contributing](#contributing)
8* [Installation](#installation-via-composer)
9* [Usage](#usage)
10    - [Charts created through Image class](#charts-created-through-image-class)
11    - [Standalone charts](#standalone-charts)
12    - [Barcodes](#barcodes)
13    - [Cache](#cache)
14    - [Fonts and palletes](#fonts-and-palletes)
15* [Changelog](#changelog)
16* [References](#references)
17* [Links](#links)
18
19Support:
20========
21
22This project is supported in a basic manner and no new features will be introduced.
23Issues and pull requests will be reviewed and resolved if need be, so feel free
24to post them.
25
26About:
27======
28
29This library is a port of the excellent pChart statistics library created by Jean-Damien Pogolotti,
30and aims to allow the usage of it in modern applications. This was done through
31applying PSR standards to code, introducing namespaces and typehints, along with
32some basic annotations to methods.
33
34This is the `3.x` version, which removes the factory service and reorganizes the
35file structure a bit. It does not introduce any new features, but the changes are
36not compatibile with the `2.x` branch. BC compatibility with the original library
37is mostly retained, however you can still use the `1.x` version if you cannot risk
38any of these.
39
40If you require support for the unsupported PHP versions, you will need to use the
41`3.0.x` versions. Starting from `3.1`, only PHP `8.x` versions are supported.
42
43What was done:
44
45- Support for PHP `8.x`.
46
47- Made a full port of the library's functionality. I have touched very little of
48the actual logic, so most code from the original library should work.
49
50- Defined and added namespaces to all classes.
51
52- Replaced all `exit()` / `die()` commands with `throw` statements.
53
54- Refactored the code to meet PSR-2 standard and added annotations (as best as I could figure them out)
55to methods Also, typehinting was added to methods where possible, so some backwards compatibility breaks
56may occur if you did some weird things.
57
58- Moved all constants to a [single file](constants.php). It is loaded automatically
59through Composer, so no need for manual action.
60
61License:
62========
63
64It was previously stated that this package uses the [MIT](https://opensource.org/licenses/MIT) license,
65which did not meet the requirements set by the original author. It is now under the
66[GNU GPL v3](http://www.gnu.org/licenses/gpl-3.0.html) license, so if you wish to
67use it in a commercial project, you need to pay an [appropriate fee](http://www.pchart.net/license).
68
69UPDATE the [official website](http://www.pchart.net) is no longer active and I
70have had no success in trying to contact the original library developer. I have
71no idea how this translated to any legal actions you would have to perform in
72order to use this library in a commercial projects.
73
74Contributing:
75=============
76
77All in all, this is a legacy library ported over from PHP 4, so the code is neither
78beautiful nor easy to understand. I did my best to modernize and cover it with
79some basic tests, but there is much more that could be done. If you are willing and
80have time to fix or improve anything, feel free to post a PR or issue.
81
82Installation (via Composer):
83============================
84
85For composer installation, add:
86
87```json
88"require": {
89    "szymach/c-pchart": "^3.1"
90},
91```
92
93to your composer.json file and update your dependencies. Or you can run:
94
95```sh
96$ composer require szymach/c-pchart
97```
98
99in your project's root directory.
100
101Usage:
102======
103
104Your best source to understanding how to use the library is still the [official wiki](http://wiki.pchart.net/).
105However, I have ported at least one example for each chart into Markdown files,
106so you can compare each version and figure out how to use the current implementation.
107
108Charts created through Image class
109---------------------------------------
110
111Most of the basic charts are created through methods of the `CpChart\Image`
112class. Below you can find a full list of these charts, alongside example code.
113
114- [area](resources/doc/area.md)
115- [bar](resources/doc/bar.md)
116- [best fit](resources/doc/best_fit.md)
117- [filled spline](resources/doc/filled_spline.md)
118- [filled step](resources/doc/filled_step.md)
119- [line](resources/doc/line.md)
120- [plot](resources/doc/plot.md)
121- [progress](resources/doc/progress.md)
122- [spline](resources/doc/spline.md)
123- [stacked area](resources/doc/stacked_area.md)
124- [stacked bar](resources/doc/stacked_bar.md)
125- [step](resources/doc/step.md)
126- [zone](resources/doc/zone.md)
127
128Standalone charts:
129------------------------------------
130
131The more advanced charts have their own separate class you need to use in order
132to create them. As before, below is a full list of these, with example code.
133
134- [2D pie](resources/doc/2d_pie.md)
135- [3D pie](resources/doc/3d_pie.md)
136- [2D ring](resources/doc/2d_ring.md)
137- [3D ring](resources/doc/3d_ring.md)
138- [bubble](resources/doc/bubble.md)
139- [contour](resources/doc/contour.md)
140- [polar](resources/doc/polar.md)
141- [radar](resources/doc/radar.md)
142- [scatter best fit](resources/doc/scatter_best_fit.md)
143- [scatter line](resources/doc/scatter_line.md)
144- [scatter plot](resources/doc/scatter_plot.md)
145- [scatter spline](resources/doc/scatter_spline.md)
146- [scatter threshold](resources/doc/scatter_threshold.md)
147- [scatter threshold area](resources/doc/scatter_threshold_area.md)
148- [split path](resources/doc/split_path.md)
149- [spring](resources/doc/spring.md)
150- [stock](resources/doc/stock.md)
151- [surface](resources/doc/surface.md)
152
153Barcodes
154--------
155
156The pChart library also provides a way to render barcodes 39 and 128. Below you
157can find links to doc on creating them:
158
159- [barcode39](resources/doc/barcode_39.md)
160- [barcode128](resources/doc/barcode_128.md)
161
162Cache
163-----
164
165If you find yourself creating charts out of a set of data more than once, you may
166consider using the cache component of the library. Head on to the [dedicated part](resources/doc/cache.md)
167of the documentation for information on how to do that.
168
169Fonts and palletes
170------------------
171
172If you want to use any of the fonts or palletes files, provide only
173the name of the actual file, do not add the `fonts` or `palettes` folder to the
174string given into the function. If you want to load them from a different directory
175than the default, you need to add the full path to the file (ex. `__DIR__.'/folder/to/my/palletes`).
176
177References
178==========
179[The original pChart website](http://www.pchart.net/) (no longer active)
180
181Links
182=====
183
184[GitHub](https://github.com/szymach/c-pchart)
185
186[Packagist](https://packagist.org/packages/szymach/c-pchart)
187