Skip to content

tylernathanreed/nova-gantt-metric

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Nova Gantt Metric

Adds Gantt metrics to your Nova application

Latest Stable Version Total Downloads

Introduction

This package implements a new type of metric, being specifically for showing high level timelines using a Gantt Chart.

Here's some examples of the metric being used in the wild:

Tasks

Installation

Use composer require reedware/nova-gantt-metric.

Usage

<?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'
        ];
    }
}