cvs: pear /Image_Graph/docs/examples barchart1.php linechart1.php piechart1.php

From: Date: Thu, 16 Dec 2004 08:24:20 +0000
Subject: cvs: pear /Image_Graph/docs/examples barchart1.php linechart1.php piechart1.php
Groups: php.pear.cvs 
Request: Send a blank email to pear-cvs+get-27472@lists.php.net to get a copy of this message
nosey Thu Dec 16 03:24:20 2004 EDT Modified files: /pear/Image_Graph/docs/examples linechart1.php piechart1.php barchart1.php Log: Checkin of updated source from previous CVS

http://cvs.php.net/diff.php/pear/Image_Graph/docs/examples/linechart1.php?r1=1.1&r2=1.2&ty=u Index: pear/Image_Graph/docs/examples/linechart1.php diff -u pear/Image_Graph/docs/examples/linechart1.php:1.1 pear/Image_Graph/docs/examples/linechart1.php:1.2 --- pear/Image_Graph/docs/examples/linechart1.php:1.1 Mon Nov 1 10:33:13 2004 +++ pear/Image_Graph/docs/examples/linechart1.php Thu Dec 16 03:24:20 2004 @@ -1,89 +1,91 @@ -<?php - include('Image/Graph.php'); - - function XtoYear($Value) { - return floor($Value+1998); - } - - function salaries($Value) { - // I wish! - return exp($Value)+1000; - } - - // create the graph as a 500 x 300 image - $Graph =& Image_Graph::factory('graph', array(600, 300)); - - // create a random dataset to use for demonstrational purposes - $DataSet =& Image_Graph::factory('Image_Graph_Dataset_Function', array(1, 9, 'salaries', 9)); - - $DataSet2 =& Image_Graph::factory('dataset'); - $DataSet2->addPoint('CEO', 10); - $DataSet2->addPoint('TAP', 32); - $DataSet2->addPoint('TBF', 13); - $DataSet2->addPoint('ABC', 19); - $DataSet2->addPoint('QED', 26); - - // create the title font - $Font =& $Graph->addNew('ttf_font', 'arial.ttf'); - $Font->setSize(11); - - // create the title font - $VerticalFont =& $Graph->addNew('Image_Graph_Font_Vertical'); - $Font->setSize(11); - - // add a plot area in a vertical layout to display a title on top - $Graph->add( - Image_Graph::vertical( - Image_Graph::factory('title', array('Annual income', &$Font)), - Image_Graph::horizontal( - $Plotarea = Image_Graph::factory('plotarea'), - $Plotarea2 = Image_Graph::factory('plotarea') - ), - 5 - ), - 5 - ); - - // - $Grid =& $Plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); - $Grid->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey'))); - - // add the line plot to the plotarea - $Plot =& $Plotarea->addNew('line', &$DataSet); - - // add coins-icon as marker - $Plot->setMarker(Image_Graph::factory('Image_Graph_Marker_Icon', './images/coins.png')); - - $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); - $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); - // make x-axis start at 0 - $AxisX->forceMinimum(0); - - // make x-axis end at 11 - $AxisX->forceMaximum(9); - - // show axis arrows - $AxisX->showArrow(); - $AxisY->showArrow(); - - // create a datapreprocessor to map X-values to years - $AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'XtoYear')); - $AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Currency', "US$")); - - $Plot2 =& $Plotarea2->addNew('Image_Graph_Plot_Pie', &$DataSet2); - $Plotarea2->hideAxis(); - $Fill =& Image_Graph::factory('Image_Graph_Fill_Array'); - $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'red', 'white')); - $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'blue', 'white')); - $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'yellow', 'white')); - $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'green', 'white')); - $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'orange', 'white')); - $Plot2->setFillStyle($Fill); - - $Marker2 =& $Graph->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y); - $Plot2->setMarker($Marker2); - $Marker2->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.0f%%')); - - // output the graph - $Graph->done(); +<?php + include 'Image/Graph.php'; + + function XtoYear($Value) + { + return floor($Value+1998); + } + + function salaries($Value) + { + // I wish! + return exp($Value)+1000; + } + + // create the graph as a 500 x 300 image + $Graph =& Image_Graph::factory('graph', array(600, 300)); + + // create a random dataset to use for demonstrational purposes + $DataSet =& Image_Graph::factory('Image_Graph_Dataset_Function', array(1, 9, 'salaries', 9)); + + $DataSet2 =& Image_Graph::factory('dataset'); + $DataSet2->addPoint('CEO', 10); + $DataSet2->addPoint('TAP', 32); + $DataSet2->addPoint('TBF', 13); + $DataSet2->addPoint('ABC', 19); + $DataSet2->addPoint('QED', 26); + + // create the title font + $Font =& $Graph->addNew('ttf_font', 'arial.ttf'); + $Font->setSize(11); + + // create the title font + $VerticalFont =& $Graph->addNew('Image_Graph_Font_Vertical'); + $Font->setSize(11); + + // add a plot area in a vertical layout to display a title on top + $Graph->add( + Image_Graph::vertical( + Image_Graph::factory('title', array('Annual income', &$Font)), + Image_Graph::horizontal( + $Plotarea = Image_Graph::factory('plotarea'), + $Plotarea2 = Image_Graph::factory('plotarea') + ), + 5 + ), + 5 + ); + + // + $Grid =& $Plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); + $Grid->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey'))); + + // add the line plot to the plotarea + $Plot =& $Plotarea->addNew('line', &$DataSet); + + // add coins-icon as marker + $Plot->setMarker(Image_Graph::factory('Image_Graph_Marker_Icon', './images/coins.png')); + + $AxisX =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_X); + $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); + // make x-axis start at 0 + $AxisX->forceMinimum(0); + + // make x-axis end at 11 + $AxisX->forceMaximum(9); + + // show axis arrows + $AxisX->showArrow(); + $AxisY->showArrow(); + + // create a datapreprocessor to map X-values to years + $AxisX->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Function', 'XtoYear')); + $AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Currency', "US$")); + + $Plot2 =& $Plotarea2->addNew('Image_Graph_Plot_Pie', &$DataSet2); + $Plotarea2->hideAxis(); + $Fill =& Image_Graph::factory('Image_Graph_Fill_Array'); + $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'red', 'white')); + $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'blue', 'white')); + $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'yellow', 'white')); + $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'green', 'white')); + $Fill->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'orange', 'white')); + $Plot2->setFillStyle($Fill); + + $Marker2 =& $Graph->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y); + $Plot2->setMarker($Marker2); + $Marker2->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.0f%%')); + + // output the graph + $Graph->done(); ?> \ No newline at end of file http://cvs.php.net/diff.php/pear/Image_Graph/docs/examples/piechart1.php?r1=1.1&r2=1.2&ty=u Index: pear/Image_Graph/docs/examples/piechart1.php diff -u pear/Image_Graph/docs/examples/piechart1.php:1.1 pear/Image_Graph/docs/examples/piechart1.php:1.2 --- pear/Image_Graph/docs/examples/piechart1.php:1.1 Mon Nov 1 10:33:13 2004 +++ pear/Image_Graph/docs/examples/piechart1.php Thu Dec 16 03:24:20 2004 @@ -1,53 +1,53 @@ -<?php - include('Image/Graph.php'); - - // create the graph - $Graph =& Image_Graph::factory('graph', array(400, 300)); - - // add a TrueType font - $Arial =& $Graph->addNew('ttf_font', 'arial.ttf'); - // set the font size to 11 pixels - $Arial->setSize(11); - // add a title using the created font - - // create the plotarea - $Graph->add( - Image_Graph::vertical( - Image_Graph::factory('title', array('Meat Export', &$Arial)), - $Plotarea = Image_Graph::factory('plotarea'), - 5 - ) - ); - - // create the 1st dataset - $Dataset1 =& Image_Graph::factory('dataset'); - $Dataset1->addPoint('Beef', rand(1, 10)); - $Dataset1->addPoint('Pork', rand(1, 10)); - $Dataset1->addPoint('Poultry', rand(1, 10)); - $Dataset1->addPoint('Camels', rand(1, 10)); - $Dataset1->addPoint('Other', rand(1, 10)); - // create the 1st plot as smoothed area chart using the 1st dataset - $Plot1 =& $Plotarea->addNew('Image_Graph_Plot_Pie', &$Dataset1); - $Plotarea->hideAxis(); - - // create a Y data value marker - $Marker =& $Plot1->addNew('Image_Graph_Marker_Value', VALUE_X); - // create a pin-point marker type - $PointingMarker =& $Plot1->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker)); - // and use the marker on the 1st plot - $Plot1->setMarker($PointingMarker); - // format value marker labels as percentage values - - $Plot1->Radius = 2; - - $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array'); - $Plot1->setFillStyle($FillArray); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'green', 'white')); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'blue', 'white')); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'yellow', 'white')); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'red', 'white')); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'orange', 'white')); - - // output the Graph - $Graph->done(); -?> +<?php + include 'Image/Graph.php'; + + // create the graph + $Graph =& Image_Graph::factory('graph', array(400, 300)); + + // add a TrueType font + $Arial =& $Graph->addNew('ttf_font', 'arial.ttf'); + // set the font size to 11 pixels + $Arial->setSize(11); + // add a title using the created font + + // create the plotarea + $Graph->add( + Image_Graph::vertical( + Image_Graph::factory('title', array('Meat Export', &$Arial)), + $Plotarea = Image_Graph::factory('plotarea'), + 5 + ) + ); + + // create the 1st dataset + $Dataset1 =& Image_Graph::factory('dataset'); + $Dataset1->addPoint('Beef', rand(1, 10)); + $Dataset1->addPoint('Pork', rand(1, 10)); + $Dataset1->addPoint('Poultry', rand(1, 10)); + $Dataset1->addPoint('Camels', rand(1, 10)); + $Dataset1->addPoint('Other', rand(1, 10)); + // create the 1st plot as smoothed area chart using the 1st dataset + $Plot1 =& $Plotarea->addNew('Image_Graph_Plot_Pie', &$Dataset1); + $Plotarea->hideAxis(); + + // create a Y data value marker + $Marker =& $Plot1->addNew('Image_Graph_Marker_Value', VALUE_X); + // create a pin-point marker type + $PointingMarker =& $Plot1->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker)); + // and use the marker on the 1st plot + $Plot1->setMarker($PointingMarker); + // format value marker labels as percentage values + + $Plot1->Radius = 2; + + $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array'); + $Plot1->setFillStyle($FillArray); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'green', 'white')); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'blue', 'white')); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'yellow', 'white')); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'red', 'white')); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_RADIAL, 'orange', 'white')); + + // output the Graph + $Graph->done(); +?> http://cvs.php.net/diff.php/pear/Image_Graph/docs/examples/barchart1.php?r1=1.1&r2=1.2&ty=u Index: pear/Image_Graph/docs/examples/barchart1.php diff -u pear/Image_Graph/docs/examples/barchart1.php:1.1 pear/Image_Graph/docs/examples/barchart1.php:1.2 --- pear/Image_Graph/docs/examples/barchart1.php:1.1 Mon Nov 1 10:33:13 2004 +++ pear/Image_Graph/docs/examples/barchart1.php Thu Dec 16 03:24:20 2004 @@ -1,93 +1,93 @@ -<?php - include('Image/Graph.php'); - - // create the graph - $Graph =& Image_Graph::factory('graph', array(400, 300)); - - // add a TrueType font - $Arial =& $Graph->addNew('ttf_font', 'arial.ttf'); - // set the font size to 15 pixels - $Arial->setSize(11); - - $Arial1 =& $Graph->addNew('ttf_font', 'arial.ttf'); - // set the font size to 15 pixels - $Arial1->setSize(9); - $Arial1->setAngle(90); - - // add a TrueType font - $Arial2 =& $Graph->addNew('ttf_font', 'arial.ttf'); - // set the font size to 15 pixels - $Arial2->setSize(9); - $Arial2->setAngle(270); - - // create the plotarea - $Graph->add( - Image_Graph::vertical( - Image_Graph::factory('title', array('German Car Popularity', &$Arial)), - Image_Graph::horizontal( - Image_Graph::factory('title', array('Popularity', &$Arial1)), - Image_Graph::horizontal( - Image_Graph::vertical( - $Plotarea = Image_Graph::factory('plotarea'), - $Legend = Image_Graph::factory('legend'), - 95 - ), - Image_Graph::factory('title', array('Defects / 1000 units', &$Arial2)), - 95 - ), - 7 - ), - 5 - ) - ); - - $Legend->setPlotArea($Plotarea); - - // create the dataset - $Dataset =& Image_Graph::factory('dataset'); - $Dataset->addPoint('Audi', 100); - $Dataset->addPoint('Mercedes', 41); - $Dataset->addPoint('Porsche', 78); - $Dataset->addPoint('BMW', 12); - //$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true)); - - $Dataset2 =& Image_Graph::factory('dataset'); - $Dataset2->addPoint('Audi', 10); - $Dataset2->addPoint('Mercedes', 17); - $Dataset2->addPoint('Porsche', 12); - $Dataset2->addPoint('BMW', 21); - - $GridY =& $Plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); - $GridY->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey'))); - - // create the plot as bar chart using the dataset - $Plot =& $Plotarea->addNew('bar', array(&$Dataset, 'normal', 'Popularity')); - $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array'); - $Plot->setFillStyle($FillArray); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'green', 'white')); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'blue', 'white')); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'yellow', 'white')); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'red', 'white')); - $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'orange', 'white')); - - $Marker =& $Graph->addNew('Image_Graph_Marker_Array'); - $Marker->addNew('Image_Graph_Marker_Icon', './images/audi.png'); - $Marker->addNew('Image_Graph_Marker_Icon', './images/mercedes.png'); - $Marker->addNew('Image_Graph_Marker_Icon', './images/porsche.png'); - $Marker->addNew('Image_Graph_Marker_Icon', './images/bmw.png'); - - $Plot->setMarker($Marker); - - $Plot2 =& $Plotarea->addNew('line', array(&$Dataset2, 'normal', 'Defects'), IMAGE_GRAPH_AXIS_Y_SECONDARY); - $Plot2->setLineColor('blue@0.4'); - - $Marker =& $Graph->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y); - $Plot2->setMarker($Marker); - - $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); - $AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.0f%%')); - $AxisY->forceMaximum(105); - - // output the Graph - $Graph->done(); -?> +<?php + include 'Image/Graph.php'; + + // create the graph + $Graph =& Image_Graph::factory('graph', array(400, 300)); + + // add a TrueType font + $Arial =& $Graph->addNew('ttf_font', 'arial.ttf'); + // set the font size to 15 pixels + $Arial->setSize(11); + + $Arial1 =& $Graph->addNew('ttf_font', 'arial.ttf'); + // set the font size to 15 pixels + $Arial1->setSize(9); + $Arial1->setAngle(90); + + // add a TrueType font + $Arial2 =& $Graph->addNew('ttf_font', 'arial.ttf'); + // set the font size to 15 pixels + $Arial2->setSize(9); + $Arial2->setAngle(270); + + // create the plotarea + $Graph->add( + Image_Graph::vertical( + Image_Graph::factory('title', array('German Car Popularity', &$Arial)), + Image_Graph::horizontal( + Image_Graph::factory('title', array('Popularity', &$Arial1)), + Image_Graph::horizontal( + Image_Graph::vertical( + $Plotarea = Image_Graph::factory('plotarea'), + $Legend = Image_Graph::factory('legend'), + 95 + ), + Image_Graph::factory('title', array('Defects / 1000 units', &$Arial2)), + 95 + ), + 7 + ), + 5 + ) + ); + + $Legend->setPlotarea($Plotarea); + + // create the dataset + $Dataset =& Image_Graph::factory('dataset'); + $Dataset->addPoint('Audi', 100); + $Dataset->addPoint('Mercedes', 41); + $Dataset->addPoint('Porsche', 78); + $Dataset->addPoint('BMW', 12); + //$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true)); + + $Dataset2 =& Image_Graph::factory('dataset'); + $Dataset2->addPoint('Audi', 10); + $Dataset2->addPoint('Mercedes', 17); + $Dataset2->addPoint('Porsche', 12); + $Dataset2->addPoint('BMW', 21); + + $GridY =& $Plotarea->addNew('bar_grid', null, IMAGE_GRAPH_AXIS_Y); + $GridY->setFillStyle(Image_Graph::factory('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'white', 'lightgrey'))); + + // create the plot as bar chart using the dataset + $Plot =& $Plotarea->addNew('bar', array(&$Dataset, 'normal', 'Popularity')); + $FillArray =& Image_Graph::factory('Image_Graph_Fill_Array'); + $Plot->setFillStyle($FillArray); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'green', 'white')); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'blue', 'white')); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'yellow', 'white')); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'red', 'white')); + $FillArray->addNew('gradient', array(IMAGE_GRAPH_GRAD_VERTICAL, 'orange', 'white')); + + $Marker =& $Graph->addNew('Image_Graph_Marker_Array'); + $Marker->addNew('Image_Graph_Marker_Icon', './images/audi.png'); + $Marker->addNew('Image_Graph_Marker_Icon', './images/mercedes.png'); + $Marker->addNew('Image_Graph_Marker_Icon', './images/porsche.png'); + $Marker->addNew('Image_Graph_Marker_Icon', './images/bmw.png'); + + $Plot->setMarker($Marker); + + $Plot2 =& $Plotarea->addNew('line', array(&$Dataset2, 'normal', 'Defects'), IMAGE_GRAPH_AXIS_Y_SECONDARY); + $Plot2->setLineColor('blue@0.4'); + + $Marker =& $Graph->addNew('Image_Graph_Marker_Value', IMAGE_GRAPH_VALUE_Y); + $Plot2->setMarker($Marker); + + $AxisY =& $Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y); + $AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted', '%0.0f%%')); + $AxisY->forceMaximum(105); + + // output the Graph + $Graph->done(); +?>
« previous php.pear.cvs (#27472) next »