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

Source for file barchart1.php

Documentation is available at barchart1.php

  1. <?php
  2.     include('Image/Graph.php');
  3.     
  4.     // create the graph
  5.     $Graph =Image_Graph::factory('graph'array(400300));
  6.     
  7.     // add a TrueType font
  8.     $Arial =$Graph->addNew('ttf_font''arial.ttf');
  9.     // set the font size to 15 pixels
  10.     $Arial->setSize(11);
  11.     
  12.     $Arial1 =$Graph->addNew('ttf_font''arial.ttf');
  13.     // set the font size to 15 pixels
  14.     $Arial1->setSize(9);
  15.     $Arial1->setAngle(90);
  16.     
  17.     // add a TrueType font
  18.     $Arial2 =$Graph->addNew('ttf_font''arial.ttf');
  19.     // set the font size to 15 pixels
  20.     $Arial2->setSize(9);
  21.     $Arial2->setAngle(270);
  22.     
  23.     // create the plotarea
  24.     $Graph->add(
  25.         Image_Graph::vertical(
  26.             Image_Graph::factory('title'array('German Car Popularity'&$Arial)),
  27.             Image_Graph::horizontal(
  28.                 Image_Graph::factory('title'array('Popularity'&$Arial1)),
  29.                 Image_Graph::horizontal(
  30.                     Image_Graph::vertical(
  31.                         $Plotarea = Image_Graph::factory('plotarea'),
  32.                         $Legend = Image_Graph::factory('legend'),
  33.                         95
  34.                     ),
  35.                     Image_Graph::factory('title'array('Defects / 1000 units'&$Arial2)),
  36.                     95
  37.                 ),
  38.                 7
  39.             ),
  40.             5
  41.         )
  42.     );
  43.     
  44.     $Legend->setPlotArea($Plotarea);
  45.     
  46.     // create the dataset
  47.     $Dataset =Image_Graph::factory('dataset');
  48.     $Dataset->addPoint('Audi'100);
  49.     $Dataset->addPoint('Mercedes'41);
  50.     $Dataset->addPoint('Porsche'78);
  51.     $Dataset->addPoint('BMW'12);
  52.     //$Dataset =& Image_Graph::factory('random', array(10, 2, 15, true));
  53.     
  54.     $Dataset2 =Image_Graph::factory('dataset');
  55.     $Dataset2->addPoint('Audi'10);
  56.     $Dataset2->addPoint('Mercedes'17);
  57.     $Dataset2->addPoint('Porsche'12);
  58.     $Dataset2->addPoint('BMW'21);
  59.     
  60.     $GridY =$Plotarea->addNew('bar_grid'nullIMAGE_GRAPH_AXIS_Y);
  61.     $GridY->setFillStyle(Image_Graph::factory('gradient'array(IMAGE_GRAPH_GRAD_VERTICAL'white''lightgrey')));
  62.     
  63.     // create the plot as bar chart using the dataset
  64.     $Plot =$Plotarea->addNew('bar'array(&$Dataset'normal''Popularity'));
  65.     $FillArray =Image_Graph::factory('Image_Graph_Fill_Array');
  66.     $Plot->setFillStyle($FillArray);
  67.     $FillArray->addNew('gradient'array(IMAGE_GRAPH_GRAD_VERTICAL'green''white'));
  68.     $FillArray->addNew('gradient'array(IMAGE_GRAPH_GRAD_VERTICAL'blue''white'));
  69.     $FillArray->addNew('gradient'array(IMAGE_GRAPH_GRAD_VERTICAL'yellow''white'));
  70.     $FillArray->addNew('gradient'array(IMAGE_GRAPH_GRAD_VERTICAL'red''white'));
  71.     $FillArray->addNew('gradient'array(IMAGE_GRAPH_GRAD_VERTICAL'orange''white'));
  72.     
  73.     $Marker =$Graph->addNew('Image_Graph_Marker_Array');
  74.     $Marker->addNew('Image_Graph_Marker_Icon''./images/audi.png');
  75.     $Marker->addNew('Image_Graph_Marker_Icon''./images/mercedes.png');
  76.     $Marker->addNew('Image_Graph_Marker_Icon''./images/porsche.png');
  77.     $Marker->addNew('Image_Graph_Marker_Icon''./images/bmw.png');
  78.     
  79.     $Plot->setMarker($Marker);
  80.     
  81.     $Plot2 =$Plotarea->addNew('line'array(&$Dataset2'normal''Defects')IMAGE_GRAPH_AXIS_Y_SECONDARY);
  82.     $Plot2->setLineColor('blue@0.4');
  83.     
  84.     $Marker =$Graph->addNew('Image_Graph_Marker_Value'IMAGE_GRAPH_VALUE_Y);
  85.     $Plot2->setMarker($Marker);
  86.     
  87.     $AxisY =$Plotarea->getAxis(IMAGE_GRAPH_AXIS_Y);
  88.     $AxisY->setDataPreprocessor(Image_Graph::factory('Image_Graph_DataPreprocessor_Formatted''%0.0f%%'));
  89.     $AxisY->forceMaximum(105);
  90.     
  91.     // output the Graph
  92.     $Graph->done();
  93. ?>

Documentation generated on Mon, 11 Mar 2019 13:57:45 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.