Source for file drivers2.php
Documentation is available at drivers2.php
include 'Image/Graph.php';
include 'Image/Graph/Driver.php';
// create a new PNG driver
$Font = & $Graph->addNew ('ttf_font', 'Gothic');
// use this by default in the graph
array ('Demonstration of Mathematical Functions', 10 )
$Legend_Weather->setPlotarea ($Plotarea_Weather);
$Legend_Weather->setFontSize (7 );
$Legend_SinCos->setPlotarea ($Plotarea_SinCos);
$Legend_SinCos->setFontSize (8 );
$GridY_Weather = & $Plotarea_Weather->addNew (
$GridY_Weather->setLineColor ('gray@0.1');
// create a axis marker marker to display min and max temperatures
$Plotarea_Weather->addNew (
'Image_Graph_Axis_Marker_Area',
$Marker_AverageSpan->setFillColor ('green@0.2');
$Marker_AverageSpan->setLowerBound (3.8 );
$Marker_AverageSpan->setUpperBound (11.4 );
// create a axis marker marker to display average temperatures
$Plotarea_Weather->addNew (
'Image_Graph_Axis_Marker_Line',
$Marker_Average->setLineColor ('blue@0.4');
$Marker_Average->setValue (7.7 );
$Dataset_Rainfall->addPoint ('Jan', 60 );
$Dataset_Rainfall->addPoint ('Feb', 41 );
$Dataset_Rainfall->addPoint ('Mar', 48 );
$Dataset_Rainfall->addPoint ('Apr', 42 );
$Dataset_Rainfall->addPoint ('May', 50 );
$Dataset_Rainfall->addPoint ('Jun', 55 );
$Dataset_Rainfall->addPoint ('Jul', 67 );
$Dataset_Rainfall->addPoint ('Aug', 65 );
$Dataset_Rainfall->addPoint ('Sep', 72 );
$Dataset_Rainfall->addPoint ('Oct', 77 );
$Dataset_Rainfall->addPoint ('Nov', 80 );
$Dataset_Rainfall->addPoint ('Dec', 68 );
$Plotarea_Weather->addNew (
$Plot_Rainfall->setLineColor ('gray');
$Plot_Rainfall->setFillColor ('yellow@0.1');
$Plot_Rainfall->setTitle ('Average rainfall');
$Dataset_TempAvg->addPoint ('Jan', 0.2 );
$Dataset_TempAvg->addPoint ('Feb', 0.1 );
$Dataset_TempAvg->addPoint ('Mar', 2.3 );
$Dataset_TempAvg->addPoint ('Apr', 5.8 );
$Dataset_TempAvg->addPoint ('May', 10.8 );
$Dataset_TempAvg->addPoint ('Jun', 14.1 );
$Dataset_TempAvg->addPoint ('Jul', 16.2 );
$Dataset_TempAvg->addPoint ('Aug', 15.9 );
$Dataset_TempAvg->addPoint ('Sep', 12.1 );
$Dataset_TempAvg->addPoint ('Oct', 8.7 );
$Dataset_TempAvg->addPoint ('Nov', 4.4 );
$Dataset_TempAvg->addPoint ('Dec', 1.8 );
$Plotarea_Weather->addNew (
'Image_Graph_Plot_Smoothed_Line',
$Plot_TempAvg->setLineColor ('blue');
$Plot_TempAvg->setTitle ('Average temperature');
$Dataset_TempMin->addPoint ('Jan', -2.7 );
$Dataset_TempMin->addPoint ('Feb', -2.8 );
$Dataset_TempMin->addPoint ('Mar', -0.9 );
$Dataset_TempMin->addPoint ('Apr', 1.2 );
$Dataset_TempMin->addPoint ('May', 5.5 );
$Dataset_TempMin->addPoint ('Jun', 9.2 );
$Dataset_TempMin->addPoint ('Jul', 11.3 );
$Dataset_TempMin->addPoint ('Aug', 11.1 );
$Dataset_TempMin->addPoint ('Sep', 7.8 );
$Dataset_TempMin->addPoint ('Oct', 5.0 );
$Dataset_TempMin->addPoint ('Nov', 1.5 );
$Dataset_TempMin->addPoint ('Dec', -0.9 );
$Plotarea_Weather->addNew (
'Image_Graph_Plot_Smoothed_Line',
$Plot_TempMin->setLineColor ('teal');
$Plot_TempMin->setTitle ('Minimum temperature');
$Dataset_TempMax->addPoint ('Jan', 2.4 );
$Dataset_TempMax->addPoint ('Feb', 2.5 );
$Dataset_TempMax->addPoint ('Mar', 5.4 );
$Dataset_TempMax->addPoint ('Apr', 10.5 );
$Dataset_TempMax->addPoint ('May', 15.8 );
$Dataset_TempMax->addPoint ('Jun', 18.9 );
$Dataset_TempMax->addPoint ('Jul', 21.2 );
$Dataset_TempMax->addPoint ('Aug', 20.8 );
$Dataset_TempMax->addPoint ('Sep', 16.3 );
$Dataset_TempMax->addPoint ('Oct', 11.8 );
$Dataset_TempMax->addPoint ('Nov', 6.9 );
$Dataset_TempMax->addPoint ('Dec', 4.1 );
$Plotarea_Weather->addNew (
'Image_Graph_Plot_Smoothed_Line',
$Plot_TempMax->setLineColor ('red');
$Plot_TempMax->setTitle ('Maximum temperature');
// create a datapreprocessor to display milimeter unit
// create a datapreprocessor to display degrees centigrade unit
$DataPreprocessor_DegC = &
// create a value marker for the rainfall chart
$Marker_Rainfall->setDataPreprocessor ($DataPreprocessor_MM);
$Marker_Rainfall->setFontSize (7 );
$PointingMarker_Rainfall = &
'Image_Graph_Marker_Pointing_Angular',
array (20 , &$Marker_Rainfall)
$Plot_Rainfall->setMarker ($PointingMarker_Rainfall);
// setup the primary y axis
$AxisY_Weather->setDataPreprocessor ($DataPreprocessor_DegC);
$AxisY_Weather->setTitle (
array ('vertical' => true , 'angle' => 90 )
// setup the secondary y axis
$AxisYsecondary_Weather = &
$AxisYsecondary_Weather->setDataPreprocessor ($DataPreprocessor_MM);
$AxisYsecondary_Weather->setTitle (
array ('vertical' => true , 'angle' => 270 )
// setup grid for mathematical chart (sin, cos)
'Image_Graph_Dataset_Function',
array (-2* pi(), 2* pi(), 'sin', 50 )
'Image_Graph_Dataset_Function',
array (-2* pi(), 2* pi(), 'cos', 50 )
// create and setup plots
$Plot_Sin = & $Plotarea_SinCos->addNew ('line', $Dataset_Sin);
$Plot_Cos = & $Plotarea_SinCos->addNew ('line', $Dataset_Cos);
$Plot_Sin->setLineColor ('red');
$Plot_Cos->setLineColor ('blue');
$Plot_Sin->setTitle ('sin(x)');
$Plot_Cos->setTitle ('cos(x)');
$AxisX_SinCos->setLabelInterval (array (-6 , -4 , -2 , 2 , 4 , 6 ));
$AxisY_SinCos->forceMinimum (-1.1 );
$AxisY_SinCos->forceMaximum (1.1 );
$AxisY_SinCos->setLabelInterval (array (-1 , -0.5 , 0.5 , 1 ));
// a user defined callback function used in preprocessor
// create x-axis label preprocessor for 'car' chart
$GridX_Car->setLineColor ('gray@0.2');
$GridY_Car->setLineColor ('gray@0.2');
// setup dataset (random)
// create the car filling
$Plotarea_Car->setFillStyle ($Fill_Car);
$Plotarea_Car->addNew ('Image_Graph_Plot_Smoothed_Area', $Dataset_Car);
$Plot_Car->setLineColor ('gray');
$Plot_Car->setFillColor ('white@0.7');
$AxisX_Car->setDataPreprocessor ($DataPreprocessor_Car);
$AxisX_Car->setFontSize (6 );
$AxisY_Car->forceMaximum (100 );
// output the graph using the GD driver
$Graph->done (array ('filename' => './frontpage_sample.png'));
// create a new SVG driver
// make the graph use this now instead
$Graph->setDriver ($Driver);
// 're'-output the graph, but not using the SVG driver
$Graph->done (array ('filename' => './frontpage_sample.svg'));
// create a new PDF driver
'orientation' => 'landscape',
// make the graph use this now instead
$Graph->setDriver ($Driver);
// 're'-output the graph, but not using the PDF driver
$Graph->done (array ('filename' => './frontpage_sample.pdf'));
// create a new SWF driver
// make the graph use this now instead
$Graph->setDriver ($Driver);
// 're'-output the graph, but not using the SWF driver
$Graph->done (array ('filename' => './frontpage_sample.swf'));
Documentation generated on Mon, 11 Mar 2019 14:21:48 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|