CpChart

A modern PHP 8 port of the pChart library for generating charts, graphs, and statistics images.

Library
Composer
vv3.1.1
151stars
GNU GPLv3

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
46/100Fair
Development Activity0
Maintenance32
Community72
Maturity60
Momentum20

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
63/100Good
Architecture66
Code Quality68
Innovation55
Learning Curve60

CpChart is a maintained port of Jean-Damien Pogolotti’s pChart statistics library, bringing Composer support, PSR standards, namespaces and type hints to a proven PHP charting engine. It renders line, bar, pie, radar, scatter, stock, bubble and other chart types as images using the GD extension, plus barcodes and cached output.

The library keeps broad backward compatibility with the original pChart API while modernizing the code so it runs cleanly on PHP 8+. It is aimed at server-side chart generation where you need a self-contained, dependency-light way to produce chart images without a JavaScript front end.

What You Get

  • A broad catalog of chart types - line, bar, pie, radar, scatter, bubble, stock, spring, surface and more
  • Barcode generation alongside the charting classes
  • PSR-4 autoloading, namespaces and type hints over the original pChart codebase
  • A built-in cache layer for reusing rendered chart output

Common Use Cases

  • Generating chart images on the server for emails, PDFs or reports where client-side JS charts are unavailable
  • Producing statistical graphics in dashboards and admin panels driven by PHP
  • Rendering barcodes and data visualizations as static image assets

Under The Hood

Architecture - The library is organized under the CpChart namespace with core classes Image, Draw, BaseDraw, Data and Cache, plus a Chart subnamespace holding one class per chart type (Pie, Radar, Scatter, Bubble, Stock, Surface, Spring, Split, Indicator) and a Barcode subnamespace. You build a Data object, hand it to an Image or a specific chart class, call drawing methods, then render to a file or stream via GD. Fonts, palettes and resources live under a resources directory loaded through constants.php.

Tech Stack - Pure PHP requiring PHP 8.0+ and the GD extension, installed via Composer with PSR-4 autoloading and a files entry for constants. Dev tooling includes Codeception and PHPUnit for tests, PHP_CodeSniffer for style, and PHPStan configs for static analysis.

Code Quality - As a port of legacy pChart, the drawing internals are procedural in places, but the maintainer has layered PSR standards, namespaces, type hints and a test suite (tests/unit) plus PHPStan analysis on top. The project is explicitly in maintenance mode: bug fixes and PRs are accepted but no new features are planned.

API Design - The API mirrors the original pChart, so existing pChart knowledge transfers directly; newcomers work through the README examples for the Image class and standalone chart classes. Some boilerplate is needed to configure data, scales and drawing options, typical of imperative charting libraries.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search