';
if($this->charts > 1) {
$divide = ceil($bars / $this->charts);
$graph .= '';
}
else $divide = 0;
for($i = $sum = $max = $max_neg = $max_dec = $ccnt = $lcnt = $chart = 0; $i < $bars; $i++) {
if($divide && $i && !($i % $divide)) {
$lcnt = 0;
$chart++;
}
$drv = explode(';', $d[$i]);
for($j = $dec = 0; $j < count($drv); $j++) {
$val[$chart][$lcnt][$j] = $v = trim(str_replace(',', '.', $drv[$j]));
if($v > $max) $max = $v;
else if($v < $max_neg) $max_neg = $v;
if($v < 0) $v *= -1;
$sum += $v;
if(strstr($v, '.')) {
$dec = strlen(substr($v, strrpos($v, '.') + 1));
if($dec > $max_dec) $max_dec = $dec;
}
if(!$bc[$j]) {
if($ccnt >= count($this->colors)) $ccnt = 0;
$bc[$j] = (!$drc[$j] || strlen($drc[$j]) < 3) ? $this->colors[$ccnt++] : trim($drc[$j]);
}
}
$lcnt++;
}
$border = (int) $this->barBorder;
$mPerc = $sum ? round($max * 100 / $sum) : 0;
if($this->type == 'pbar' || $this->type == 'fader') $mul = 2;
else $mul = $mPerc ? 100 / $mPerc : 1;
$mul *= $this->barLength;
if($this->showValues < 2) {
if($this->type == 'hbar')
$valSpace = ($this->percValuesDecimals * ($this->percValuesSize / 1.6)) + ($this->percValuesSize * 3.2);
else $valSpace = $this->percValuesSize * 1.2;
}
else $valSpace = $this->percValuesSize;
$spacer = $maxSize = round($mPerc * $mul + $valSpace + $border * 2);
if($max_neg) {
$mPerc_neg = $sum ? round(-$max_neg * 100 / $sum) : 0;
$spacer_neg = round($mPerc_neg * $mul + $valSpace + $border * 2);
$maxSize += $spacer_neg;
}
$titleLabel = $titleValue = $titleBar = '';
if(count($t) > 0) {
$titleLabel = ($t[0] == '') ? ' ' : $t[0];
if($this->showValues == 1 || $this->showValues == 2) {
$titleValue = ($t[1] == '') ? ' ' : $t[1];
$titleBar = ($t[2] == '') ? ' ' : $t[2];
}
else $titleBar = ($t[1] == '') ? ' ' : $t[1];
}
for($chart = $lcnt = 0; $chart < count($val); $chart++) {
$graph .= '';
if($this->type == 'hbar') {
if(count($t) > 0) $graph .= $this->build_hTitle($titleLabel, $titleValue, $titleBar);
for($i = 0; $i < count($val[$chart]); $i++, $lcnt++) {
$label = ($lcnt < count($r)) ? trim($r[$lcnt]) : $lcnt+1;
$rowspan = count($val[$chart][$i]);
$graph .= ' 1) ? ' rowspan=' . $rowspan : '') . '>';
$graph .= ' ' . $label . ' | ';
for($j = 0; $j < count($val[$chart][$i]); $j++) {
$percent = $sum ? $val[$chart][$i][$j] * 100 / $sum : 0;
$value = number_format($val[$chart][$i][$j], $max_dec);
$bColor = $this->level_color($val[$chart][$i][$j], $bc[$j]);
if($this->showValues == 1 || $this->showValues == 2)
$graph .= $this->build_value($val[$chart][$i][$j], $max_dec, 0, 'right');
$graph .= 'cssBARBG ? ' style="' . $this->cssBARBG . '"' : '') . ' height=100% width=' . $maxSize . '>';
$graph .= $this->create_hBar($value, $percent, $mPerc, $mPerc_neg, $max_neg, $mul, $valSpace, $bColor, $border, $spacer, $spacer_neg);
$graph .= ' | ';
if($j < count($val[$chart][$i]) - 1) $graph .= '';
}
if($this->labelSpace && $i < count($val[$chart])-1) $graph .= ' | ';
}
}
else if($this->type == 'vbar') {
$graph .= '';
if($titleBar != '') {
$titleBar = str_replace('-', '- ', $titleBar);
$graph .= '' . $titleBar . ' | ';
}
for($i = 0; $i < count($val[$chart]); $i++) {
for($j = 0; $j < count($val[$chart][$i]); $j++) {
$percent = $sum ? $val[$chart][$i][$j] * 100 / $sum : 0;
$value = number_format($val[$chart][$i][$j], $max_dec);
$bColor = $this->level_color($val[$chart][$i][$j], $bc[$j]);
$graph .= 'cssBARBG ? ' style="' . $this->cssBARBG . '"' : '') . '>';
$graph .= $this->create_vBar($value, $percent, $mPerc, $mPerc_neg, $max_neg, $mul, $valSpace, $bColor, $border, $spacer, $spacer_neg);
$graph .= ' | ';
}
if($this->labelSpace) $graph .= ' | ';
}
if($this->showValues == 1 || $this->showValues == 2) {
$graph .= ' ';
if($titleValue != '') $graph .= '' . $titleValue . ' | ';
for($i = 0; $i < count($val[$chart]); $i++) {
for($j = 0; $j < count($val[$chart][$i]); $j++) {
$graph .= $this->build_value($val[$chart][$i][$j], $max_dec);
}
if($this->labelSpace) $graph .= ' | ';
}
}
$graph .= ' ';
if($titleLabel != '') $graph .= '' . $titleLabel . ' | ';
for($i = 0; $i < count($val[$chart]); $i++, $lcnt++) {
$label = ($lcnt < count($r)) ? trim($r[$lcnt]) : $lcnt+1;
$colspan = count($val[$chart][$i]);
$graph .= ' 1) ? ' colspan=' . $colspan : '') . '>';
$graph .= ' ' . $label . ' | ';
if($this->labelSpace) $graph .= ' | ';
}
$graph .= ' ';
}
else if($this->type == 'pbar' || $this->type == 'fader') {
if(count($t) > 0) $graph .= $this->build_hTitle($titleLabel, $titleValue, $titleBar);
for($i = 0; $i < count($val[$chart]); $i++, $lcnt++) {
$label = ($lcnt < count($r)) ? trim($r[$lcnt]) : '';
$graph .= '';
if($label) {
$graph .= '';
$graph .= ' ' . $label . ' | ';
}
$sum = (float) $val[$chart][$i][1];
$percent = $sum ? $val[$chart][$i][0] * 100 / $sum : 0;
$value = number_format($val[$chart][$i][0], $max_dec);
if($this->showValues == 1 || $this->showValues == 2)
$graph .= $this->build_value($val[$chart][$i][0], $max_dec, $sum, 'right');
$graph .= 'cssBARBG ? ' style="' . $this->cssBARBG . '"' : '') . '>';
$this->barColors = $drc[$i] ? trim($drc[$i]) : $this->colors[0];
$bColor = $this->level_color($val[$chart][$i][0], $this->barColors);
$graph .= '';
if($this->type == 'fader') $graph .= $this->build_fader($value, round($this->barWidth / 2), $this->barWidth, round($percent * $mul), $bColor);
else $graph .= $this->build_bar($value, round($percent * $mul), $this->barWidth, $bColor);
$graph .= ' | | ';
$graph .= '
| ';
if($this->showValues < 2) $graph .= ' ' . number_format($percent, $this->percValuesDecimals) . '% | ';
$graph .= ' ';
if($this->labelSpace && $i < count($val[$chart])-1) $graph .= ' | ';
}
}
else $graph .= '' . $this->err_type . ' | ';
$graph .= ' ';
if($chart < $this->charts - 1 && count($val[$chart+1])) {
$graph .= ' | ';
if($this->type == 'vbar') $graph .= ' ';
$graph .= '';
}
}
if($this->charts > 1) $graph .= ' | ';
if($this->legend && $this->type != 'pbar' && $this->type != 'fader') {
$graph .= ' | | ';
$graph .= $this->build_legend($bc);
$graph .= ' |