Skip to content

Commit e2d439e

Browse files
authored
Merge pull request #1 from macocci7/dev_1.0.0
Dev 1.0.0
2 parents 4a11bee + 6c9af58 commit e2d439e

23 files changed

Lines changed: 3186 additions & 1 deletion

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/vendor/

README.md

Lines changed: 295 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,295 @@
1-
# PHP-Scatterplot
1+
# PHP-Scatterplot
2+
3+
PHP-Scatterplot is a tool for creating scatter plots.
4+
5+
You can also retrieve parsed data:
6+
7+
Mean, Variance, Standard Deviation, Covariance,
8+
9+
Correlation Coefficient and Regression Line Formula.
10+
11+
<img src="example/img/ChangingProperties.png" width="400" />
12+
13+
## Contents
14+
15+
- [Installation](#installation)
16+
- [Usage](#usage)
17+
- [Basic Usage](#basic-usage)
18+
- [Using Layers](#using-layers)
19+
- [Changing Properties](#changing-properties)
20+
- [Parsed Data](#parsed-data)
21+
- [Example](#example)
22+
- [License](#license)
23+
24+
## Installation
25+
26+
```bash
27+
composer require macocci7/php-scatterplot
28+
```
29+
30+
## Usage
31+
32+
### Basic Usage
33+
34+
- PHP
35+
36+
```php
37+
<?php
38+
require('../vendor/autoload.php');
39+
40+
use Macocci7\PhpScatterplot\Scatterplot;
41+
42+
$sp = new Scatterplot();
43+
44+
$layers = [
45+
[
46+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
47+
'y' => [1,2,3,4,5,8,4,7,11,9,1],
48+
],
49+
];
50+
51+
$sp->layers($layers)
52+
->create('img/BasicUsage.png');
53+
```
54+
55+
- Result
56+
57+
<img src="example/img/BasicUsage.png" width="400" />
58+
59+
### Using Layers
60+
61+
- PHP
62+
63+
```php
64+
<?php
65+
require('../vendor/autoload.php');
66+
67+
use Macocci7\PhpScatterplot\Scatterplot;
68+
69+
$sp = new Scatterplot();
70+
71+
$layers = [
72+
'John' => [
73+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
74+
'y' => [1,2,3,4,5,8,4,7,11,9,1],
75+
],
76+
'Jake' => [
77+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
78+
'y' => [11,8,10,7,9,6,5,3,4,2,1],
79+
],
80+
'Hugo' => [
81+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
82+
'y' => [4,8,10,1,9,6,5,3,7,1,11],
83+
],
84+
'Alex' => [
85+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
86+
'y' => [3,5,11,4,8,2,9,10,1,11,7],
87+
],
88+
];
89+
90+
$legends = array_keys($layers);
91+
92+
$sp->layers($layers)
93+
->create('img/UsingLayers.png');
94+
```
95+
96+
- Result
97+
98+
<img src="example/img/UsingLayers.png" width="400" />
99+
100+
### Changing Properties
101+
102+
- PHP
103+
104+
```php
105+
<?php
106+
require('../vendor/autoload.php');
107+
108+
use Macocci7\PhpScatterplot\Scatterplot;
109+
110+
$sp = new Scatterplot();
111+
112+
$layers = [
113+
'John' => [
114+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
115+
'y' => [1,2,3,4,5,8,4,7,11,9,1],
116+
],
117+
'Jake' => [
118+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
119+
'y' => [11,8,10,7,9,6,5,3,4,2,1],
120+
],
121+
'Hugo' => [
122+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
123+
'y' => [4,8,10,1,9,6,5,3,7,1,11],
124+
],
125+
'Alex' => [
126+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
127+
'y' => [3,5,11,4,8,2,9,10,1,11,7],
128+
],
129+
];
130+
131+
$legends = array_keys($layers);
132+
133+
$sp->layers($layers)
134+
->limitX(0, 12)
135+
->limitY(0, 12)
136+
->gridXPitch(2)
137+
->gridYPitch(2)
138+
->bgcolor('#ccccff')
139+
->colors(['#ffffff'])
140+
->plotSize(4)
141+
->fontColor('#333333')
142+
->grid(1, '#999999')
143+
->gridXOn()
144+
->gridYOn()
145+
->regressionLine(3, ['#666666', '#cc2222', '#2222cc', '#22cc22'])
146+
->referenceLineX(1.5, 1, '#00ccff')
147+
->referenceLineY(1.5, 1, '#00ccff')
148+
->specificationLimitX(0.5, 11.5, 1, '#ff00ff')
149+
->specificationLimitY(0.5, 11.5, 1, '#ff00ff')
150+
->labelX('DATA X')
151+
->labelY('DATA Y')
152+
->caption('SCATTER PLOT')
153+
->legends($legends)
154+
->create('img/ChangingProperties.png');
155+
```
156+
157+
- Result
158+
159+
<img src="example/img/ChangingProperties.png" width="400" />
160+
161+
### Parsed Data
162+
163+
- PHP
164+
165+
```php
166+
<?php
167+
require('../vendor/autoload.php');
168+
169+
use Macocci7\PhpScatterplot\Analyzer;
170+
171+
$a = new Analyzer();
172+
173+
$layers = [
174+
'John' => [
175+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
176+
'y' => [1,2,3,4,5,8,4,7,11,9,1],
177+
],
178+
'Jake' => [
179+
'x' => [1,2,3,4,5,6,7,8,9,10,11],
180+
'y' => [11,8,10,7,9,6,5,3,4,2,1],
181+
],
182+
];
183+
184+
var_dump($a->parse($layers));
185+
```
186+
187+
- Result
188+
189+
```bash
190+
array(2) {
191+
["John"]=>
192+
array(6) {
193+
["count"]=>
194+
int(11)
195+
["x"]=>
196+
array(5) {
197+
["Mean"]=>
198+
int(6)
199+
["Max"]=>
200+
int(11)
201+
["Min"]=>
202+
int(1)
203+
["Variance"]=>
204+
int(10)
205+
["StandardDeviation"]=>
206+
float(3.1622776601683795)
207+
}
208+
["y"]=>
209+
array(5) {
210+
["Mean"]=>
211+
int(5)
212+
["Max"]=>
213+
int(11)
214+
["Min"]=>
215+
int(1)
216+
["Variance"]=>
217+
float(10.181818181818182)
218+
["StandardDeviation"]=>
219+
float(3.1908961408698624)
220+
}
221+
["Covariance"]=>
222+
float(5.181818181818182)
223+
["CorrelationCoefficient"]=>
224+
float(0.5135343537364686)
225+
["RegressionLineFormula"]=>
226+
array(2) {
227+
["a"]=>
228+
float(0.5181818181818182)
229+
["b"]=>
230+
float(1.8909090909090907)
231+
}
232+
}
233+
["Jake"]=>
234+
array(6) {
235+
["count"]=>
236+
int(11)
237+
["x"]=>
238+
array(5) {
239+
["Mean"]=>
240+
int(6)
241+
["Max"]=>
242+
int(11)
243+
["Min"]=>
244+
int(1)
245+
["Variance"]=>
246+
int(10)
247+
["StandardDeviation"]=>
248+
float(3.1622776601683795)
249+
}
250+
["y"]=>
251+
array(5) {
252+
["Mean"]=>
253+
int(6)
254+
["Max"]=>
255+
int(11)
256+
["Min"]=>
257+
int(1)
258+
["Variance"]=>
259+
int(10)
260+
["StandardDeviation"]=>
261+
float(3.1622776601683795)
262+
}
263+
["Covariance"]=>
264+
float(-9.454545454545455)
265+
["CorrelationCoefficient"]=>
266+
float(-0.9454545454545453)
267+
["RegressionLineFormula"]=>
268+
array(2) {
269+
["a"]=>
270+
float(-0.9454545454545455)
271+
["b"]=>
272+
float(11.672727272727274)
273+
}
274+
}
275+
}
276+
```
277+
278+
## Example
279+
280+
- [BasicUsage.php](example/BasicUsage.php) >> results in [BasicUsage.md](example/BasicUsage.md)
281+
- [UsingLayers.php](example/UsingLayers.php) >> results in [UsingLayers.md](example/UsingLayers.md)
282+
- [ChangingProperties.php](example/ChangingProperties.php) >> results in [ChangingProperties.md](example/ChangingProperties.md)
283+
- [ParsedData.php](example/ParsedData.php) >> results in [ParsedData.txt](example/ParsedData.txt)
284+
285+
## License
286+
287+
[MIT](LICENSE)
288+
289+
***
290+
291+
*Document written: 2023/06/06*
292+
293+
*Document updated: 2023/06/07*
294+
295+
Copyright 2023 macocci7.

composer.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "macocci7/php-scatterplot",
3+
"description": "it's easy to use for creating scatter plots.",
4+
"version": "1.0.0",
5+
"type": "library",
6+
"license": "MIT",
7+
"autoload": {
8+
"psr-4": {
9+
"Macocci7\\PhpScatterplot\\": "src/"
10+
}
11+
},
12+
"authors": [
13+
{
14+
"name": "macocci7",
15+
"email": "macocci7@yahoo.co.jp"
16+
}
17+
],
18+
"minimum-stability": "stable",
19+
"require": {
20+
"intervention/image": "^2.7",
21+
"macocci7/php-frequency-table": "^1.1"
22+
}
23+
}

0 commit comments

Comments
 (0)