-
Notifications
You must be signed in to change notification settings - Fork 3
/
advanced-line-chart.php
129 lines (124 loc) · 3.92 KB
/
advanced-line-chart.php
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
use Maantje\Charts\Annotations\PointAnnotation;
use Maantje\Charts\Annotations\XAxis\XAxisLineAnnotation;
use Maantje\Charts\Annotations\XAxis\XAxisRangeAnnotation;
use Maantje\Charts\Annotations\YAxis\YAxisLineAnnotation;
use Maantje\Charts\Annotations\YAxis\YAxisRangeAnnotation;
use Maantje\Charts\Chart;
use Maantje\Charts\Formatter;
use Maantje\Charts\Line\Line;
use Maantje\Charts\Line\Lines;
use Maantje\Charts\Line\Point;
use Maantje\Charts\XAxis;
use Maantje\Charts\YAxis;
require '../vendor/autoload.php';
$chart = new Chart(
yAxis: [
new YAxis(
name: 'celsius',
title: 'Temperature',
color: 'red',
minValue: 30,
maxValue: 50,
annotations: [
new YAxisLineAnnotation(
y: 48,
color: 'red',
size: 3,
dash: '20,20',
label: 'Critical Hot',
textLeftMargin: 3
),
new YAxisRangeAnnotation(
y1: 39,
y2: 48,
color: 'red',
label: 'Too hot',
),
new YAxisRangeAnnotation(
y1: 36,
y2: 39,
color: 'green',
label: 'Ideal',
),
new YAxisRangeAnnotation(
y1: 36,
y2: 32,
color: 'blue',
label: 'Too cold',
),
new YAxisLineAnnotation(
y: 32,
color: 'blue',
size: 3,
dash: '20,20',
label: 'Critical Cold',
textLeftMargin: 3
),
],
),
new YAxis(
name: 'elevation',
title: 'Elevation',
minValue: 0,
maxValue: 3000,
labelMargin: 10,
annotations: [
new PointAnnotation(
x: 1725331334 + 3600,
y: 2000,
markerSize: 10,
markerBackgroundColor: 'white',
markerBorderColor: 'red',
markerBorderWidth: 4,
label: 'Point annotation',
),
],
formatter: Formatter::template(':value m')
),
],
xAxis: new XAxis(
title: 'Time',
annotations: [
new XAxisLineAnnotation(
x: 1725331334 + 3600 + 1800,
color: 'green',
label: 'Halfway',
textLeftMargin: -2
),
new XAxisRangeAnnotation(
x1: 1725331334 + 3600 + 3600,
x2: 1725331334 + 3600 + 3600 + 3600,
color: 'blue',
label: 'Last hour',
),
],
formatter: Formatter::timestamp(),
),
series: [
new Lines(
lines: [
new Line(
[
new Point(y: 37.3, x: 1725331334),
new Point(y: 37.8, x: 1725331334 + 3600),
new Point(y: 38, x: 1725331334 + 3600 + 3600),
new Point(y: 42.2, x: 1725331334 + 3600 + 3600 + 3600),
],
yAxis: 'celsius',
lineColor: '#FF0000',
),
new Line(
[
new Point(y: 0, x: 1725331334),
new Point(y: 900, x: 1725331334 + 3600),
new Point(y: 1800, x: 1725331334 + 3600 + 3600),
new Point(y: 2200, x: 1725331334 + 3600 + 3600 + 3600),
],
yAxis: 'elevation',
),
]
),
],
);
echo $chart->render();