Package Data | |
---|---|
Maintainer Username: | gfazioli |
Maintainer Contact: | giovambattista.fazioli@gmail.com (Giovambattista Fazioli) |
Package Create Date: | 2016-10-19 |
Package Last Update: | 2017-03-06 |
Home Page: | http://gfazioli.github.io/Laravel-Morris-PHP/ |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-19 03:14:44 |
Package Statistics | |
---|---|
Total Downloads: | 2,430 |
Monthly Downloads: | 3 |
Daily Downloads: | 0 |
Total Stars: | 3 |
Total Watchers: | 2 |
Total Forks: | 0 |
Total Open Issues: | 1 |
Laravel Morris PHP is the version for Laravel of MorrisPHP With this Service Provider, you can draw amazing char by usign Morris.js.
composer require gfazioli/laravel-morris-php
We include service providers and a facade for easy integration and a nice syntax for Laravel.
Firstly, add the gfazioli\Morris\MorrisServiceProvider
provider to the providers array in config/app.php
'providers' => [
...
gfazioli\Morris\MorrisServiceProvider::class,
],
and then add the facade to your aliases
array
'aliases' => [
...
'Morris' => gfazioli\Morris\Facades\MorrisFacade::class,
],
Remember to include the following Javascript and styles before use Morris.
<!-- Morris -->
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.css">
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/morris.js/0.5.1/morris.min.js"></script>
<div id="morris-area"></div>
<?php
echo Morris::area( 'morris-area' )
->xkey( [ 'y' ] )
->ykeys( [ 'a', 'b' ] )
->labels( [ 'Series A', 'Series B' ] )
->hoverCallback( 'function(index, options, content){var row = options.data[index];return "sin(" + row.x + ") = " + row.y;}' )
->data( [
[ "y" => '2006', "a" => 100, "b" => 90 ],
[ "y" => '2007', "a" => 75, "b" => 65 ],
[ "y" => '2008', "a" => 50, "b" => 40 ],
[ "y" => '2009', "a" => 75, "b" => 65 ],
[ "y" => '2010', "a" => 50, "b" => 40 ],
[ "y" => '2011', "a" => 75, "b" => 65 ],
[ "y" => '2012', "a" => 100, "b" => 90 ]
] );
<div id="morris-bar"></div>
<?php
echo Morris::bar( 'morris-bar' )
->xkey( [ 'y' ] )
->ykeys( [ 'a', 'b' ] )
->labels( [ 'Series A', 'Series B' ] )
->data( [
[ "y" => '2006', "a" => 100, "b" => 90 ],
[ "y" => '2007', "a" => 75, "b" => 65 ],
[ "y" => '2008', "a" => 50, "b" => 40 ],
[ "y" => '2009', "a" => 75, "b" => 65 ],
[ "y" => '2010', "a" => 50, "b" => 40 ],
[ "y" => '2011', "a" => 75, "b" => 65 ],
[ "y" => '2012', "a" => 100, "b" => 90 ]
] );
<div id="morris-donut"></div>
<?php
echo Morris::donut( 'morris-donut' )
->data( [
[ "label" => "Download Sales", "value" => 12 ],
[ "label" => "In-Store Sales", "value" => 30 ],
[ "label" => "Mail-Order Sales", "value" => 20 ]
] );
<div id="morris-line"></div>
<?php
echo Morris::line( 'morris-line' )
->xkey( [ 'date' ] )
->ykeys( [ 'value' ] )
->labels( [ 'Money' ] )
->data( [
[ 'date' => '2010', 'value' => 88 ],
[ 'date' => '2011', 'value' => 18 ],
[ 'date' => '2012', 'value' => 28 ],
[ 'date' => '2013', 'value' => 48 ],
] );