定制 amenadiel/jpgraph 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

amenadiel/jpgraph

Composer 安装命令:

composer require amenadiel/jpgraph

包简介

Composer Friendly, full refactor of JpGraph, library to make graphs and charts

README 文档

README

JpGraph Community Edition was created as a Composer friendly port of JpGraph v3.5. With time and through incremental refactorings, it became a whole different library, with PSR-1 and PSR-2 compliant codebase, namespaces and folder hierarchy enabling PSR-4 autoloading, and more.

We are now, at most, distant cousins with the current official release.

Refactoring is an ongoing effort and we ensure editions and additions don't hurt our (already poor) metrics

Scrutinizer Code Quality

What is JPGraph Community Edition?

As can be seen in their releases section, there was a six year pause in JPGraph release cycle, during which some of us had no choice but to code our way out of PHP 5.x. And thus "Community Edition" was born. From then on, this library evolved on its own and completely diverged from the official packages.

In general terms, JPGraph CE relies in PHP's thriving ecosystem. We aim to be a simple dependency you can seamlessly integrate in your app. JPGraph CE aligns with PHP Standards Reccomendations as published by the PHP Framework Interoperability Group, and when presented with the choice, will always pick an agnostic implementation over custom ones that reinvent the wheel. A lot of code has been trimmed and refactored with this purpose and a lot more is waiting to undergo such a change.

  • Distrbution through PHP's popular Packagist Registry
  • Relies in Composer, so you don't need to manually download or copy anything, nor check for platform and dependency requirements yourself.
  • PSR-4: Autoloader compliant structure. No need to resort to require or include in your code.
  • Sensible fallbacks to handle missing fonts or particular GD version features availability.
  • IDE friendly, allowing for autocompletion and go-to-definition where supported.
  • Integration pipelines checking new releases compatibility against different PHP versions
  • New or refactored code is expected to observe PSR-1 and PSR-2 coding standards (Eventually PSR-12 as well).

Comparing against the original v3.5 codebase, we also stripped examples or incomplete implementation of graph types exclusive to v3.5 pro (e.g. Barcodes).

Things that JPGraph CE is NOT

  • This library is NOT an official JPGraph package. The offcial package can be downloaded at JPGraph's downloads section of their website. They have a full featured free version with support for current and olver PHP versions.
  • Endorsed in any way by JPGraph's creator company Asial
  • A composer enabled wrapper for the official package
  • A drop-in replacement for the official package. We do not claim nor offer any kind of feature parity with the official package.

Requirements And Installation

This version requires PHP v7.2.0+. If you need to install this library package in older PHP environments please try

  • Upgrading your PHP installation. (No, really, even PHP 7.2 is past its EOL)
  • for PHP v7.0+ please try release v4.0.x
  • for PHP v5.6+ please check release v3.6.x

Install it Using composer

composer require amenadiel/jpgraph:^4

How to use

See the examples folder for working samples.

The examples work the same way you should use this library:

  • run composer install

  • require vendor/autoload.php it the top of your script

  • generate a graph with a snippet like the following

   require_once 'PATH/TO/vendor/autoload.php';

   use Amenadiel\JpGraph\Graph;
   use Amenadiel\JpGraph\Plot;

   // Create the Pie Graph.
   $graph = new Graph\PieGraph(350, 250);
   $graph->title->Set("A Simple Pie Plot");
   $graph->SetBox(true);

   $data = array(40, 21, 17, 14, 23);
   $p1   = new Plot\PiePlot($data);
   $p1->ShowBorder();
   $p1->SetColor('black');
   $p1->SetSliceColors(array('#1E90FF', '#2E8B57', '#ADFF2F', '#DC143C', '#BA55D3'));

   $graph->Add($p1);
   $graph->Stroke();
  • important make sure to instance the Graph (or Graph child class) before its content (for example, Plots). Doing this will load the global configuration to the global scope. Yeah, we know we are polluting the global scope with dozens of constants, but we are still refactoring 🤷 .

See the examples working by performing the following steps:

  • run composer install
  • run make start or php -S localhost:8000 -t Examples
  • Open your browser at http://localhost:8000

Change the config

You can override some configs set on config.inc.php by creating a .env file in your project root. See .env.example as a reference.

Contributors ✨

All Contributors

Thanks goes to these wonderful people (emoji key):


Sean Zhang

💻

Shawn McCool

💻

Vinicius Dias

💻

Paul van der Knaap

💻

Florent Morselli

💻

Tony Murray

💻

Andreas

💻

Corey Watts

💻

Alexander Rakushin

💻

Muhammad Abid

💻

WhileTrue

🐛

This project follows the all-contributors specification. Contributions of any kind welcome!

Wishlist

  • Get all the examples working (half of them have yet to be transformed from the old code to the new PSR-4 format)
  • Add more tests (We need to test more classes and methods besides the ones in the examples, as well as perform more assetions on the current tests)
  • Add alternative use of imagick

jpgraph_logo

Similar Projects

License

FOSSA Status

amenadiel/jpgraph 适用场景与选型建议

amenadiel/jpgraph 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.35M 次下载、GitHub Stars 达 149, 最近一次更新时间为 2015 年 07 月 27 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「data」 「graph」 「chart」 「pie」 「jpgraph」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 amenadiel/jpgraph 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 amenadiel/jpgraph 我们能提供哪些服务?
定制开发 / 二次开发

基于 amenadiel/jpgraph 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 2.35M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 153
  • 点击次数: 30
  • 依赖项目数: 9
  • 推荐数: 1

GitHub 信息

  • Stars: 149
  • Watchers: 20
  • Forks: 58
  • 开发语言: PHP

其他信息

  • 授权协议: QPL-1.0
  • 更新时间: 2015-07-27