diff --git a/README.md b/README.md index ced173a..ededa46 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ This page contains information about installing the Library for PHP. ### Requirements -- PHP version 5.3.0 or greater +- PHP version 5.4.0 or greater - The GD PHP extension ### Obtaining the client library @@ -29,7 +29,7 @@ You can install the library by adding it as a dependency to your composer.json. ```json "require": { - "davaxi/sparkline": "^1.1" + "davaxi/sparkline": "^1.2" } ``` @@ -140,6 +140,36 @@ $sparkline->save('/your/path/to/save/picture'); $sparkline->destroy(); // Destroy picture after generated / displayed / saved ``` +### Multiple sparkline series +```php +$sparkline = new Davaxi\Sparkline(); + +// For add series +$sparkline->addSeries([0,1,2,3]); +$sparkline->addSeries([2,3,5,6]); + +// Or +$sparkline->setData( + [0,1,2,3], + [2,3,5,6] +); +// For add point on series +$sparkline->addPoint('first', 3, '#efefef', 0); // Add point on series 0 +$sparkline->addPoint('last', 3, '#efefef', 1); // add point on series 1 + +// For fill colors, specify on last argument series index's +$sparkline->setFillColorHex('#8b1c2b', 0); +$sparkline->setFillColorHex('#8bdddf', 1); +// or +$sparkline->setFillColorRGB(139, 28, 43, 0); +$sparkline->setFillColorRGB(139, 28, 55, 1); + +// For line colors, specify on last argument series index's +$sparkline->setLineColorHex('#1c628b', 0); +$sparkline->setLineColorHex('#1c62df', 1); +// or +$sparkline->setLineColorRGB(28, 98, 139, 0); +$sparkline->setLineColorRGB(28, 98, 55, 1); \ No newline at end of file diff --git a/composer.json b/composer.json index cf23cdd..965bfc6 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { "name": "davaxi/sparkline", "description": "PHP Class (using GD) to generate sparklines", - "version": "1.1.2", + "version": "1.2.0", "type": "library", "keywords": [ "sparkline", diff --git a/tests/SparklineTest.php b/tests/SparklineTest.php index 877dd11..5d98249 100644 --- a/tests/SparklineTest.php +++ b/tests/SparklineTest.php @@ -160,18 +160,18 @@ public function testSetLineColorHex() { $this->sparkline->setLineColorHex('#0f354b'); $color = $this->sparkline->getAttribute('lineColor'); - $this->assertEquals([15, 53, 75], $color); + $this->assertEquals([[15, 53, 75]], $color); $this->sparkline->setLineColorHex('#666'); $color = $this->sparkline->getAttribute('lineColor'); - $this->assertEquals([102, 102, 102], $color); + $this->assertEquals([[102, 102, 102]], $color); } public function testSetLineColorRGB() { $this->sparkline->setLineColorRGB(123, 233, 199); $color = $this->sparkline->getAttribute('lineColor'); - $this->assertEquals([123, 233, 199], $color); + $this->assertEquals([[123, 233, 199]], $color); } /** @@ -186,18 +186,18 @@ public function testSetFillColorHex() { $this->sparkline->setFillColorHex('#0f354b'); $color = $this->sparkline->getAttribute('fillColor'); - $this->assertEquals([15, 53, 75], $color); + $this->assertEquals([[15, 53, 75]], $color); $this->sparkline->setFillColorHex('#666'); $color = $this->sparkline->getAttribute('fillColor'); - $this->assertEquals([102, 102, 102], $color); + $this->assertEquals([[102, 102, 102]], $color); } public function testSetFillColorRGB() { $this->sparkline->setFillColorRGB(123, 233, 199); $color = $this->sparkline->getAttribute('fillColor'); - $this->assertEquals([123, 233, 199], $color); + $this->assertEquals([[123, 233, 199]], $color); } public function testSetLineThickness() @@ -211,19 +211,19 @@ public function testSetData() { $this->sparkline->setData([]); $data = $this->sparkline->getAttribute('data'); - $this->assertEquals([0,0], $data); + $this->assertEquals([[0,0]], $data); $this->sparkline->setData([1]); $data = $this->sparkline->getAttribute('data'); - $this->assertEquals([1,1], $data); + $this->assertEquals([[1,1]], $data); $this->sparkline->setData([1, 2]); $data = $this->sparkline->getAttribute('data'); - $this->assertEquals([1,2], $data); + $this->assertEquals([[1,2]], $data); $this->sparkline->setData([1, 3, 5]); $data = $this->sparkline->getAttribute('data'); - $this->assertEquals([1, 3, 5], $data); + $this->assertEquals([[1, 3, 5]], $data); } /**