function JpGraph() { $graph = new PieGraph(230, 200, "auto"); //$graph->SetShadow(); // Set A title for the plot $graph->title->Set($tpl->_ENGINE_parse_body("{your mailbox usage}\n ({$kb} mb free)")); $graph->title->SetFont(FF_FONT1, FS_BOLD, 12); $graph->title->SetColor("black"); $p1 = new PiePlot($data); $p1->SetSliceColors(array("red", "green", "yellow", "green")); $p1->SetTheme("water"); $p1->value->SetFont(FF_FONT1, FS_NORMAL, 10); $p1->Explode(array(0, 15, 15, 25, 15)); //$p1->SetLabelType(PIE_VALUE_PER); //$lbl = array("{used} $USER_STORAGE_USAGE","{free}"); //$p1->SetLabels($lbl); $graph->Add($p1); //$graph->img->SetAntiAliasing(); $graph->Stroke(); }
<?php include "../jpgraph.php"; include "../jpgraph_pie.php"; // Some data $data = array(113, 5, 160, 3, 15, 10, 1); // Create the Pie Graph. $graph = new PieGraph(300, 200, "auto"); $graph->SetShadow(); // Set A title for the plot $graph->title->Set("Example 1 Pie plot"); $graph->title->SetFont(FF_VERDANA, FS_BOLD, 14); $graph->title->SetColor("brown"); // Create pie plot $p1 = new PiePlot($data); //$p1->SetSliceColors(array("red","blue","yellow","green")); $p1->SetTheme("earth"); $p1->SetFont(FF_ARIAL, FS_NORMAL, 10); // Set how many pixels each slice should explode $p1->Explode(array(0, 15, 15, 25, 15)); $graph->Add($p1); $graph->Stroke(); ?>
function parse($input, $parser) { global $jpgraphLabelType; foreach (split("\n", $input) as $line) { // skip empty line or comments if (preg_match("/^(\\s*)#.*\$|^(\\s*)\$/", $line)) { continue; } // Storing data $raw_data = split($this->fieldsep, $line); if (count($raw_data) == 2) { $this->labels[] = $raw_data[0]; $this->datay[] = $raw_data[1]; } else { $this->datay[] = $raw_data[0]; } } if ($this->is3d) { $pie = new PiePlot3D($this->datay); $pie->SetAngle($this->angle); } else { $pie = new PiePlot($this->datay); } if ($this->center) { $tmp = split(",", $this->center); if (is_array($tmp) && count($tmp) == 2) { $pie->SetCenter($tmp[0], $tmp[1]); } else { if (is_array($tmp) && count($tmp) == 1) { $pie->SetCenter($tmp[0]); } } } if ($this->labeltype) { $label_type = $jpgraphLabelType[$this->labeltype]; if (!$label_type) { throw new JpgraphMWException("Unknown label type(" . $this->labeltype . "). Possible values are: " . implode(", ", array_keys($jpgraphLabelType))); } $pie->SetLabelType($label_type); } if ($this->labelformat) { $pie->value->SetFormat($this->labelformat); } if ($this->usettf) { $pie->value->SetFont($this->font); } $pie->value->Show($this->showlabel); $explode_pie_list = split(",", $this->explode); if (count($explode_pie_list) == 1) { $pie->ExplodeAll($explode_pie_list[0]); } else { $pie->Explode($explode_pie_list); } if (count($this->labels) == count($this->datay)) { $pie->SetLegends($this->labels); } $this->graph->Add($pie); }