/
Series.php
executable file
·228 lines (202 loc) · 6.84 KB
/
Series.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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php namespace Khill\Lavacharts\Configs;
/**
* Series Properties Object
*
* An object containing all the values for a single series in a multiple data
* set chart, which can be passed into the series property of the chart's options.
*
*
* @package Lavacharts
* @subpackage Configs
* @author Kevin Hill <kevinkhill@gmail.com>
* @copyright (c) 2015, KHill Designs
* @link http://github.com/kevinkhill/lavacharts GitHub Repository Page
* @link http://lavacharts.com Official Docs Site
* @license http://opensource.org/licenses/MIT MIT
*/
use Khill\Lavacharts\Utils;
use Khill\Lavacharts\Exceptions\InvalidConfigValue;
class Series extends ConfigObject
{
/**
* Alignment of the series.
*
* @var Annotation
*/
public $annotation;
/**
* Overrides the global curveType value for this series.
*
* @var string
*/
public $curveType;
/**
* Which axis is the target of the series definition.
*
* @var string
*/
public $targetAxisIndex;
/**
* Text style of the series.
*
* @var TextStyle
*/
public $textStyle;
/**
* The type of marker for this series.
*
* @var string
*/
public $type;
/**
* Builds the series object when passed an array of configuration options.
*
* @param array $config Options for the series
* @return Series
*/
public function __construct($config = array())
{
parent::__construct($this, $config);
}
/**
* An object to be applied to annotations for this series.
* This can be used to control, for instance, the textStyle for the series.
*
* @param Annotation Style of the series annotations
* @throws InvalidConfigValue
* @return Series
*/
public function annotation(Annotation $annotation)
{
if (Utils::isAnnotation($annotation)) {
$this->annotation = $annotation;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'annotation'
);
}
return $this;
}
/**
* Controls the curve of the lines when the line width is not zero.
*
* Can be one of the following:
* 'none' - Straight lines without curve.
* 'function' - The angles of the line will be smoothed.
*
* @param string $curveType
* @throws InvalidConfigValue
* @return Series
*/
public function curveType($curveType)
{
$values = array(
'none',
'function'
);
if (is_string($curveType) && in_array($curveType, $values)) {
$this->curveType = $curveType;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'string',
'with a value of '.Utils::arrayToPipedString($values)
);
}
return $this;
}
/**
* Which axis to assign this series to.
*
* 0 is the default axis, and 1 is the opposite axis.
*
* Default value is 0; set to 1 to define a chart where different series
* are rendered against different axes.
*
* At least one series much be allocated to the default axis.
* You can define a different scale for different axes.
*
* @param int $index
* @throws InvalidConfigValue
* @return Series
*/
public function targetAxisIndex($index)
{
if (is_int($index)) {
$this->targetAxisIndex = $index;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'int'
);
}
return $this;
}
/**
* The default line type for any series not specified in the series property.
* Available values are:
* 'line', 'area', 'bars', 'candlesticks' and 'steppedArea'
*
* @param string $type
* @throws InvalidConfigValue
* @return Series
*/
public function type($type)
{
$values = array(
'line',
'area',
'bars',
'candlesticks',
'steppedArea'
);
if (in_array($type, $values)) {
$this->type = $type;
} else {
throw new InvalidConfigValue(
__FUNCTION__,
'string',
'with a value of '.Utils::arrayToPipedString($values)
);
}
return $this;
}
/**
* An object that specifies the series text style.
*
* @param TextStyle $textStyle
* @throws InvalidConfigValue
* @return Series
*/
public function textStyle(TextStyle $textStyle)
{
$this->textStyle = $textStyle;
return $this;
}
}
/*
[x] annotations - :An object to be applied to annotations for this series. This can be used to control, for instance, the textStyle for the series
series: {
0: {
annotations: {
textStyle: {fontSize: 12, color: 'red' }
}
}
} See the various annotations options for a more complete list of what can be customized.
[ ] areaOpacity - Overrides the global areaOpacity for this series.
[ ] color - The color to use for this series. Specify a valid HTML color string.
[x] curveType - Overrides the global curveType value for this series.
[ ] fallingColor.fill - Overrides the global candlestick.fallingColor.fill value for this series.
[ ] fallingColor.stroke - Overrides the global candlestick.fallingColor.stroke value for this series.
[ ] fallingColor.strokeWidth - Overrides the global candlestick.fallingColor.strokeWidth value for this series.
[ ] lineWidth - Overrides the global lineWidth value for this series.
[ ] pointShape - Overrides the global pointShape value for this series.
[ ] pointSize - Overrides the global pointSize value for this series.
[ ] risingColor.fill - Overrides the global candlestick.risingColor.fill value for this series.
[ ] risingColor.stroke - Overrides the global candlestick.risingColor.stroke value for this series.
[ ] risingColor.strokeWidth - Overrides the global candlestick.risingColor.strokeWidth value for this series.
[x] targetAxisIndex - Which axis to assign this series to, where 0 is the default axis, and 1 is the opposite axis. Default value is 0; set to 1 to define a chart where different series are rendered against different axes. At least one series much be allocated to the default axis. You can define a different scale for different axes.
[x] type - The type of marker for this series. Valid values are 'line', 'area', 'bars', 'candlesticks' and 'steppedArea'. Note that bars are actually vertical bars (columns). The default value is specified by the chart's seriesType option.
[ ] visibleInLegend - A bool value, where true means that the series should have a legend entry, and false means that it should not. Default is true.
*/