Download the PHP package comecc/c-pchart without Composer
On this page you can find all versions of the php package comecc/c-pchart. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download comecc/c-pchart
More information about comecc/c-pchart
Files in comecc/c-pchart
Package c-pchart
Short Description Port of "pChart" library into PHP 5
License GPL-3.0
Homepage https://github.com/comecc/c-pchart
Informations about the package c-pchart
Table of contents:
- About
- License
- Contributing
- Installation
- Usage
- Draw a chart through Image class only
- Draw a chart with a dedicated class
- Notes
- Changelog
- References
- Links
About:
A project bringing Composer support and some basic PHP 5 standards to pChart 2.0 library. The aim is to allow pChart integration into modern frameworks like Symfony2.
This is the 2.0 version, which aims to further update the code, but without changing the functionality if possible. It will introduce some minor backwards compatibility breaks, so if that's a concern, use the 1.* version.
What was done:
-
Updated the supported PHP version to 5.5.
-
Made a full port of the library's functionality.
-
Defined and added namespaces to all classes.
-
Replaced all
exit()
/die()
commands withthrow
statements to allow a degree of error control. -
Refactored the code to meet PSR-2 standard and added annotations (as best as I could figure them out). to methods Also, typehinting was added to methods where possible, so some backwards compatibility breaks may occur.
-
Added a factory service for loading the classes.
- Moved all constants to a single file
src/Resources/data/constants.php
. This file is required for the library to function and is now loaded via Composer.
License:
It was previously stated that this package is on MIT license, which did not meet the requirements set by the original author. It is now under the GNU GPL v3 license, so if you wish to use it in a commercial project, you need to pay an appropriate fee.
Contributing:
If you wish to contribute to the 1.*
version, there is a branch called legacy
to which you
may submit pull requests. Otherwise feel free to use the master
branch.
Installation (via Composer):
For composer installation, add:
to your composer.json file and update your dependencies. Or you can run:
in your project directory, where the composer.json file is.
After that, all classes are available under CpChart\Chart
namespace or
CpChart\Factory
for the factory.
Usage:
Now you can autoload or use the classes via their namespaces. If you want to, you may utilize the provided factory class. Below are examples of how to use the library, the charts themselves are borrowed from the official documentation.
Draw a chart through Image class only
Not all charts need to be created through a seperate class (ex. bar or spline charts), some are created via the Image class (check the official documentation before drawing). An example for a spline chart below:
Draw a chart with a dedicated class:
Some charts require using a dedicated class, which you can create via the factory. Notice that you specify the type of chart, not the class name. An example for a pie chart below:
Notes:
Basically, all should work as defined in the pChart 2.0 documentation with added support for try/catch functionality. The factory class has methods to load all types of classes present in the pChart library.
IMPORTANT! If you want to use any of the fonts or palletes files, provide only
the name of the actual file, do not add the 'fonts' or 'palettes' folder to the
string given into the function. If you want to load them from a different directory
than the default, you need to add the full path to the file (ex. __DIR__.'/folder/to/my/palletes
).
Changelog
1.0 Stable version with basic functionality.
1.1 Added factory service.
1.1.1 Changed chart loading via factory a bit (see class annotations).
1.1.2 Updated service class with Exception handling regarding missing / wrong class name.
1.1.3 The file with classes' constants is now loaded via Composer (thanks to ThaDafinser).
1.1.4 Fixed code-breaking typ (thanks to subtronic).
1.1.5 Added an option to hide the X axis or only it's values (thanks to julien-gm).
1.1.6 Added support for closures in formatting scale (thanks to funkjedi)
2.0 Updated all classes to PSR-2 standard, added typehinting where possible, updated annotations in methods to be as accurate as possible. Added Behat testing and restructed the namespaces into more sensible structure.
References
PHP Framework Interoperability Group at GitHub on PHP coding standards:
Links
All versions of c-pchart with dependencies
ext-gd Version *