public function customizeChartProperties() { parent::customizeChartProperties(); if ($this->displayPercentageInTooltip) { foreach ($this->data as $seriesIndex => &$series) { $sum = array_sum($series); foreach ($series as $valueIndex => $value) { $value = (float) $value; $percentage = 0; if ($sum > 0) { $percentage = round(100 * $value / $sum); } $this->tooltip['percentages'][$seriesIndex][$valueIndex] = $percentage; } } } }
public function customizeChartProperties() { parent::customizeChartProperties(); // if one column is a percentage we set the grid accordingly // note: it is invalid to plot a percentage dataset along with a numeric dataset if ($this->yUnit == '%' && $this->maxValue > 90) { $this->axes['yaxis']['ticks'] = array(0, 50, 100); } }
function customizeChartProperties() { parent::customizeChartProperties(); $dataSetsToDisplay = $this->getDataSetsToDisplay(); if ($dataSetsToDisplay === false) { return; } $colors = array("0x3357A0", "0xCC3399", "0x9933CC", "0x80a033", "0xFD9816", "0x246AD2", "0xFD16EA", "0x49C100"); $i = 0; foreach ($dataSetsToDisplay as $dataSetToDisplay) { $color = $colors[$i % count($colors)]; $labelName = $this->yLabels[$dataSetToDisplay]; $d = new hollow_dot(); $d->size(3)->halo_size(0)->colour($color); $line = new line(); $line->set_default_dot_style($d); $line->set_key($labelName, 11); $line->set_width(1); $line->set_colour($color); // Line Values // Note: we have to manually create the dot values as the steps feature doens't work on X axis // when it's working again, we can remove code below and set generic tooltip above: // ->tooltip('#x_label#<br>#val# '.$labelName) $yValues = $this->yValues[$dataSetToDisplay]; $labelName = $this->yLabels[$dataSetToDisplay]; $lineValues = array(); $j = 0; $unit = $this->yUnit; foreach ($this->xLabels as $label) { $value = (double) $yValues[$j]; $lineValue = new hollow_dot($value); $whole = (int) $value; if ($value - $whole >= 0.005) { $value = sprintf('%.2f', $value); } $lineValue->tooltip("{$label}<br><b>{$value}{$unit}</b> {$labelName}"); if (!empty($this->xOnClick)) { $lineValue->on_click("piwikHelper.redirectToUrl('" . $this->xOnClick[$j] . "')"); } $lineValues[] = $lineValue; $j++; } $line->set_values($lineValues); $lines[] = $line; $i++; } foreach ($lines as $line) { $this->chart->add_element($line); } // if one column is a percentage we set the grid accordingly // note: it is invalid to plot a percentage dataset along with a numeric dataset if ($this->yUnit == '%' && $this->maxValue > 90) { $this->y->set_range(0, 100, 50); } }
function customizeChartProperties() { parent::customizeChartProperties(); $dataSetsToDisplay = $this->getDataSetsToDisplay(); if ($dataSetsToDisplay === false) { return; } $dataSetToDisplay = current($dataSetsToDisplay); $this->x->set_grid_colour('#ffffff'); $this->x_labels->set_steps(2); $this->x->set_stroke(1); // create the Bar object $bar = new bar_filled('#3B5AA9', '#063E7E'); $bar->set_alpha("0.5"); $bar->set_key($this->yLabels[$dataSetToDisplay], 12); $bar->set_tooltip('#val# #key#'); // create the bar values $yValues = $this->yValues[$dataSetToDisplay]; $labelName = $this->yLabels[$dataSetToDisplay]; $unit = $this->yUnit; $barValues = array(); $i = 0; $sum = array_sum($yValues); foreach ($this->xLabels as $label) { $value = (double) $yValues[$i]; $displayPercentage = ''; if ($this->displayPercentageInTooltip) { $percentage = round(100 * $value / $sum); $displayPercentage = "({$percentage}%)"; } $barValue = new bar_value($value); $barValue->set_tooltip("{$label}<br>{$value}{$unit} {$labelName} {$displayPercentage}"); $barValues[] = $barValue; $i++; } $bar->set_values($barValues); $this->chart->add_element($bar); }
function customizeChartProperties() { parent::customizeChartProperties(); $dataSetsToDisplay = $this->getDataSetsToDisplay(); if ($dataSetsToDisplay === false) { return; } $dataSetToDisplay = current($dataSetsToDisplay); // create the Pie $pie = new pie(); $pie->set_alpha("0.6"); $pie->set_start_angle(35); $pie->add_animation(new pie_fade()); $pie->set_label_colour('#142448'); $pie->set_colours(array('#3C5A69', '#679BB5', '#695A3C', '#B58E67', '#969696')); // create the Pie values $yValues = $this->yValues[$dataSetToDisplay]; $labelName = $this->yLabels[$dataSetToDisplay]; $unit = $this->yUnit; $sum = array_sum($yValues); $pieValues = array(); $i = 0; foreach ($this->xLabels as $label) { $value = (double) $yValues[$i]; $i++; // we never plot empty pie slices (eg. visits by server time pie chart) if ($value <= 0) { continue; } $pieValue = new pie_value($value, $label); $percentage = round(100 * $value / $sum); $pieValue->set_tooltip("{$label}<br>{$percentage}% ({$value}{$unit} {$labelName})"); $pieValues[] = $pieValue; } $pie->set_values($pieValues); $this->chart->add_element($pie); }