summaryrefslogtreecommitdiff
path: root/html/includes/renderer-general-output.php
diff options
context:
space:
mode:
authorMatthijs Kuiper <info@matthijskuiper.nl>2018-08-31 17:11:18 +0200
committerGitHub <noreply@github.com>2018-08-31 17:11:18 +0200
commit4d21dfcac97fd02c186bb3ce4085275b36e3790e (patch)
tree19165fcd9ada17e2f7110dfeccb9b5c6daa3a7dc /html/includes/renderer-general-output.php
parent6f048612c7f297c83bb4b8e8de51d77e0bb5d002 (diff)
parent5554b8a3f7ce42416e00e829fe5dda6f2a8f3aca (diff)
Merge pull request #18 from sn3p/fix-uncaught-errorHEAD4.4.2master
Fix uncaught argument error introduced in PHP7.1
Diffstat (limited to 'html/includes/renderer-general-output.php')
-rw-r--r--html/includes/renderer-general-output.php102
1 files changed, 51 insertions, 51 deletions
diff --git a/html/includes/renderer-general-output.php b/html/includes/renderer-general-output.php
index 462e7bb..8ae0a15 100644
--- a/html/includes/renderer-general-output.php
+++ b/html/includes/renderer-general-output.php
@@ -1,132 +1,132 @@
<?php
// Fix for UTF-8 required for local use
-require_once('encoding.php');
+require_once('encoding.php');
use \ForceUTF8\Encoding;
function renderChart($target,$layout,$color,$title,$data,$labels,$categories,$width,$height,$charttype) {
// Add categories if required
- if(!empty($categories) && count($categories)>0) {
+ if(!empty($categories) && count($categories)>0) {
$categoriesString = "categories: ".json_encode($categories).", ";
$categoriesStringPos = strpos($layout,"{",strpos($layout,"xAxis"))+1;
if($categoriesStringPos !== false)
$layout = substr_replace($layout,$categoriesString,$categoriesStringPos,0);
}
-
+
// Replace title if required
- if(!empty($title) && strlen($title)>0) {
+ if(!empty($title) && strlen($title)>0) {
$titleStringPosStart = strpos($layout,":",strpos($layout,"text"))+1;
$titleStringPosEnd = strpos($layout,"}",strpos($layout,"text"))-1;
-
+
if($categoriesStringPos !== false)
$layout = substr_replace($layout,json_encode($title),$titleStringPosStart,$titleStringPosEnd-$titleStringPosStart);
}
$chart = "
- <div id='$target' style='width: ".$width."px; height: ".$height."px; margin: 0em'></div>
+ <div id='$target' style='width: ".$width."px; height: ".$height."px; margin: 0em'></div>
<script type='text/javascript'>
var chart = new Highcharts.Chart({
chart: {
renderTo: '$target' ";
-
- if($charttype == RENDERER_CHARTTYPE_RADAR)
+
+ if($charttype == RENDERER_CHARTTYPE_RADAR)
$chart .= ", polar: true, type: 'area'";
-
+
// Encoding::toUTF8() required for $data & $labels in offline use
$chart .= "}, ".Encoding::toUTF8($layout)." ,series: [
".jsonEncodeSeries(Encoding::toUTF8($data),Encoding::toUTF8($labels),$color,$charttype)."
]
});
</script>";
-
+
return $chart;
}
-function jsonEncodeMultiSeries($data,$labels,$color,$charttype) {
+function jsonEncodeMultiSeries($data,$labels,$color,$charttype) {
$countSeries = count($data);
-
+
for($i=0;$i<$countSeries;$i++) {
-
+
// Reset vars per serie
$layoutSerie = '';
$colorTransparant = false;
$charttypeSingle = $charttype;
-
+
// Check if this is the last one
- if($i == ($countSeries-1)) {
-
+ if($i == ($countSeries-1)) {
+
if($charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN)
$charttypeSingle = RENDERER_CHARTTYPE_LINESTEP;
-
+
} else {
-
+
if($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN) {
$colorTransparant = true;
$charttypeSingle = RENDERER_CHARTTYPE_COLUMN;
-
-
+
+
$layoutSerie .= "
showInLegend: false,
yAxis: 1,
";
}
-
- }
-
+
+ }
+
$jsonData .= jsonEncodeSingleSerie($data[$i],$labels,$color,$charttypeSingle,$layoutSerie,$colorTransparant);
-
+
if($i<($countSeries-1))
$jsonData .= ",";
-
+
}
-
+
return $jsonData;
}
-function jsonEncodeSingleSerie($data,$labels,$color,$charttype,$layoutSerie,$colorTransparant=false) {
+function jsonEncodeSingleSerie($data,$labels,$color,$charttype,$layoutSerie='',$colorTransparant=false) {
global $renderer_color;
global $renderer_color_transparancy;
-
+
$countSeries = count($data);
$jsonData = "";
-
+
if($countSeries>0) {
- for($i=0;$i<$countSeries;$i++) {
-
+ for($i=0;$i<$countSeries;$i++) {
+
$colorSerie = $renderer_color[$color][$i][0];
if($colorTransparant)
$colorSerie = "rgba(".hex2rgb($colorSerie).",".$renderer_color_transparancy.")";
-
+
$jsonData .= " { ";
-
+
if($charttype == RENDERER_CHARTTYPE_COLUMN)
- $jsonData .= " type: 'column',";
-
+ $jsonData .= " type: 'column',";
+
if($charttype == RENDERER_CHARTTYPE_BAR)
- $jsonData .= " type: 'bar',";
-
+ $jsonData .= " type: 'bar',";
+
if($charttype == RENDERER_CHARTTYPE_LINESTEP)
- $jsonData .= " step: 'left',";
-
+ $jsonData .= " step: 'left',";
+
$jsonData .= $layoutSerie;
-
+
$jsonData .= "
color: '".$colorSerie."',
name: ".json_encode($labels[$i]).",
data: ".json_encode($data[$i])." }";
-
+
if($i<($countSeries-1))
$jsonData .= ",";
-
+
}
-
+
} else if(countSeries==1) {
$jsonData .= "data: { ".$layoutSerie.json_encode($data[0])." }";
- }
-
+ }
+
return $jsonData;
}
@@ -135,13 +135,13 @@ function jsonEncodeRadarSerie($data,$labels,$color,$charttype) {
}
-function jsonEncodeSeries($data,$labels,$color,$charttype) {
-
+function jsonEncodeSeries($data,$labels,$color,$charttype) {
+
if($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN)
- return jsonEncodeMultiSeries($data,$labels,$color,$charttype);
-
+ return jsonEncodeMultiSeries($data,$labels,$color,$charttype);
+
else
- return jsonEncodeSingleSerie($data,$labels,$color,$charttype);
+ return jsonEncodeSingleSerie($data,$labels,$color,$charttype);
}
@@ -192,4 +192,4 @@ function hex2rgb($hex) {
}
-?> \ No newline at end of file
+?>