Skip to content

Commit 6c9af58

Browse files
committed
Release 1.0.0
1 parent 6e29aeb commit 6c9af58

8 files changed

Lines changed: 41 additions & 49 deletions

File tree

Outline.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Correlation Coefficient and Regression Line Formula.
1717
- [Basic Usage](#basic-usage)
1818
- [Using Layers](#using-layers)
1919
- [Changing Properties](#changing-properties)
20+
- [Parsed Data](#parsed-data)
2021
- [Example](#example)
2122
- [License](#license)
2223

@@ -135,13 +136,13 @@ composer require macocci7/php-scatterplot
135136
->gridXPitch(2)
136137
->gridYPitch(2)
137138
->bgcolor('#ccccff')
138-
->color('#ffffff')
139+
->colors(['#ffffff'])
139140
->plotSize(4)
140141
->fontColor('#333333')
141142
->grid(1, '#999999')
142143
->gridXOn()
143144
->gridYOn()
144-
->regressionLine(3, '#cc2222')
145+
->regressionLine(3, ['#666666', '#cc2222', '#2222cc', '#22cc22'])
145146
->referenceLineX(1.5, 1, '#00ccff')
146147
->referenceLineY(1.5, 1, '#00ccff')
147148
->specificationLimitX(0.5, 11.5, 1, '#ff00ff')
@@ -165,9 +166,9 @@ composer require macocci7/php-scatterplot
165166
<?php
166167
require('../vendor/autoload.php');
167168

168-
use Macocci7\PhpScatterplot\Scatterplot;
169+
use Macocci7\PhpScatterplot\Analyzer;
169170

170-
$sp = new Scatterplot();
171+
$a = new Analyzer();
171172

172173
$layers = [
173174
'John' => [
@@ -180,7 +181,7 @@ composer require macocci7/php-scatterplot
180181
],
181182
];
182183

183-
var_dump($sp->parse($layers));
184+
var_dump($a->parse($layers));
184185
```
185186

186187
- Result
@@ -289,6 +290,6 @@ composer require macocci7/php-scatterplot
289290

290291
*Document written: 2023/06/06*
291292

292-
*Document updated: 2023/06/06*
293+
*Document updated: 2023/06/07*
293294

294295
Copyright 2023 macocci7.

example/ChangingProperties.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
|legends|[John, Jake, Hugo, Alex]|
6161
|legendWidth|100|
6262
|legendFontSize|10|
63-
|colors|[#3333cc, #cc3333, #339933, #33cccc, #cc3333, #ffcc33, #cccc33, #cc33cc]|
63+
|colors|[#ffffff, #cc3333, #339933, #33cccc, #cc3333, #ffcc33, #cccc33, #cc33cc]|
6464
</details>
6565

6666
<details><summary>Regression Line Formula</summary>

example/ChangingProperties.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
->gridXPitch(2)
3333
->gridYPitch(2)
3434
->bgcolor('#ccccff')
35-
->color('#ffffff')
35+
->colors(['#ffffff'])
3636
->plotSize(4)
3737
->fontColor('#333333')
3838
->grid(1, '#999999')
3939
->gridXOn()
4040
->gridYOn()
41-
->regressionLine(3, '#cc2222')
41+
->regressionLine(3, ['#666666', '#cc2222', '#2222cc', '#22cc22'])
4242
->referenceLineX(1.5, 1, '#00ccff')
4343
->referenceLineY(1.5, 1, '#00ccff')
4444
->specificationLimitX(0.5, 11.5, 1, '#ff00ff')

example/ParsedData.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
<?php
22
require('../vendor/autoload.php');
33

4-
use Macocci7\PhpScatterplot\Scatterplot;
4+
use Macocci7\PhpScatterplot\Analyzer;
55

6-
$sp = new Scatterplot();
6+
$a = new Analyzer();
77

88
$layers = [
99
'John' => [
@@ -16,4 +16,4 @@
1616
],
1717
];
1818

19-
var_dump($sp->parse($layers));
19+
var_dump($a->parse($layers));

example/img/ChangingProperties.png

-798 Bytes
Loading

src/Plotter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Plotter extends Analyzer
3737
protected $yLimitUpper;
3838
protected $yLimitLower;
3939
protected $plotDiameter = 2;
40-
protected $plotColor = '#000000';
40+
protected $plotColors = '#000000';
4141
protected $fontPath = 'fonts/ipaexg.ttf'; // IPA ex Gothic 00401
4242
//protected $fontPath = 'fonts/ipaexm.ttf'; // IPA ex Mincho 00401
4343
protected $fontSize = 16;

src/Scatterplot.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,18 @@ public function gridYPitch($pitch)
219219

220220
/**
221221
* sets the color of dots
222-
* @param string $color
222+
* @param array $color
223223
* @return self
224224
*/
225-
public function color($color)
225+
public function colors($colors)
226226
{
227-
if (!$this->isColorCode($color)) return;
228-
$this->plotColor = $color;
227+
if (!is_array($colors)) return;
228+
foreach ($colors as $index => $color) {
229+
if (!is_int($index)) return;
230+
if ($index < 0 || $index > LIMIT_LAYERS) return;
231+
if (!$this->isColorCode($color)) return;
232+
$this->colors[$index] = $color;
233+
}
229234
return $this;
230235
}
231236

@@ -374,17 +379,22 @@ public function specificationLimitY($lower, $upper, $width = 1, $color = '#ff00f
374379
/**
375380
* sets the width and color of the regression line
376381
* @param integer $width
377-
* @param string $color
382+
* @param array $color
378383
* @return self
379384
*/
380-
public function regressionLine($width, $color)
385+
public function regressionLine($width, $colors)
381386
{
382387
if (!is_int($width)) return;
383388
if ($width < 1) return;
384-
if (!$this->isColorCode($color)) return;
389+
if (!is_array($colors)) return;
390+
foreach ($colors as $index => $color) {
391+
if (!is_int($index)) return;
392+
if ($index < 0 || $index > LIMIT_LAYERS) return;
393+
if (!$this->isColorCode($color)) return;
394+
$this->regressionLineColors[$index] = $color;
395+
}
385396
$this->regressionLine = true;
386397
$this->regressionLineWidth = $width;
387-
$this->regressionLineColor = $color;
388398
return $this;
389399
}
390400

@@ -567,6 +577,15 @@ public function specificationLimitsOff()
567577
return $this;
568578
}
569579

580+
/**
581+
* sets regression line on
582+
*/
583+
public function regressionLineOn()
584+
{
585+
$this->regressionLine = true;
586+
return $this;
587+
}
588+
570589
/**
571590
* sets regression line off
572591
* @param

0 commit comments

Comments
 (0)