Lavacharts is a graphing / charting library for PHP 5.4+ that wraps Google's Javascript Chart API.
null
which enables support for Gantt charts to have linked sections.JavascriptDate
class which is an (hacky) alias for the Javascript Date object. (I really just wanted to be able to copy and paste Google examples into my tests and DataTables)Short Example:
use Khill\Lavacharts\Support\JavascriptDate as Date;
$daysToMilliseconds = function ($days) {
return $days * 24 * 60 * 60 * 1000;
};
$data = $lava->DataTable();
$data->addColumn('string', 'Task ID');
$data->addColumn('string', 'Task Name');
$data->addColumn('date', 'Start Date');
$data->addColumn('date', 'End Date');
$data->addColumn('number', 'Duration');
$data->addColumn('number', 'Percent Complete');
$data->addColumn('string', 'Dependencies');
$data->addRows([
['Research', 'Find sources',
new Date(2015, 0, 1), new Date(2015, 0, 5), null, 100, null],
['Write', 'Write paper',
null, new Date(2015, 0, 9), $daysToMilliseconds(3), 25, 'Research,Outline'],
['Cite', 'Create bibliography',
null, new Date(2015, 0, 7), $daysToMilliseconds(1), 20, 'Research'],
['Complete', 'Hand in paper',
null, new Date(2015, 0, 10), $daysToMilliseconds(1), 0, 'Cite,Write'],
['Outline', 'Outline paper',
null, new Date(2015, 0, 6), $daysToMilliseconds(1), 100, 'Research']
]);
Releasing the Symfony Bundle (again) to re-enable support for all the new chart types and the renderAll
I don't know how I accidentally removed the Symfony folder, but it's back now.
I have had this "ready" for months but have procrastinated long enough. I will fix bugs as they arise, but there have been advancements that are worth releasing.
Here is a short example of the usage of the 'domain' role:
/**
* Example implementation of the 'domain' column role:
*
* @link https://developers.google.com/chart/interactive/docs/roles
*
* label: '2009, Quarter', '2009, Sales', '2009, Expenses', '2008, Quarter', '2008, Sales', '2008, Expenses'
* role: domain, data, data, domain, data, data
* 'Q1/09', 1000, 400, 'Q1/08', 800, 300
* 'Q2/09', 1170, 460, 'Q2/08', 750, 400
* 'Q3/09', 660, 1120, 'Q3/08', 700, 540
* 'Q4/09', 1030, 540, 'Q4/08', 820, 620
*
*/
use \Khill\Lavacharts\Lavacharts;
$lava = new Lavacharts;
$table = $lava->DataTable();
$table->addStringColumn('2009, Quarter', null, 'domain')
->addNumberColumn('2009, Sales')
->addNumberColumn('2009, Expenses')
->addStringColumn('2008, Quarter', null, 'domain')
->addNumberColumn('2008, Sales')
->addNumberColumn('2008, Expenses')
->addRow(['Q1/09', 1000, 400, 'Q1/08', 800, 300])
->addRow(['Q2/09', 1170, 460, 'Q2/08', 750, 400])
->addRow(['Q3/09', 660, 1120, 'Q3/08', 700, 540])
->addRow(['Q4/09', 1030, 540, 'Q4/08', 820, 620]);
$lava->LineChart('Money', $table, [
'width'=> 400,
'height'=> 240,
'legend'=>'right',
'focusTarget'=> 'category'
]);
Adding support for objects that implement Traversable and ArrayAccess to be passed into the addRows()
method
Refactored the LavachartsServiceProvider to use singleton
over share
since it was removed in Laravel 5.4
Fixed the missing ")" bug. Defensively removing the "()" as well to support version Laravel 5.3 and below.
Fixing bug where TreeMap was not in list of chartClasses