|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace Ob\HighchartsBundle\Highcharts; |
|
4
|
|
|
|
|
5
|
|
|
/** |
|
6
|
|
|
* This class is part of the Ob/HighchartsBundle |
|
7
|
|
|
* See Highcharts documentation at http://www.highcharts.com/ref/ |
|
8
|
|
|
* |
|
9
|
|
|
* @method Highstock colors(array $colors) |
|
10
|
|
|
* @method Highstock series(array $series) |
|
11
|
|
|
*/ |
|
12
|
|
|
class Highstock extends AbstractChart implements ChartInterface |
|
13
|
|
|
{ |
|
14
|
|
|
/** |
|
15
|
|
|
* @param string $engine |
|
16
|
|
|
* |
|
17
|
|
|
* @return string |
|
18
|
|
|
*/ |
|
19
|
35 |
|
public function render($engine = 'jquery') |
|
20
|
|
|
{ |
|
21
|
35 |
|
$chartJS = ""; |
|
22
|
35 |
|
$chartJS .= $this->renderEngine($engine); |
|
23
|
35 |
|
$chartJS .= $this->renderOptions(); |
|
24
|
35 |
|
$chartJS .= "\n var " . (isset($this->chart->renderTo) ? $this->chart->renderTo : 'chart') . " = new Highcharts.StockChart({\n"; |
|
25
|
|
|
|
|
26
|
|
|
// Chart Option |
|
27
|
35 |
|
$chartJS .= $this->renderWithJavascriptCallback($this->chart->chart, "chart"); |
|
28
|
|
|
|
|
29
|
|
|
// Colors |
|
30
|
35 |
|
$chartJS .= $this->renderColors(); |
|
31
|
|
|
|
|
32
|
|
|
// Credits |
|
33
|
35 |
|
$chartJS .= $this->renderCredits(); |
|
34
|
|
|
|
|
35
|
|
|
// Exporting |
|
36
|
35 |
|
$chartJS .= $this->renderWithJavascriptCallback($this->exporting->exporting, "exporting"); |
|
37
|
|
|
|
|
38
|
|
|
// Labels |
|
39
|
|
|
|
|
40
|
|
|
// Legend |
|
41
|
35 |
|
$chartJS .= $this->renderWithJavascriptCallback($this->legend->legend, "legend"); |
|
42
|
|
|
|
|
43
|
|
|
// Loading |
|
44
|
|
|
// Navigation |
|
45
|
|
|
|
|
46
|
|
|
// PlotOptions |
|
47
|
35 |
|
$chartJS .= $this->renderWithJavascriptCallback($this->plotOptions->plotOptions, "plotOptions"); |
|
48
|
|
|
|
|
49
|
|
|
// RangeSelector |
|
50
|
35 |
|
$chartJS .= $this->renderWithJavascriptCallback($this->rangeSelector->rangeSelector, "rangeSelector"); |
|
51
|
|
|
|
|
52
|
|
|
// Scrollbar |
|
53
|
35 |
|
$chartJS .= $this->renderScrollbar(); |
|
54
|
|
|
|
|
55
|
|
|
// Series |
|
56
|
35 |
|
$chartJS .= $this->renderWithJavascriptCallback($this->series, "series"); |
|
57
|
|
|
|
|
58
|
|
|
// Subtitle |
|
59
|
35 |
|
$chartJS .= $this->renderSubtitle(); |
|
60
|
|
|
|
|
61
|
|
|
// Title |
|
62
|
35 |
|
$chartJS .= $this->renderTitle(); |
|
63
|
|
|
|
|
64
|
|
|
// Tooltip |
|
65
|
35 |
|
$chartJS .= $this->renderWithJavascriptCallback($this->tooltip->tooltip, "tooltip"); |
|
66
|
|
|
|
|
67
|
|
|
// xAxis |
|
68
|
35 |
|
$chartJS .= $this->renderXAxis(); |
|
69
|
|
|
|
|
70
|
|
|
// yAxis |
|
71
|
35 |
|
$chartJS .= $this->renderYAxis(); |
|
72
|
|
|
|
|
73
|
|
|
// trim last trailing comma and close parenthesis |
|
74
|
35 |
|
$chartJS = rtrim($chartJS, ",\n") . "\n });\n"; |
|
75
|
|
|
|
|
76
|
35 |
|
if ($engine !== false) { |
|
77
|
35 |
|
$chartJS .= "});\n"; |
|
78
|
35 |
|
} |
|
79
|
|
|
|
|
80
|
35 |
|
return trim($chartJS); |
|
81
|
|
|
} |
|
82
|
|
|
} |
|
83
|
|
|
|