Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • kevinkhill/lavacharts
  • Helg18/lavacharts
2 results
Show changes
Commits on Source (3)
- 3.1.9
- Fixing bug where using `setOptions` instead of the constructor skipped the processing of `png` and `material` attributes.
- 3.1.8
- Production build of the Lava.js module.
- 3.1.7
- Added the tag lavacharts to the config publishing.
Use `php artisan vendor:publish --tag=lavacharts`
If that does not work, try to clear the cache with `php artisan config:clear` and re-publish with `--force`.
- 3.1.6
- The event callback within lava.js was modified to pass back the chart and the datatable so users can interact with either during an event. This solves issue [#203](https://github.com/kevinkhill/lavacharts/issues/203)
- 3.1.5
- Adding DonutChart alias class back
- 3.1.4
- Chart's should resize properly on page resize.
- 3.1.3
- Adding support for date columns to be null which enables support for Gantt charts to have linked sections.
- Adding JavascriptDate class that mimics the way the Javascript Date object is created. (I wanted to be able to copy and paste google's examples into addRows)
- 3.1.1 & 3.1.2
Loading
Loading
# Contributors
Thank you for finding bugs, helping me fix them, pull requests, issues and anything else.
- [deringer](https://github.com/deringer)
- [MicahKV](micah138@yahoo.com)
- [rajivseelam](https://github.com/rajivseelam)
- [SendDerek](https://github.com/SendDerek)
- [stevebauman](https://github.com/stevebauman)
- [Stonos](https://github.com/Stonos)
- [tobias-kuendig](https://github.com/tobias-kuendig)
- [twify93](https://github.com/twify93)
If your name is not on this list and needs to be, I'm sorry! Please add it in a pull request and I will merge it in.
# Lavacharts 3.1.8
# Lavacharts 3.1.9
 
[![Total Downloads](https://img.shields.io/packagist/dt/khill/lavacharts.svg?style=plastic)](https://packagist.org/packages/khill/lavacharts)
[![License](https://img.shields.io/packagist/l/khill/lavacharts.svg?style=plastic)](http://opensource.org/licenses/MIT)
Loading
Loading
@@ -59,7 +59,11 @@ If you are using Lavacharts with Silex, Lumen or your own Composer project, that
## Laravel
To integrate Lavacharts into Laravel, a ServiceProvider has been included.
 
### Laravel 5.x
### Laravel ~5.5
Thanks to the fantastic new [Package Auto-Discovery](https://laravel-news.com/package-auto-discovery) feature added in 5.5, you're ready to go, no extra configuration required :)
### Laravel ~5.4
Register Lavacharts in your app by adding these lines to the respective arrays found in `config/app.php`:
```php
<?php
Loading
Loading
@@ -84,7 +88,7 @@ To modify the default configuration of Lavacharts, datetime formats for datatabl
Publish the configuration with `php artisan vendor:publish --tag=lavacharts`
 
 
### Laravel 4.x
### Laravel ~4
Register Lavacharts in your app by adding these lines to the respective arrays found in `app/config/app.php`:
 
```php
Loading
Loading
Loading
Loading
@@ -15,46 +15,6 @@
"name": "Kevin Hill",
"email": "kevinkhill@gmail.com",
"role": "Creator"
},
{
"name": "twify93",
"homepage": "https://github.com/twify93",
"role": "Contributor"
},
{
"name": "SendDerek",
"homepage": "https://github.com/SendDerek",
"role": "Contributor"
},
{
"name": " MicahKV",
"email": "micah138@yahoo.com",
"role": "Contributor"
},
{
"name": "deringer",
"homepage": "https://github.com/deringer",
"role": "Contributor"
},
{
"name": "stevebauman",
"homepage": "https://github.com/stevebauman",
"role": "Contributor"
},
{
"name": "rajivseelam",
"homepage": "https://github.com/rajivseelam",
"role": "Contributor"
},
{
"name": "tobias-kuendig",
"homepage": "https://github.com/tobias-kuendig",
"role": "Contributor"
},
{
"name": "Stonos",
"homepage": "https://github.com/Stonos",
"role": "Contributor"
}
],
"support": {
Loading
Loading
@@ -79,7 +39,6 @@
},
"require-dev": {
"phpunit/phpunit": "~4.8",
"mybuilder/phpunit-accelerator": "~1.1",
"mockery/mockery": "~0.9",
"squizlabs/php_codesniffer": "~2.5",
"satooshi/php-coveralls": "~1.0",
Loading
Loading
@@ -100,5 +59,10 @@
"lavajs:pull" : "git subtree --prefix=javascript pull lavajs master",
"lavajs:push" : "git subtree --prefix=javascript push lavajs master"
},
"config": {
"platform": {
"php": "5.4"
}
},
"minimum-stability": "stable"
}
This diff is collapsed.
Loading
Loading
@@ -51,7 +51,6 @@
</logging>
 
<listeners>
<listener class="\MyBuilder\PhpunitAccelerator\TestListener" />
<listener class="\Mockery\Adapter\Phpunit\TestListener" />
</listeners>
</phpunit>
Loading
Loading
@@ -67,7 +67,7 @@ class ChartBuilder extends GenericBuilder
public function setType($type)
{
if (ChartFactory::isValidChart($type) === false) {
throw new InvalidChartType($type, ChartFactory::getChartTypes());
throw new InvalidChartType($type);
}
 
$this->type = $type;
Loading
Loading
Loading
Loading
@@ -6,6 +6,7 @@ use Khill\Lavacharts\Support\Customizable;
use Khill\Lavacharts\DataTables\DataTable;
use Khill\Lavacharts\Values\ElementId;
use Khill\Lavacharts\Values\Label;
use Khill\Lavacharts\Support\Traits\ElementIdTrait as HasElementId;
use Khill\Lavacharts\Support\Traits\DataTableTrait as HasDataTable;
use Khill\Lavacharts\Support\Traits\RenderableTrait as IsRenderable;
use Khill\Lavacharts\Support\Contracts\JsonableInterface as Jsonable;
Loading
Loading
@@ -50,11 +51,40 @@ class Chart extends Customizable implements Renderable, Wrappable, Jsonable, Vis
$this->label = $chartLabel;
$this->datatable = $datatable;
 
if (array_key_exists('elementId', $options)) {
$this->elementId = new ElementId($options['elementId']);
$this->setExtendedAttributes();
}
/**
* Set extended chart attributes from the assigned options, if present.
*
* @since 3.1.9
*/
protected function setExtendedAttributes()
{
if (array_key_exists('elementId', $this->options)) {
$this->setElementId($this->options['elementId']);
unset($this->options['elementId']);
}
if (method_exists($this, 'setPngOutput') &&
array_key_exists('png', $this->options))
{
$this->setPngOutput($this->options['png']);
unset($this->options['png']);
}
if (method_exists($this, 'setMaterialOutput') &&
array_key_exists('material', $this->options))
{
$this->setMaterialOutput($this->options['material']);
unset($this->options['material']);
}
}
 
/**
* Returns the chart type.
*
Loading
Loading
Loading
Loading
@@ -159,7 +159,13 @@ class DataFactory
$datatable = new DataTable();
 
foreach ($decodedJson['cols'] as $column) {
$datatable->addColumn($column['type'], $column['label']);
if (isset($column['label'])) {
$label = $column['label'];
} else {
$label = '';
}
$datatable->addColumn($column['type'], $label);
}
 
foreach ($decodedJson['rows'] as $row) {
Loading
Loading
Loading
Loading
@@ -753,6 +753,10 @@ class DataTable implements Jsonable, JsonSerializable
* @return bool
*/
protected function isValidTimezone($tz) {
if (! is_string($tz)) {
return false;
}
$timezoneList = call_user_func_array('array_merge', timezone_abbreviations_list());
 
$timezones = array_map(function ($timezone) {
Loading
Loading
Loading
Loading
@@ -2,14 +2,16 @@
 
namespace Khill\Lavacharts\Exceptions;
 
use Khill\Lavacharts\Charts\ChartFactory;
class InvalidChartType extends LavaException
{
public function __construct($invalidChart, array $validCharts)
public function __construct($invalidChart)
{
$badChart = (string) $invalidChart;
 
$message = "'$badChart' is not a valid chart type, must be one of ";
$message .= '[ ' . implode(' | ', $validCharts) . ']';
$message .= '[ ' . implode(' | ', ChartFactory::getChartTypes()) . ']';
 
parent::__construct($message);
}
Loading
Loading
Loading
Loading
@@ -12,6 +12,7 @@ use Khill\Lavacharts\Dashboards\Wrappers\ChartWrapper;
use Khill\Lavacharts\Dashboards\Wrappers\ControlWrapper;
use Khill\Lavacharts\DataTables\DataTable;
use Khill\Lavacharts\DataTables\Formats\Format;
use Khill\Lavacharts\Exceptions\InvalidElementId;
use Khill\Lavacharts\Exceptions\InvalidLabel;
use Khill\Lavacharts\Exceptions\InvalidLavaObject;
use Khill\Lavacharts\Javascript\ScriptManager;
Loading
Loading
@@ -355,12 +356,14 @@ class Lavacharts
{
$label = new Label($label);
 
if (is_string($elementId)) {
try {
$elementId = new ElementId($elementId);
} catch (InvalidElementId $e) {
$elementId = null;
}
 
if (is_array($elementId)) {
$div = $elementId; // @TODO allow missing element ids to use renderable instance's id
$div = $elementId;
}
 
if ($type == 'Dashboard') {
Loading
Loading
@@ -416,6 +419,10 @@ class Lavacharts
/** @var \Khill\Lavacharts\Charts\Chart $chart */
$chart = $this->volcano->get($type, $label);
 
if ($elementId === null) {
$elementId = $chart->getElementId();
}
if ($elementId instanceof ElementId) {
$chart->setElementId($elementId);
}
Loading
Loading
Loading
Loading
@@ -59,20 +59,30 @@ class Customizable implements \ArrayAccess, \JsonSerializable
*
* @param string $option
* @param mixed $value
* @return self
*/
public function setOption($option, $value)
{
$this->options[$option] = $value;
return $this;
}
 
/**
* Sets the values of the customized class with an array of key value pairs.
*
* @param array $options
* @return self
*/
public function setOptions(array $options)
{
$this->options = $options;
if (method_exists($this, 'setExtendedAttributes')) {
$this->setExtendedAttributes();
}
return $this;
}
 
/**
Loading
Loading
@@ -80,10 +90,13 @@ class Customizable implements \ArrayAccess, \JsonSerializable
*
* @since 3.0.5
* @param array $options
* @return self
*/
public function mergeOptions(array $options)
{
$this->options = array_merge($this->options, $options);
return $this;
}
 
/**
Loading
Loading
Loading
Loading
@@ -27,11 +27,11 @@ trait MaterialRenderableTrait
/**
* Sets the chart to be rendered as material design or classic.
*
* @param bool $png Sets the material render status.
* @param bool $material Sets the material render status.
*/
public function setMaterialOutput($png)
public function setMaterialOutput($material)
{
$this->material = $png;
$this->material = $material;
}
 
/**
Loading
Loading
Loading
Loading
@@ -2,10 +2,10 @@
 
namespace Khill\Lavacharts\Tests\Javascript;
 
use Khill\Lavacharts\Charts\LineChart;
use Khill\Lavacharts\Javascript\ChartJsFactory;
use Khill\Lavacharts\Tests\ProvidersTestCase;
use Khill\Lavacharts\DataTables\DataTable;
use Khill\Lavacharts\Javascript\JavascriptFactory;
 
/**
* @property \Mockery\Mock mockChartLabel
Loading
Loading
@@ -29,10 +29,15 @@ class ChartJsFactoryTest extends ProvidersTestCase
->addColumn('number')
->addRow([10101, 12345, 67890]);
 
$this->mlc = \Mockery::mock('Khill\Lavacharts\Charts\LineChart', [$this->mockChartLabel, $datatable, [
// $this->mlc = \Mockery::mock('Khill\Lavacharts\Charts\LineChart', [$this->mockChartLabel, $datatable, [
// 'elementId' => 'chart-div',
// 'legend' => 'none'
// ]])->makePartial();
$this->mlc = new LineChart($this->mockChartLabel, $datatable, [
'elementId' => 'chart-div',
'legend' => 'none'
]])->makePartial();
]);
 
$this->factory = new ChartJsFactory($this->mlc);
}
Loading
Loading
@@ -58,6 +63,6 @@ class ChartJsFactoryTest extends ProvidersTestCase
$this->assertEquals($templateVars['pngOutput'], false);
$this->assertEquals($templateVars['formats'], '');
$this->assertEquals($templateVars['events'], '');
$this->assertEquals($templateVars['chartOptions'], '{"elementId":"chart-div","legend":"none"}');
$this->assertEquals($templateVars['chartOptions'], '{"legend":"none"}');
}
}
Loading
Loading
@@ -121,15 +121,15 @@ class LavachartsTest extends ProvidersTestCase
/**
* depends testCreateDataTableViaAlias
*/
public function testRenderChartWithNoElementIdAndDivNoDimensions()
public function testUseChartElementIdWhenMissingInRenderCall()
{
$this->lava->LineChart('test', $this->partialDataTable, [
'elementId' => 'test-div'
]);
 
$output = $this->lava->render('LineChart', 'test', true);
$output = $this->lava->render('LineChart', 'test');
 
$this->assertStringHasString($output, '<div id="test-div"></div>');
$this->assertStringHasString($output, '$chart.setElement(\'test-div\')');
}
 
/**
Loading
Loading
Loading
Loading
@@ -39,7 +39,7 @@ abstract class ProvidersTestCase extends \PHPUnit_Framework_TestCase
* @param $haystack
* @param $needle
*/
public function assetStringHasString($haystack, $needle)
public function assertStringHasString($haystack, $needle)
{
$this->assertTrue(strpos($haystack, $needle) !== false);
}
Loading
Loading