forked from nickn17/evDashVisualizer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsvggraph.php
More file actions
90 lines (69 loc) · 3.07 KB
/
svggraph.php
File metadata and controls
90 lines (69 loc) · 3.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
require 'SVGGraph/autoloader.php';
function geoRevLoc ($lat, $lon)
{
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "TileProxy/1.0");
curl_setopt($ch, CURLOPT_URL, "https://nominatim.openstreetmap.org/reverse?lat=$lat&lon=$lon&format=json&accept-language=sk");
$place = curl_exec($ch);
curl_close($ch);
$place = "[" . $place . "]";
$place = json_decode($place, true);
// print_r($place);
$amenity = isset($place[0]['address']['amenity']) ? $place[0]['address']['amenity'] . ', ' : '';
$road = isset($place[0]['address']['road']) ? $place[0]['address']['road'] : '';
$house_number = isset($place[0]['address']['house_number']) ? ' ' . $place[0]['address']['house_number'] . ', ' : ', ';
$city = isset($place[0]['address']['city']) ? $place[0]['address']['city'] :
( isset($place[0]['address']['town']) ? $place[0]['address']['town'] :
( isset($place[0]['address']['village']) ? $place[0]['address']['village'] : '' ));
return ($amenity.$road.$house_number.$city);
}
$settings = [
'auto_fit' => true,
'thousands' => ' ',
'decimal' => ',',
// 'datetime_keys' => true,
// 'structured_data' => true,
'back_colour' => '#fff',
// 'back_stroke_width' => 0,
// 'back_stroke_colour' => '#eee',
// 'stroke_colour' => '#000',
// 'axis_colour' => '#333',
'axis_overlap' => 2,
'grid_colour' => '#666',
'label_colour' => '#000',
'axis_font' => 'Verdana',
'axis_font_size' => 10,
'label_v' => 'nabíjací výkon [kW]',
// 'label_colour_v' => 'blue',
// 'units_y' => 'kW',
'axis_min_h' => 0,
'axis_max_h' => 100,
'label_h' => '% SOC',
'minimum_grid_spacing' => 20,
'show_subdivisions' => true,
'show_grid_subdivisions' => true,
// 'grid_subdivision_colour' => '#ccc',
'line_stroke_width' => 1,
'marker_size' => 2,
'legend_entry_height' => 10,
'legend_position' => 'outer bottom 5 -5',
'legend_stroke_width' => 0,
'legend_shadow_opacity' => 0,
];
$markers = "circle square triangle cross x pentagon diamond hexagon octagon asterisk star threestar fourstar eightstar";
$settings['marker_type'] = explode(' ', $markers);
$mode = LiveData::MODE_DRIVE;
foreach ($this->jsonData as $row) {
if ($row === false)
continue;
if ($row['odoKm'] <= 0)
continue;
$mode = LiveData::MODE_DRIVE;
}
$settings['pad_bottom']= 5 + 16 * count ($data);
$graph = new Goat1000\SVGGraph\SVGGraph(960, 520, $settings);
$graph->values($data);
echo $graph->fetch('MultiLineGraph', false);
?>