szymach/c-pchart
Composer 安装命令:
composer require szymach/c-pchart
包简介
Port of "pChart" library into PHP 8+
README 文档
README
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.
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.
If you require support for the unsupported PHP versions, you will need to use the
3.0.x versions. Starting from 3.1, only PHP 8.x versions are supported.
What was done:
-
Support for PHP
8.x. -
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 withthrowstatements. -
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. It is loaded automatically through Composer, so no need for manual action.
License:
It was previously stated that this package uses the 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.
UPDATE the official website is no longer active and I have had no success in trying to contact the original library developer. I have no idea how this translated to any legal actions you would have to perform in order to use this library in a commercial projects.
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):
For composer installation, add:
"require": { "szymach/c-pchart": "^3.1" },
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:
Your best source to understanding how to use the library is still the official wiki. 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
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
- bar
- best fit
- filled spline
- filled step
- line
- plot
- progress
- spline
- stacked area
- stacked bar
- step
- zone
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
- 3D pie
- 2D ring
- 3D ring
- bubble
- contour
- polar
- radar
- scatter best fit
- scatter line
- scatter plot
- scatter spline
- scatter threshold
- scatter threshold area
- split path
- spring
- stock
- surface
Barcodes
The pChart library also provides a way to render barcodes 39 and 128. Below you can find links to doc on creating them:
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 of the documentation for information on how to do that.
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
The original pChart website (no longer active)
Links
szymach/c-pchart 适用场景与选型建议
szymach/c-pchart 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.79M 次下载、GitHub Stars 达 151, 最近一次更新时间为 2014 年 04 月 24 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「charts」 「statistics」 「pchart」 「c-pChart」 「CpChart」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 szymach/c-pchart 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 szymach/c-pchart 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 szymach/c-pchart 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Helper to handle stats table with multiple formatter
The "View Counter" bundle
A Versatile and Expandable jQuery Plotting Plugin
SPSS is a php-based implementation of IBM SPSS Statistics Standard. (Read/write SPSS, PSPP .sav files)
PHP library for c3js
TYPO3 View-Statistics by coding.ms: Logs frontend actions in TYPO3 and displays them in a backend module. It tracks page views, news, downloads, and objects such as products or real estate, while custom objects can be configured via TypoScript. Frontend logins, login duration, user ID, IP address, a
统计信息
- 总下载量: 2.79M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 159
- 点击次数: 27
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: GPL-3.0-only
- 更新时间: 2014-04-24