PHPackages                             kodasnarl/c-pchart - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. kodasnarl/c-pchart

ActiveLibrary

kodasnarl/c-pchart
==================

Port of "pChart" library into PHP 5+

v3.0.14(4y ago)08.8k↓100%GPL-3.0-onlyPHPPHP &gt;=5.4

Since Jun 12Pushed 4y agoCompare

[ Source](https://github.com/kodasnarl/c-pchart)[ Packagist](https://packagist.org/packages/kodasnarl/c-pchart)[ Docs](https://github.com/kodasnarl/c-pchart)[ RSS](/packages/kodasnarl-c-pchart/feed)WikiDiscussions master Synced today

READMEChangelog (7)Dependencies (3)Versions (36)Used By (0)

Table of contents:
==================

[](#table-of-contents)

- [Support](#support)
- [Build status](#build-status)
- [Code quality](#code-quality)
- [About](#about)
- [License](#license)
- [Contributing](#contributing)
- [Installation](#installation-via-composer)
- [Usage](#usage)
    - [Charts created through Image class](#charts-created-through-image-class)
    - [Standalone charts](#standalone-charts)
    - [Barcodes](#barcodes)
    - [Cache](#cache)
    - [Fonts and palletes](#fonts-and-palletes)
- [Changelog](#changelog)
- [References](#references)
- [Links](#links)

Support:
========

[](#support)

This project is supported in a basic manner and no new features will be introduced. Issues and pull requests will be reviewed and resolved if need be, so feel free to post them.

Build status:
=============

[](#build-status)

- [![Build Status](https://camo.githubusercontent.com/ff620011d80b6c6fc6e7fbee5694bc8236efd877edf950a6869fdd70f2508960/68747470733a2f2f7472617669732d63692e6f72672f737a796d6163682f632d7063686172742e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/szymach/c-pchart) master
- [![Build Status](https://camo.githubusercontent.com/bbe947dbaafe89df09c641ef7bb3bc36bc577f6fbfee5caaf39a67fc19748edf/68747470733a2f2f7472617669732d63692e6f72672f737a796d6163682f632d7063686172742e7376673f6272616e63683d322e30)](https://travis-ci.org/szymach/c-pchart) 2.0

Code quality:
=============

[](#code-quality)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/b8e52d2ccc87c4d5ee352a6eeda7d69ad54d035e731fb59f69759ef06c9e9735/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f737a796d6163682f632d7063686172742f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/szymach/c-pchart/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/0721172a706948e822dfa0c925bf12fd248208cade5cf52f6b55148efc5e8a1a/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f737a796d6163682f632d7063686172742f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/szymach/c-pchart/?branch=master)

About:
======

[](#about)

This library is a port of the excellent pChart statistics library created by Jean-Damien Pogolotti, and aims to allow the usage of it in modern applications. This was done through applying PSR standards to code, introducing namespaces and typehints, along with some basic annotations to methods.

This is the `3.x` version, which removes the factory service and reorganizes the file structure a bit. It does not introduce any new features, but the changes are not compatibile with the `2.x` branch. BC compatibility with the original library is mostly retained, however you can still use the `1.x` version if you cannot risk any of these.

What was done:

- Support for PHP versions from 5.4 to 7.3.
- Made a full port of the library's functionality. I have touched very little of the actual logic, so most code from the original library should work.
- Defined and added namespaces to all classes.
- Replaced all `exit()` / `die()` commands with `throw` statements.
- 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 if you did some weird things.
- Moved all constants to a [single file](constants.php). It is loaded automatically through Composer, so no need for manual action.

License:
========

[](#license)

It was previously stated that this package uses the [MIT](https://opensource.org/licenses/MIT) license, which did not meet the requirements set by the original author. It is now under the [GNU GPL v3](http://www.gnu.org/licenses/gpl-3.0.html) license, so if you wish to use it in a commercial project, you need to pay an [appropriate fee](http://www.pchart.net/license).

Contributing:
=============

[](#contributing)

All in all, this is a legacy library ported over from PHP 4, so the code is neither beautiful nor easy to understand. I did my best to modernize and cover it with some basic tests, but there is much more that could be done. If you are willing and have time to fix or improve anything, feel free to post a PR or issue.

Installation (via Composer):
============================

[](#installation-via-composer)

For composer installation, add:

```
"require": {
    "szymach/c-pchart": "^3.0"
},
```

to your composer.json file and update your dependencies. Or you can run:

```
$ composer require szymach/c-pchart
```

in your project's root directory.

Usage:
======

[](#usage)

Your best source to understanding how to use the library is still the [official wiki](http://wiki.pchart.net/). However, I have ported at least one example for each chart into Markdown files, so you can compare each version and figure out how to use the current implementation.

Charts created through Image class
----------------------------------

[](#charts-created-through-image-class)

Most of the basic charts are created through methods of the `CpChart\Image`class. Below you can find a full list of these charts, alongside example code.

- [area](resources/doc/area.md)
- [bar](resources/doc/bar.md)
- [best fit](resources/doc/best_fit.md)
- [filled spline](resources/doc/filled_spline.md)
- [filled step](resources/doc/filled_step.md)
- [line](resources/doc/line.md)
- [plot](resources/doc/plot.md)
- [progress](resources/doc/progress.md)
- [spline](resources/doc/spline.md)
- [stacked area](resources/doc/stacked_area.md)
- [stacked bar](resources/doc/stacked_bar.md)
- [step](resources/doc/step.md)
- [zone](resources/doc/zone.md)

Standalone charts:
------------------

[](#standalone-charts)

The more advanced charts have their own separate class you need to use in order to create them. As before, below is a full list of these, with example code.

- [2D pie](resources/doc/2d_pie.md)
- [3D pie](resources/doc/3d_pie.md)
- [2D ring](resources/doc/2d_ring.md)
- [3D ring](resources/doc/3d_ring.md)
- [bubble](resources/doc/bubble.md)
- [contour](resources/doc/contour.md)
- [polar](resources/doc/polar.md)
- [radar](resources/doc/radar.md)
- [scatter best fit](resources/doc/scatter_best_fit.md)
- [scatter line](resources/doc/scatter_line.md)
- [scatter plot](resources/doc/scatter_plot.md)
- [scatter spline](resources/doc/scatter_spline.md)
- [scatter threshold](resources/doc/scatter_threshold.md)
- [scatter threshold area](resources/doc/scatter_threshold_area.md)
- [split path](resources/doc/split_path.md)
- [spring](resources/doc/spring.md)
- [stock](resources/doc/stock.md)
- [surface](resources/doc/surface.md)

Barcodes
--------

[](#barcodes)

The pChart library also provides a way to render barcodes 39 and 128. Below you can find links to doc on creating them:

- [barcode39](resources/doc/barcode_39.md)
- [barcode128](resources/doc/barcode_128.md)

Cache
-----

[](#cache)

If you find yourself creating charts out of a set of data more than once, you may consider using the cache component of the library. Head on to the [dedicated part](resources/doc/cache.md)of the documentation for information on how to do that.

Fonts and palletes
------------------

[](#fonts-and-palletes)

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`).

References
==========

[](#references)

[The original pChart website](http://www.pchart.net/)

Links
=====

[](#links)

[GitHub](https://github.com/szymach/c-pchart)

[Packagist](https://packagist.org/packages/szymach/c-pchart)

###  Health Score

35

—

LowBetter than 81% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity22

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 82.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~77 days

Recently: every ~103 days

Total

33

Last Release

1823d ago

Major Versions

2.0.0 → v3.0.02017-07-01

v2.0.9 → v3.0.22017-07-15

v2.0.10 → v3.0.42017-08-21

v2.0.11 → v3.0.52017-11-25

2.0.x-dev → v3.0.72018-11-22

PHP version history (3 changes)1.1.1PHP &gt;=5.3.3

2.0.1PHP &gt;=5.5

2.0.4PHP &gt;=5.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/9814ee88009324b3f4f81f865ce70e7ab07009765870e7e840d5f550d329a971?d=identicon)[jacksmithcb](/maintainers/jacksmithcb)

---

Top Contributors

[![szymach](https://avatars.githubusercontent.com/u/2230556?v=4)](https://github.com/szymach "szymach (174 commits)")[![kodasnarl](https://avatars.githubusercontent.com/u/51690574?v=4)](https://github.com/kodasnarl "kodasnarl (12 commits)")[![magnusjt](https://avatars.githubusercontent.com/u/5463727?v=4)](https://github.com/magnusjt "magnusjt (7 commits)")[![ThaDafinser](https://avatars.githubusercontent.com/u/533017?v=4)](https://github.com/ThaDafinser "ThaDafinser (5 commits)")[![jamesleesaunders](https://avatars.githubusercontent.com/u/13055416?v=4)](https://github.com/jamesleesaunders "jamesleesaunders (3 commits)")[![ywarnier](https://avatars.githubusercontent.com/u/609839?v=4)](https://github.com/ywarnier "ywarnier (2 commits)")[![caugner](https://avatars.githubusercontent.com/u/495429?v=4)](https://github.com/caugner "caugner (2 commits)")[![bowlofeggs](https://avatars.githubusercontent.com/u/354506?v=4)](https://github.com/bowlofeggs "bowlofeggs (2 commits)")[![subtronic](https://avatars.githubusercontent.com/u/1489572?v=4)](https://github.com/subtronic "subtronic (1 commits)")[![iansltx](https://avatars.githubusercontent.com/u/472804?v=4)](https://github.com/iansltx "iansltx (1 commits)")[![funkjedi](https://avatars.githubusercontent.com/u/9314?v=4)](https://github.com/funkjedi "funkjedi (1 commits)")[![rage28](https://avatars.githubusercontent.com/u/1128700?v=4)](https://github.com/rage28 "rage28 (1 commits)")

---

Tags

statisticschartspchartc-pChartCpChart

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/kodasnarl-c-pchart/health.svg)

```
[![Health](https://phpackages.com/badges/kodasnarl-c-pchart/health.svg)](https://phpackages.com/packages/kodasnarl-c-pchart)
```

###  Alternatives

[szymach/c-pchart

Port of "pChart" library into PHP 8+

1592.2M6](/packages/szymach-c-pchart)[markrogoyski/math-php

Math Library for PHP. Features descriptive statistics and regressions; Continuous and discrete probability distributions; Linear algebra with matrices and vectors, Numerical analysis; special mathematical functions; Algebra

2.4k6.9M36](/packages/markrogoyski-math-php)[wnx/laravel-stats

Get insights about your Laravel Project

1.8k1.7M7](/packages/wnx-laravel-stats)[khill/lavacharts

PHP wrapper library for the Google Chart API

6201.9M2](/packages/khill-lavacharts)[ghunti/highcharts-php

A php wrapper for highcharts and highstock javascript libraries

3642.3M5](/packages/ghunti-highcharts-php)[rubix/tensor

A library and extension that provides objects for scientific computing in PHP.

2691.4M5](/packages/rubix-tensor)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
