Image_Graph
[ class tree: Image_Graph ] [ index: Image_Graph ] [ all elements ]

Source for file drivers1.php

Documentation is available at drivers1.php

  1. <?php
  2.     // include the libraries 
  3.     include 'Image/Graph.php';
  4.     include 'Image/Graph/Driver.php';
  5.  
  6.     // create a PNG driver (this is normally default)
  7.     $Driver =Image_Graph_Driver::factory('png',
  8.         array(
  9.             'width' => 400,
  10.             'height' => 200
  11.         )
  12.     );            
  13.         
  14.  
  15.     // create the graph
  16.     $Graph =Image_Graph::factory('graph'&$Driver);
  17.  
  18.     // add a new font
  19.     $Font =$Graph->addNew('ttf_font''Gothic');
  20.     $Font->setSize(8);
  21.  
  22.     // use this by default in the graph
  23.     $Graph->setFont($Font);
  24.  
  25.     // create the layout
  26.     $Graph->add(
  27.         Image_Graph::vertical(
  28.             Image_Graph::factory('title'array('Gradient Filled Step Chart'11)),
  29.             Image_Graph::horizontal(
  30.                 $Plotarea Image_Graph::factory('plotarea'),
  31.                 Image_Graph::factory('title'array('Anybody recognize?'array('size' => 7'color' => 'gray@0.6''angle' => 270))),
  32.                 98
  33.             ),
  34.         5)
  35.     );
  36.     
  37.     // add a grid
  38.     $Grid =$Plotarea->addNew('line_grid'array()IMAGE_GRAPH_AXIS_Y);
  39.     $Grid->setLineColor('white@0.4');           
  40.     
  41.     // create dataset
  42.     $Dataset =Image_Graph::factory('dataset');
  43.     $Dataset->addPoint(120);
  44.     $Dataset->addPoint(210);
  45.     $Dataset->addPoint(335);
  46.     $Dataset->addPoint(45);
  47.     $Dataset->addPoint(518);
  48.     $Dataset->addPoint(633);
  49.     
  50.     // add a step chart
  51.     $Plot =$Plotarea->addNew('step'&$Dataset);
  52.       
  53.     // fill the plot with a vertical gradient fill
  54.     $Fill =Image_Graph::factory('gradient'array(IMAGE_GRAPH_GRAD_VERTICAL'darkgreen''white'));
  55.     $Plot->setFillStyle($Fill);
  56.  
  57.     // fill the plotarea with a vertical gradient fill
  58.     $Fill =Image_Graph::factory('gradient'array(IMAGE_GRAPH_GRAD_VERTICAL'yellow''darkred'));
  59.     $Plotarea->setFillStyle($Fill);
  60.  
  61.     // configure the y-axis options    
  62.     $AxisY =$Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
  63.     $AxisY->forceMaximum(40);
  64.     $AxisY->setLabelInterval(10);
  65.     
  66.     // set some graph options
  67.     $Graph->setBackgroundColor('green@0.2');
  68.     $Graph->setBorderColor('black');
  69.     $Graph->setPadding(10);    
  70.     
  71.     // make the plot have a black border
  72.     $Plot->setBorderColor('black');      
  73.                     
  74.     // output the graph
  75.     $Graph->done();
  76. ?>

Documentation generated on Mon, 11 Mar 2019 14:21:47 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.