示例#1
0
 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);
     }
 }
示例#2
0
    $line_3 = new line();
    $line_3->set_default_dot_style($line_3_default_dot);
    $line_3->set_values($data_3);
    $line_3->set_colour($data_3_color);
    $line_3->set_width(2);
}
if (isset($data[4])) {
    $data_4_color = '#009900';
    $data_4 = explode('|', $data[4]);
    foreach ($data_4 as $k => $v) {
        $kw = $k + 1;
        $v = floatval($v);
        $d = $kw_daterange[$kw];
        $lv = new hollow_dot($v);
        $lv->colour($data_4_color)->size(3)->halo_size(0);
        $lv->tooltip('#x_label#<br>' . $d . '<br>Value: #val#');
        $data_4[$k] = $lv;
        if ($v > $data_max) {
            $data_max = ceil($v);
        }
    }
    $line_4 = new line();
    $line_4->set_default_dot_style($line_4_default_dot);
    $line_4->set_values($data_4);
    $line_4->set_colour($data_4_color);
    $line_4->set_width(1);
}
//CHECK MAX VALUE TO DEFINE BEST VERTICAL STEPS
if ($data_max <= 10) {
    $data_step = 1;
} else {