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) { $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 = "
"; return $chart; } 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($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) { global $renderer_color; global $renderer_color_transparancy; $countSeries = count($data); $jsonData = ""; if($countSeries>0) { 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',"; if($charttype == RENDERER_CHARTTYPE_BAR) $jsonData .= " type: 'bar',"; if($charttype == RENDERER_CHARTTYPE_LINESTEP) $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; } function jsonEncodeRadarSerie($data,$labels,$color,$charttype) { return jsonEncodeSingleSerie($data,$labels,$color,$charttype,'',true); } function jsonEncodeSeries($data,$labels,$color,$charttype) { if($charttype == RENDERER_CHARTTYPE_LINECOLUMN || $charttype == RENDERER_CHARTTYPE_LINESTEPCOLUMN) return jsonEncodeMultiSeries($data,$labels,$color,$charttype); else return jsonEncodeSingleSerie($data,$labels,$color,$charttype); } /** Functions to render block in which the graphs are shown */ function renderHeaderBlock($category) { return ''.$category.' | |
'; } function renderFootBlock() { return ' |