xanpena/svg-chart-builder
最新稳定版本:1.3
Composer 安装命令:
composer require xanpena/svg-chart-builder
包简介
PHP SVG Chart Builder
README 文档
README
SVGChartBuilder is a PHP library that allows you to generate SVG-based charts for use in your backend applications.
Requirements
PHP 8.0 or later
Installation
You can install SVGChartBuilder via Composer:
To install using Composer, run the following command in your terminal:
composer require xanpena/svg-chart-builder
Usage
SVGChartBuilder provides several types of charts that you can create:
Example
To create a bar chart, use the following code:
- Tipo Bar chart
use Xanpena\SVGChartBuilder\SVGChartBuilder; $data = [ 16, 18, 40, // ... other data ... ]; $options = [ 'labels' => [ 'math', 'literature', 'english', // ... other data ... ], 'colors' => [ '#CDDC39', '#00BCD4', '#9E9E9E', // ... other data ... ], 'axisColors' => [ 'x' => 'red', 'y' => 'blue' ], 'labelsColor' => 'orange', 'dataColor' => 'white', ]; $chartBuilder = new SVGChartBuilder(SVGChartBuilder::CHART_TYPE_BAR, $data, $options); $svg = $chartBuilder->create(); echo $svg;
- Tipo Horizontal bar chart
use Xanpena\SVGChartBuilder\SVGChartBuilder; $data = [ 16, 18, 40, // ... other data ... ]; $options = [ 'labels' => [ 'math', 'literature', 'english', // ... other data ... ], 'colors' => [ '#CDDC39', '#00BCD4', '#9E9E9E', // ... other data ... ], 'axisColors' => [ 'x' => 'red', 'y' => 'blue' ], 'labelsColor' => 'orange', 'dataColor' => 'white', ]; $chartBuilder = new SVGChartBuilder(SVGChartBuilder::CHART_TYPE_HORIZONTALBAR, $data, $options); $svg = $chartBuilder->create(); echo $svg;
- Tipo Doughnut chart
use Xanpena\SVGChartBuilder\SVGChartBuilder; $data = [ 16, 18, 40, // ... other data ... ]; $options = [ 'labels' => [ 'math', 'literature', 'english', // ... other data ... ], 'colors' => [ '#CDDC39', '#00BCD4', '#9E9E9E', // ... other data ... ], 'labelsColor' => 'white' ]; $chartBuilder = new SVGChartBuilder(SVGChartBuilder::CHART_TYPE_DOUGHNUT, $data, $options); $svg = $chartBuilder->create(); echo $svg;
- Tipo Pie chart
use Xanpena\SVGChartBuilder\SVGChartBuilder; $data = [ 16, 18, 40, // ... other data ... ]; $options = [ 'labels' => [ 'math', 'literature', 'english', // ... other data ... ], 'colors' => [ '#CDDC39', '#00BCD4', '#9E9E9E', // ... other data ... ], 'labelsColor' => 'white' ]; $chartBuilder = new SVGChartBuilder(SVGChartBuilder::CHART_TYPE_PIE, $data, $options); $svg = $chartBuilder->create(); echo $svg;
- Tipo Line chart
use Xanpena\SVGChartBuilder\SVGChartBuilder; $data = [ 'math' => [ 11, 17, 15, // ... other data ... ], 'literature' => [ 21, 21, 23, // ... other data ... ], 'english' => [ 14, 9, 18, // ... other data ... ] // ... other data ... ]; $options = [ 'labels' => [ '2020/2021', '2021/2022', '2023/2024', // ... other data ... ], 'colors' => [ '#CDDC39', '#00BCD4', '#9E9E9E', // ... other data ... ], 'axisColors' => [ 'x' => 'red', 'y' => 'blue' ], 'labelsColor' => 'orange', ]; $chartBuilder = new SVGChartBuilder(SVGChartBuilder::CHART_TYPE_LINE, $data, $options); $svg = $chartBuilder->create(); echo $svg;
Chart Types
SVGChartBuilder supports the following chart types:
SVGChartBuilder::BAR_CHART: Bar chart
SVGChartBuilder::HORIZONTALBAR_CHART: Horizontal bar chart
SVGChartBuilder::DOUGHNUT_CHART: Doughnut chart
SVGChartBuilder::PIE_CHART: Pie chart
SVGChartBuilder::CHART_TYPE_LINE: Line chart
Changelog
Please see CHANGELOG for more information what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please using the issue tracker.
Credits
xanpena/svg-chart-builder 适用场景与选型建议
xanpena/svg-chart-builder 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.59k 次下载、GitHub Stars 达 1, 最近一次更新时间为 2023 年 08 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「pdf」 「charts」 「svg」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 xanpena/svg-chart-builder 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 xanpena/svg-chart-builder 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 xanpena/svg-chart-builder 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
The "View Counter" bundle
A Versatile and Expandable jQuery Plotting Plugin
PHP library for c3js
Draw charts with a simple API on Laravel
Laravel Service Provider for morris.js
Provides TCPDF integration for Symfony
统计信息
- 总下载量: 1.59k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-08-23