vitopedro/laravel-chartjs 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

vitopedro/laravel-chartjs

Composer 安装命令:

composer require vitopedro/laravel-chartjs

包简介

chartjs wrapper for laravel

README 文档

README

This is a wrapper of chart.js in php to be used in Laravel Framework.

This component offers an easy and fast interface to add charts to a lavaravel application.

Setup

Installation

Install it via composer with the command:

composer require vitopedro/laravel-chartjs

Configuration

1 - Add the service provider to your application in your configuration file that is normally under config/app.php

...
/*
 * Application Service Providers...
 */
...
App\Providers\EventServiceProvider::class,
App\Providers\RouteServiceProvider::class,

vitopedro\chartjs\ChartjsServiceProvider::class,
...

2 - Test your application with php artisan serve, if it has errors, reset your composer qutoload with:

composer dump-autoload

3 - Publish the public assets with the the command:

php artisan vendor:publish --tag=public --force

if everything worked correctlly, you will have in your application's public folder a folder vitopedro\chartjs

Usage

Include the class coresponding to the chart type nedeed, the minimum requirement for a chart to properlly render is to set the labels and the series. It is also recommended to set the title, but not mandatory.

Line/Area/Column

Those chart types are similar and can be used interchangeblly to represent the same set of data. In those types, the labels correspond to the points in the x axix of the chart and are required to properlly render the data. The series corresponds to the data itself, and it is an array containing in each position a label and a data positions. The label is to be used in the legend and in the tooltip of the chart, the data should be an array of numbers and should have the same length that labels has.

Examples

Line chart

use vitopedro\chartjs\LineChart;

$line = new LineChart();
$line->setTitle("this is a title");
$line->setLabels(['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange']);
$line->setSeries([
    [
        'label' => 'data 1',
        'data' => [12, 19, 3, 5, 2, 3],
    ],
    [
        'label' => 'data 2',
        'data' => [10, 15, 3, 5, 2, 3],
    ],
]);
echo $line->render();

alt Line chart example

Area chart

use vitopedro\chartjs\AreaChart;

$area = new AreaChart();
$area->setTitle("this is a title");
$area->setLabels(['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange']);
$area->setSeries([
    [
        'label' => 'data 1',
        'data' => [12, 19, 3, 5, 2, 3],
    ],
    [
        'label' => 'data 2',
        'data' => [10, 15, 3, 5, 2, 3],
    ],
]);
echo $area->render();

alt Area chart example

Column chart

use vitopedro\chartjs\ColumnChart;

$column = new ColumnChart();
$column->setTitle("this is a title");
$column->setLabels(['Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange']);
$column->setSeries([
    [
        'label' => 'data 1',
        'data' => [12, 19, 3, 5, 2, 3],
    ],
    [
        'label' => 'data 2',
        'data' => [10, 15, 3, 5, 2, 3],
    ],
]);
echo $column->render();

alt Column chart example

Pie

This chart type differs from the the previous ones, since it doesnt have x axix. In here the labels correspond to the legend or tooltip of each value. To create a pure pie chart only one serie should be used, if multiple series are passed to the setSeries function, multiple circles will be rendered. In the series, the label must also be sent in order to maintain consistency, but it is not rendered anywhere.

Example

use vitopedro\chartjs\PieChart;

$pie = new PieChart();
$pie->setTitle("this is a title");
$pie->setLabels([
    'Red', 'Blue', 'Yellow', 'Green', 'Purple', 'Orange',
]);
$pie->setSeries([
    [
        'label' => 'data 1',
        'data' => [
            12, 19, 3, 5, 2, 3,
        ],
    ],
]);
return $pie->render();

alt Pie chart example

vitopedro/laravel-chartjs 适用场景与选型建议

vitopedro/laravel-chartjs 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 422 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 11 月 28 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 vitopedro/laravel-chartjs 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 422
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-28