|
1 | 1 | <?php |
| 2 | + |
2 | 3 | require('../vendor/autoload.php'); |
3 | | -require('./class/CsvUtil.php'); |
4 | | -require('./class/Combination.php'); |
5 | 4 |
|
6 | | -use Macocci7\CsvUtil; |
7 | | -use Macocci7\Combination; |
8 | 5 | use Macocci7\PhpScatterplot\Scatterplot; |
| 6 | +use Macocci7\PhpCsv\Csv; |
| 7 | +use Macocci7\PhpCombination\Combination; |
9 | 8 |
|
10 | | -$cu = new CsvUtil(); |
| 9 | +$cu = new Csv('csv/weather_tokyo.csv'); |
11 | 10 | $cb = new Combination(); |
12 | 11 |
|
13 | | -$cu->load('csv/weather_tokyo.csv') |
14 | | - ->encode('SJIS', 'UTF-8') |
15 | | - ->offset(7); |
16 | | -$heads = $cu->heads(4); |
17 | | -$days = $cu->raw()->column(0); |
| 12 | +$cu->encode('SJIS', 'UTF-8') |
| 13 | + ->offsetRow(7); |
| 14 | +$heads = $cu->row(5); |
| 15 | +$days = $cu->raw()->column(1); |
18 | 16 |
|
19 | 17 | $dictionary = [ |
20 | 18 | '平均気温(℃)' => 'Mean Temperature(℃)', |
|
24 | 22 | '降水量の合計(mm)' => 'Precipitation Amount(mm)', |
25 | 23 | '平均現地気圧(hPa)' => 'Mean Local Air Pressure(hPa)', |
26 | 24 | ]; |
27 | | -$columns = [1, 4, 7, 10, 14, 21]; |
| 25 | +$columns = [2, 5, 8, 11, 15, 22]; |
28 | 26 | $parsed = []; |
29 | 27 | $pairs = $cb->pairs($columns); |
30 | 28 | foreach ($pairs as $index => $pair) { |
|
36 | 34 | 'y' => $cu->float()->column($y), |
37 | 35 | ], |
38 | 36 | ]; |
39 | | - |
| 37 | + |
40 | 38 | $sp = new Scatterplot(); |
41 | 39 | $sp->layers($layers) |
42 | 40 | ->regressionLineOn() |
|
50 | 48 | // Markdown ------------------------------------- |
51 | 49 |
|
52 | 50 | echo "# Scatterplot Matrix: Weather in Tokyo\n\n"; |
53 | | -echo "## Data Source\n\n<a href='https://www.data.jma.go.jp/gmd/risk/obsdl/' target='_blank'>Japan Meteorological Agency</a>\n\n"; |
| 51 | +echo "## Data Source\n\n" |
| 52 | + . "<a href='https://www.data.jma.go.jp/gmd/risk/obsdl/' target='_blank'>" |
| 53 | + . "Japan Meteorological Agency</a>\n\n"; |
54 | 54 | echo "## Period: " . $days[0] . '~' . $days[count($days) - 1] . "\n"; |
55 | 55 | $count = count($columns); |
56 | 56 | echo "<table>\n"; |
|
0 commit comments