GithubHelp home page GithubHelp logo

laravel-gantt's Introduction

Laravel Gantt Chart

License

A Laravel 5.x package to display items within a Gantt chart (adapted from bastianallgeier/gantti).

Screenshot

Installation

Require this package with composer:

composer require swatkins/laravel-gantt

After updating composer, add the ServiceProvider to the providers array in config/app.php

Swatkins\LaravelGantt\GanttServiceProvider::class,

Copy the package css file to your local css with the publish command:

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

Usage

The model to display in the Gantt Chart will need to have properties of label, start and end at minimum.

  • label is the string to display for the item
  • start is a date or datetime (will need to pass this as a YYYY-MM-DD format)
  • end is a date or datetime (will need to pass this as a YYYY-MM-DD format)
/**
 *  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 Swatkins\LaravelGantt\Gantt($test_array, array(
    'title'      => 'Demo',
    'cellwidth'  => 25,
    'cellheight' => 35
));

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

Display in your view

In your view, add the gantt.css file:

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

And then output the gantt HTML:

{!! $gantt !!}

Model Factory

Here is a factory for creating test data for your projects. You can paste this into your database/factories/ModelFactory.php file and then run this via tinker. See https://laravel.com/docs/5.2/seeding#using-model-factories.

$factory->define(App\Project::class, function (Faker\Generator $faker) {
    return [
        'title' => $faker->sentence(),
        'start' => $faker->dateTimeBetween('-30 days'),
        'end' => $faker->dateTimeBetween('now', '+30 days')
    ];
});

Attribution

This code is adapted from https://github.com/bastianallgeier/gantti

License:

MIT License - http://www.opensource.org/licenses/mit-license.php

laravel-gantt's People

Contributors

q76762 avatar swatkins avatar

Stargazers

 avatar Jade Edward avatar

Watchers

James Cloos avatar A. avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.