-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #65 from halfpastfouram/dev
Release v1.2.2
- Loading branch information
Showing
10 changed files
with
167 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
require_once '../../vendor/autoload.php'; | ||
|
||
use Halfpastfour\PHPChartJS\Chart\Bar; | ||
|
||
$bar = new Bar(); | ||
$bar->setId('myChart'); | ||
|
||
// Set labels | ||
$bar->labels()->exchangeArray(["M", "T", "W", "T", "F", "S", "S"]); | ||
|
||
// Add Datasets | ||
$apples = $bar->createDataSet(); | ||
|
||
$apples->setLabel("apples") | ||
->setBackgroundColor("rgba( 0, 150, 0, .5 )") | ||
->data()->exchangeArray([12, 19, 3, 17, 28, 24, 7]); | ||
$bar->addDataSet($apples); | ||
|
||
$oranges = $bar->createDataSet(); | ||
$oranges->setLabel("oranges") | ||
->setBackgroundColor('rgba( 255, 153, 0, .5 )') | ||
->data()->exchangeArray([30, 29, 5, 5, 20, 3, 10]); | ||
$oranges->setHidden(true); | ||
$bar->addDataSet($oranges); | ||
|
||
?> | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<title>Bar</title> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script> | ||
</head> | ||
<body> | ||
<?php | ||
// Render the chart | ||
echo $bar->render(); | ||
?> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
namespace Test; | ||
|
||
use Halfpastfour\PHPChartJS\Chart\Bar; | ||
use Halfpastfour\PHPChartJS\ChartOwnedInterface; | ||
use Halfpastfour\PHPChartJS\Options; | ||
use PHPUnit_Framework_TestCase; | ||
|
||
/** | ||
* Class ChartOwnedTest | ||
* | ||
* @package Test | ||
*/ | ||
class ChartOwnedTest extends PHPUnit_Framework_TestCase | ||
{ | ||
/** | ||
* | ||
*/ | ||
public function testSetOwner() | ||
{ | ||
$options = new Options(); | ||
$this->assertNull($options->owner(), 'Owner should be empty'); | ||
|
||
$this->assertSame($options, $options->setOwner($bar = new Bar())); | ||
$this->assertSame($bar, $options->owner()); | ||
} | ||
|
||
/** | ||
* | ||
*/ | ||
public function testOwnerFromChart() | ||
{ | ||
$bar = new Bar(); | ||
$this->assertInstanceOf(ChartOwnedInterface::class, $bar->options()); | ||
$this->assertSame($bar, $bar->options()->owner()); | ||
|
||
$this->assertInstanceOf(ChartOwnedInterface::class, $dataSet = $bar->createDataSet()); | ||
$this->assertSame($dataSet->owner(), $bar); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters