micbelmelo/laravel-gantt

Laravel 包,用于在甘特图中显示项目。

1.0.2 2024-07-21 14:49 UTC

This package is auto-updated.

Last update: 2024-09-21 15:07:49 UTC


README

安装

使用 composer 安装此包

composer require michelmelo/laravel-gantt

更新 composer 后,将 ServiceProvider 添加到 config/app.php 中的 providers 数组

MichelMelo\LaravelGantt\GanttServiceProvider::class,

使用发布命令将包的 css 文件复制到您本地的 css 目录

php artisan vendor:publish --tag="gantt"

用法

要在甘特图中显示的模型至少需要具有 labelstartend 属性。

  • label 是用于显示项目的字符串
  • start 是日期或日期时间(需要以 YYYY-MM-DD 格式传递)
  • end 是日期或日期时间(需要以 YYYY-MM-DD 格式传递)
/**
 *  You'll pass data as an array in this format:
    $test_array = [
                      [
                        'label' => 'The item title',
                          'date' => [
                             [
                                 'start' => '2016-10-08',
                                 'end'   => '2016-10-14',
                                 'class' => '',
                             ],
                             [
                                 'start' => '2016-10-16',
                                 'end'   => '2016-10-19',
                                 'class' => '',
                             ]
                         ]
 
                     ]
                 ];
 */
 
$gantt = new MichelMelo\LaravelGantt\Gantt($test_array, array(
    'title'      => 'Demo',
    'cellwidth'  => 25,
    'cellheight' => 35
));

return view('gantt')->with([ 'gantt' => $gantt ]);

在视图中显示

在视图中,添加 gantt.css 文件

<link href="/vendor/michelmelo/gantt/css/gantt.css" rel="stylesheet" type="text/css">

然后输出甘特图 HTML

{!! $gantt !!}