本文整理汇总了PHP中Image_Graph::add方法的典型用法代码示例。如果您正苦于以下问题:PHP Image_Graph::add方法的具体用法?PHP Image_Graph::add怎么用?PHP Image_Graph::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Image_Graph
的用法示例。
在下文中一共展示了Image_Graph::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Generate
/**
* Generate
* Generates the charts from the data passed into it
*
* @param chart Array of data and labels
*
* @return Void Doesn't return anything.
*/
function Generate($chart) {
$this->graph->add(
$PlotArea =& new Image_Graph_Plotarea()
);
$this->graph->_outputImage = false;
switch ($chart['chart_type']) {
case 'column':
// Add grid
$PlotArea->addGridY(new Image_Graph_Grid_Lines());
$PlotArea->addGridX(new Image_Graph_Grid_Lines());
$labels = array_shift($chart['chart_data']);
$legend_labels = array();
$DataSets = array();
foreach ($chart['chart_data'] as $data) {
$Dataset =& new Image_Graph_Dataset_Trivial();
foreach ($data as $key => $value) {
if (!is_numeric($value)) {
if ($key == 0) {
$legend_labels[] = $value;
}
continue;
}
$Dataset->addPoint($key, $value);
}
$DataSets[] =& $Dataset;
}
$PlotMultiple =& new Image_Graph_Plot_Bar_Multiple($DataSets);
$PlotMultiple->spacing(3);
$PlotMultiple->setXValueWidth(1);
$Plot1 =& $PlotArea->addPlot($PlotMultiple);
$noBorder =& new Image_Graph_Line_Solid();
$noBorder->setThickness(0);
// create a Y data value marker
$Marker =& $Plot1->add(new Image_Graph_Marker_Value(IMAGE_GRAPH_VALUE_Y));
//$Marker->setFillColor(0xFFFFFF);
$Marker->setBorderColor(0xFFFFFF);
$PointingMarker =& $Plot1->add(new Image_Graph_Marker_Pointing(0,-10, $Marker));
$PointingMarker->setLineStyle($noBorder);
$Plot1->setMarker($PointingMarker);
$FillArray =& new Image_Graph_Fill_Array();
foreach ($this->colors as $color) {
$FillArray->add(new Image_Graph_Fill_Gradient(IMAGE_GRAPH_GRAD_RADIAL, eval("return 0x{$color};"), eval("return 0x{$color};"), 200));
}
$Plot1->setFillStyle($FillArray);
$AxisX =& $PlotArea->getAxis(IMAGE_GRAPH_AXIS_X);
$AxisX->setDataPreprocessor(
new Image_Graph_DataPreprocessor_Array(
$labels
)
);
$thickAxis =& new Image_Graph_Line_Solid();
$thickAxis->setThickness(2);
$AxisX->setLineStyle($thickAxis);
$AxisX->setLabelInterval(1);
$AxisY =& $PlotArea->getAxis(IMAGE_GRAPH_AXIS_Y);
$AxisY->setLineStyle($thickAxis);
$AxisY->setDataPreprocessor(new Image_Graph_DataPreprocessor_Function("FormatNumber"));
$this->graph->done();
$canvas =& $this->graph->_canvas();
$canvas =& $this->DrawTitle($canvas,$this->title,true);
$this->DrawLegend($canvas,$legend_labels,'column');
break; // case column
case 'pie':
$DataSet =& new Image_Graph_Dataset_Trivial();
$Plot1 =& $PlotArea->addPlot(new Image_Graph_Plot_Pie($DataSet));
$points = $chart['chart_data'][1];
$labels = $chart['chart_data'][0];
foreach ($points as $key => $value) {
if (!is_numeric($value)) { continue; }
//.........这里部分代码省略.........