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
|
|
|
class Highmap extends AbstractChart implements ChartInterface |
10
|
|
|
{ |
11
|
|
|
public $colorAxis; |
12
|
|
|
public $mapNavigation; |
13
|
|
|
|
14
|
|
|
public function __construct() |
15
|
|
|
{ |
16
|
|
|
parent::__construct(); |
17
|
|
|
$this->initChartOption('colorAxis'); |
18
|
|
|
$this->initChartOption('mapNavigation'); |
19
|
|
|
} |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* @param string $engine |
23
|
|
|
* |
24
|
|
|
* @return string |
25
|
|
|
*/ |
26
|
|
|
public function render($engine = 'jquery') |
27
|
|
|
{ |
28
|
|
|
$chartJS = ""; |
29
|
|
|
$chartJS .= $this->renderEngine($engine); |
30
|
|
|
$chartJS .= $this->renderOptions(); |
31
|
|
|
$chartJS .= "\n var " . (isset($this->chart->renderTo) ? $this->chart->renderTo : 'chart') . " = new Highcharts.Map({\n"; |
32
|
|
|
|
33
|
|
|
// Chart Option |
34
|
|
|
$chartJS .= $this->renderWithJavascriptCallback($this->chart->chart, "chart"); |
35
|
|
|
|
36
|
|
|
// Colors |
37
|
|
|
$chartJS .= $this->renderColors(); |
38
|
|
|
|
39
|
|
|
// Color Axis |
40
|
|
|
$chartJS .= $this->renderColorAxis(); |
41
|
|
|
|
42
|
|
|
// Credits |
43
|
|
|
$chartJS .= $this->renderCredits(); |
44
|
|
|
|
45
|
|
|
// Exporting |
46
|
|
|
$chartJS .= $this->renderWithJavascriptCallback($this->exporting->exporting, "exporting"); |
47
|
|
|
|
48
|
|
|
// Labels |
49
|
|
|
|
50
|
|
|
// Legend |
51
|
|
|
$chartJS .= $this->renderWithJavascriptCallback($this->legend->legend, "legend"); |
52
|
|
|
|
53
|
|
|
// MapNavigation |
54
|
|
|
$chartJS .= $this->renderWithJavascriptCallback($this->mapNavigation->mapNavigation, "mapNavigation"); |
55
|
|
|
|
56
|
|
|
// Loading |
57
|
|
|
// Navigation |
58
|
|
|
|
59
|
|
|
// PlotOptions |
60
|
|
|
$chartJS .= $this->renderWithJavascriptCallback($this->plotOptions->plotOptions, "plotOptions"); |
61
|
|
|
|
62
|
|
|
// RangeSelector |
63
|
|
|
$chartJS .= $this->renderWithJavascriptCallback($this->rangeSelector->rangeSelector, "rangeSelector"); |
64
|
|
|
|
65
|
|
|
// Scrollbar |
66
|
|
|
$chartJS .= $this->renderScrollbar(); |
67
|
|
|
|
68
|
|
|
// Series |
69
|
|
|
$chartJS .= $this->renderWithJavascriptCallback($this->series, "series"); |
70
|
|
|
|
71
|
|
|
// Subtitle |
72
|
|
|
$chartJS .= $this->renderSubtitle(); |
73
|
|
|
|
74
|
|
|
// Title |
75
|
|
|
$chartJS .= $this->renderTitle(); |
76
|
|
|
|
77
|
|
|
// Tooltip |
78
|
|
|
$chartJS .= $this->renderWithJavascriptCallback($this->tooltip->tooltip, "tooltip"); |
79
|
|
|
|
80
|
|
|
// xAxis |
81
|
|
|
$chartJS .= $this->renderXAxis(); |
82
|
|
|
|
83
|
|
|
// yAxis |
84
|
|
|
$chartJS .= $this->renderYAxis(); |
85
|
|
|
|
86
|
|
|
// trim last trailing comma and close parenthesis |
87
|
|
|
$chartJS = rtrim($chartJS, ",\n") . "\n });\n"; |
88
|
|
|
|
89
|
|
|
if ($engine !== false) { |
90
|
|
|
$chartJS .= "});\n"; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
return trim($chartJS); |
94
|
|
|
} |
95
|
|
|
|
96
|
|
|
/** |
97
|
|
|
* @return string |
98
|
|
|
*/ |
99
|
|
|
private function renderColorAxis() |
100
|
|
|
{ |
101
|
|
|
if (gettype($this->colorAxis) === 'array') { |
102
|
|
|
return $this->renderWithJavascriptCallback($this->colorAxis, "colorAxis"); |
103
|
|
|
} elseif (gettype($this->colorAxis) === 'object') { |
104
|
|
|
return $this->renderWithJavascriptCallback($this->colorAxis->colorAxis, "colorAxis"); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
return ""; |
108
|
|
|
} |
109
|
|
|
} |