Skip to content

Commit 4d21dfc

Browse files
authored
Merge pull request #18 from sn3p/fix-uncaught-error
Fix uncaught argument error introduced in PHP7.1
2 parents 6f04861 + 5554b8a commit 4d21dfc

File tree

1 file changed

+51
-51
lines changed

1 file changed

+51
-51
lines changed
Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,132 +1,132 @@
11
<?php
22
// Fix for UTF-8 required for local use
3-
require_once('encoding.php');
3+
require_once('encoding.php');
44
use \ForceUTF8\Encoding;
55

66
function renderChart($target,$layout,$color,$title,$data,$labels,$categories,$width,$height,$charttype) {
77

88
// Add categories if required
9-
if(!empty($categories) && count($categories)>0) {
9+
if(!empty($categories) && count($categories)>0) {
1010
$categoriesString = "categories: ".json_encode($categories).", ";
1111
$categoriesStringPos = strpos($layout,"{",strpos($layout,"xAxis"))+1;
1212
if($categoriesStringPos !== false)
1313
$layout = substr_replace($layout,$categoriesString,$categoriesStringPos,0);
1414
}
15-
15+
1616
// Replace title if required
17-
if(!empty($title) && strlen($title)>0) {
17+
if(!empty($title) && strlen($title)>0) {
1818
$titleStringPosStart = strpos($layout,":",strpos($layout,"text"))+1;
1919
$titleStringPosEnd = strpos($layout,"}",strpos($layout,"text"))-1;
20-
20+
2121
if($categoriesStringPos !== false)
2222
$layout = substr_replace($layout,json_encode($title),$titleStringPosStart,$titleStringPosEnd-$titleStringPosStart);
2323
}
2424

2525
$chart = "
26-
<div id='$target' style='width: ".$width."px; height: ".$height."px; margin: 0em'></div>
26+
<div id='$target' style='width: ".$width."px; height: ".$height."px; margin: 0em'></div>
2727
<script type='text/javascript'>
2828
2929
var chart = new Highcharts.Chart({
3030
chart: {
3131
renderTo: '$target' ";
32-
33-
if($charttype == RENDERER_CHARTTYPE_RADAR)
32+
33+
if($charttype == RENDERER_CHARTTYPE_RADAR)
3434
$chart .= ", polar: true, type: 'area'";
35-
35+
3636
// Encoding::toUTF8() required for $data & $labels in offline use
3737
$chart .= "}, ".Encoding::toUTF8($layout)." ,series: [
3838
".jsonEncodeSeries(Encoding::toUTF8($data),Encoding::toUTF8($labels),$color,$charttype)."
3939
]
4040
});
4141
</script>";
42-
42+
4343
return $chart;
4444
}
4545

46-
function jsonEncodeMultiSeries($data,$labels,$color,$charttype) {
46+
function jsonEncodeMultiSeries($data,$labels,$color,$charttype) {
4747
$countSeries = count($data);
48-
48+
4949
for($i=0;$i<$countSeries;$i++) {
50-
50+
5151
// Reset vars per serie
5252
$layoutSerie = '';
5353
$colorTransparant = false;
5454
$charttypeSingle = $charttype;
55-
55+
5656
// Check if this is the last one
57-
if($i == ($countSeries-1)) {
58-
57+
if($i == ($countSeries-1)) {
58+
5959
if($charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN)
6060
$charttypeSingle = RENDERER_CHARTTYPE_LINESTEP;
61-
61+
6262
} else {
63-
63+
6464
if($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN) {
6565
$colorTransparant = true;
6666
$charttypeSingle = RENDERER_CHARTTYPE_COLUMN;
67-
68-
67+
68+
6969
$layoutSerie .= "
7070
showInLegend: false,
7171
yAxis: 1,
7272
";
7373
}
74-
75-
}
76-
74+
75+
}
76+
7777
$jsonData .= jsonEncodeSingleSerie($data[$i],$labels,$color,$charttypeSingle,$layoutSerie,$colorTransparant);
78-
78+
7979
if($i<($countSeries-1))
8080
$jsonData .= ",";
81-
81+
8282
}
83-
83+
8484
return $jsonData;
8585
}
8686

8787

8888

89-
function jsonEncodeSingleSerie($data,$labels,$color,$charttype,$layoutSerie,$colorTransparant=false) {
89+
function jsonEncodeSingleSerie($data,$labels,$color,$charttype,$layoutSerie='',$colorTransparant=false) {
9090
global $renderer_color;
9191
global $renderer_color_transparancy;
92-
92+
9393
$countSeries = count($data);
9494
$jsonData = "";
95-
95+
9696
if($countSeries>0) {
97-
for($i=0;$i<$countSeries;$i++) {
98-
97+
for($i=0;$i<$countSeries;$i++) {
98+
9999
$colorSerie = $renderer_color[$color][$i][0];
100100
if($colorTransparant)
101101
$colorSerie = "rgba(".hex2rgb($colorSerie).",".$renderer_color_transparancy.")";
102-
102+
103103
$jsonData .= " { ";
104-
104+
105105
if($charttype == RENDERER_CHARTTYPE_COLUMN)
106-
$jsonData .= " type: 'column',";
107-
106+
$jsonData .= " type: 'column',";
107+
108108
if($charttype == RENDERER_CHARTTYPE_BAR)
109-
$jsonData .= " type: 'bar',";
110-
109+
$jsonData .= " type: 'bar',";
110+
111111
if($charttype == RENDERER_CHARTTYPE_LINESTEP)
112-
$jsonData .= " step: 'left',";
113-
112+
$jsonData .= " step: 'left',";
113+
114114
$jsonData .= $layoutSerie;
115-
115+
116116
$jsonData .= "
117117
color: '".$colorSerie."',
118118
name: ".json_encode($labels[$i]).",
119119
data: ".json_encode($data[$i])." }";
120-
120+
121121
if($i<($countSeries-1))
122122
$jsonData .= ",";
123-
123+
124124
}
125-
125+
126126
} else if(countSeries==1) {
127127
$jsonData .= "data: { ".$layoutSerie.json_encode($data[0])." }";
128-
}
129-
128+
}
129+
130130
return $jsonData;
131131
}
132132

@@ -135,13 +135,13 @@ function jsonEncodeRadarSerie($data,$labels,$color,$charttype) {
135135
}
136136

137137

138-
function jsonEncodeSeries($data,$labels,$color,$charttype) {
139-
138+
function jsonEncodeSeries($data,$labels,$color,$charttype) {
139+
140140
if($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN)
141-
return jsonEncodeMultiSeries($data,$labels,$color,$charttype);
142-
141+
return jsonEncodeMultiSeries($data,$labels,$color,$charttype);
142+
143143
else
144-
return jsonEncodeSingleSerie($data,$labels,$color,$charttype);
144+
return jsonEncodeSingleSerie($data,$labels,$color,$charttype);
145145
}
146146

147147

@@ -192,4 +192,4 @@ function hex2rgb($hex) {
192192

193193
}
194194

195-
?>
195+
?>

0 commit comments

Comments
 (0)