Skip to content

Commit

Permalink
Update documentation & version & test with last merged PR
Browse files Browse the repository at this point in the history
  • Loading branch information
davaxi committed Jan 13, 2020
1 parent a4812a1 commit f501acd
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 13 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
}
```

Expand Down Expand Up @@ -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);
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
20 changes: 10 additions & 10 deletions tests/SparklineTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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()
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit f501acd

Please sign in to comment.