定制 nggiahao/laravel-dashboard-chart-tile 二次开发

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

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

nggiahao/laravel-dashboard-chart-tile

Composer 安装命令:

composer require nggiahao/laravel-dashboard-chart-tile

包简介

Generic chart tiles for laravel dashboard

README 文档

README

Latest Version on Packagist GitHub Workflow Status (with branch) Codecov Twitter Follow

Show off your charting skills with this easy to use tile. Supports line, bar, pie, doughnut and many more!

Preview

Installation

You can install the package via composer:

composer require fidum/laravel-dashboard-chart-tile

Usage

In the dashboard config file, you can optionally add this configuration in the tiles key.

// in config/dashboard.php
return [
    // ...
    'tiles' => [
        'charts' => [     
            'refresh_interval_in_seconds' => 300, // Default: 300 seconds (5 minutes)
        ],
    ],
];

This tile uses chart.js to render the charts with the help of Laravel Charts package see links to documentation for both below:

So that you can easily add your datasets and configure your charts exactly how you want them you need to create a chart class that implements the Fidum\ChartTile\Contracts\ChartFactory interface.

See chart example below:

namespace App\Charts;

use Carbon\Carbon;
use Fidum\ChartTile\Charts\Chart;
use Fidum\ChartTile\Contracts\ChartFactory;

class ExampleBarChart implements ChartFactory
{
    public static function make(array $settings): ChartFactory
    {
        return new static;
    }

    public function chart(): Chart
    {
        $date = Carbon::now()->subMonth()->startOfDay();

        $data = collect(range(0, 12))->map(function ($days) use ($date) {
            return [
                'x' => $date->clone()->addDays($days)->toDateString(),
                'y' => rand(100, 500),
            ];
        });

        $chart = (new Chart)
            ->labels($data->pluck('x')->toArray())
            ->options([
                  'responsive' => true,
                  'maintainAspectRatio' => false,
                  // etc...
             ], true);

        $chart->dataset('Example Data', 'bar', $data->toArray())
            ->backgroundColor('#848584');

        return $chart;
    }
}

In your dashboard view you can use the below component as many times as needed. Pass your chart class reference to the component and that will be used to generate the chart.

<x-dashboard>
    <livewire:chart-tile chartFactory="{{App\Charts\DailyUsersChart::class}}" position="a1:a3" />
</x-dashboard>

Optional properties:

  • chartFilters optional key value array of settings that is passed to your chart static::make method. Only use this for passing simple values strings, integers, arrays etc. To use this you will have to use @livewire syntax over the component syntax in order set the array value.
@livewire('chart-tile', [
    'chartFactory' => App\Charts\DailyUsersChart::class, 
    'chartFilters' => ['type' => 'customer'],
])
  • height sets the height of the chart, depending on your dashboard layout you may need to adjust this (defaults to 100%).

  • refreshIntervalInSeconds use this to override the refresh rate of an individual tile (defaults to 300 seconds)

Examples

We have provided some chart factory examples to help get you started here. You can use the below dashboard layout to have an instant showcase of these examples:

<x-dashboard>
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExamplePieChart::class}}" position="a1:a2" height="140%"/>
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExampleDoughnutChart::class}}" position="b1:b2" height="140%"/>
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExamplePieChart::class}}" position="c1:c2" height="140%" />
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExampleDoughnutChart::class}}" position="d1:d2" height="140%" />
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExampleBarChart::class}}" position="a3:b4" />
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExampleLineChart::class}}" position="c3:d4" />
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExampleLineChart::class}}" position="a5:b6" />
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExampleBarChart::class}}" position="c5:d6" />
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExampleBarChart::class}}" position="a7:b8" />
    <livewire:chart-tile chartFactory="{{\Fidum\ChartTile\Examples\ExampleLineChart::class}}" position="c7:d8" />
</x-dashboard>

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email :author_email instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

nggiahao/laravel-dashboard-chart-tile 适用场景与选型建议

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

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

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

围绕 nggiahao/laravel-dashboard-chart-tile 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2023-11-21