reedware/nova-gantt-metric

为您的 Nova 应用程序添加甘特图指标。

v1.0.1 2020-09-12 13:46 UTC

This package is auto-updated.

Last update: 2024-09-07 21:19:38 UTC


README

为您的 Nova 应用程序添加甘特图指标

Latest Stable Version Total Downloads

简介

本包实现了一种新型指标,特别用于通过甘特图(Gantt 图)展示高级时间线。

以下是该指标在野外的使用示例

Tasks

安装

使用 composer require reedware/nova-gantt-metric

用法

<?php

namespace App\Nova\Metrics;

use Illuminate\Http\Request;
use Reedware\NovaGanttMetric\Gantt;

class MyExampleGantt extends Gantt
{
    /**
     * The element's component.
     *
     * @var string
     */
    public $component = 'gantt-metric';

    /**
     * The displayable name of the metric.
     *
     * @var string
     */
    public $name = 'Estimated Completion Date';

    /**
     * Calculate the value of the metric.
     *
     * @param  \Illuminate\Http\Request  $request
     *
     * @return mixed
     */
    public function calculate(Request $request)
    {
        $query = /* ... */;

        // This will group by the "label_name" column, and use the min
        // and max of the "date_column" values to create the chart
        // data. See Gantt@aggregate for additional features.

        return $this->spreadByDays($request, $query, 'label_name', 'date_column');
    }

    /**
     * Get the ranges available for the metric.
     *
     * @return array
     */
    public function ranges()
    {
        return [
            90 => 'Next 90 Days',
            180 => 'Next 180 Days',
            270 => 'Next 270 Days'
        ];
    }
}