includes/graphs.php
author Dan
Fri, 09 May 2008 23:32:00 -0400
changeset 293 fbe306070c40
parent 262 a82133ce2d76
permissions -rw-r--r--
Fixed (again) the user -> user_id transition in enano_tags table
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     1
<?php
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     2
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     3
/*
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     4
 * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
     5
 * Version 1.1.1
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     6
 * Copyright (C) 2006-2007 Dan Fuhry
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     7
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     8
 * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
     9
 * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    10
 *
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    11
 * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    12
 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for details.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    13
 */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    14
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    15
// BarGraph for PHP
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    16
// Source: http://www.phpclasses.org/browse/package/1567.html
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    17
// License: PHP license, see licenses/phplic.html included with this package
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    18
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    19
class GraphMaker {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    20
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    21
   * GraphMaker::bar_width
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    22
   * Width of bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    23
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    24
  var $bar_width = 32;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    25
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    26
   * GraphMaker::bar_height
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    27
   * Height of bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    28
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    29
  var $bar_height = 8;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    30
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    31
   * GraphMaker::bar_data
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    32
   * Data of all bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    33
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    34
  var $bar_data = array('a' => 7, 'b' => 3, 'c' => 6, 'd' => 0, 'e' => 2);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    35
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    36
   * GraphMaker::bar_padding
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    37
   * Padding of bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    38
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    39
  var $bar_padding = 5;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    40
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    41
   * GraphMaker::bar_bordercolor
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    42
   * Border color of bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    43
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    44
  var $bar_bordercolor = array(39, 78, 120);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    45
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    46
   * GraphMaker::bar_bgcolor
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    47
   * Background color of bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    48
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    49
  var $bar_bgcolor = array(69, 129, 194);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    50
  //---------------------------------------------
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    51
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    52
   * GraphMaker::graph_areaheight
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    53
   * Height of graphic area
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    54
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    55
  var $graph_areaheight = 100;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    56
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    57
   * GraphMaker::graph_padding
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    58
   * Paddings of graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    59
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    60
  var $graph_padding = array('left' => 50, 'top' => 20, 'right'  => 20, 'bottom' => 20);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    61
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    62
   * GraphMaker::graph_title
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    63
   * Title text of graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    64
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    65
  var $graph_title = "";
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    66
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    67
   * GraphMaker::graph_bgcolor
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    68
   * Background color of graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    69
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    70
  var $graph_bgcolor = array(255, 255, 255);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    71
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    72
   * GraphMaker::graph_bgtransparent
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    73
   * Boolean for background transparency
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    74
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    75
  var $graph_bgtransparent = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    76
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    77
   * GraphMaker::graph_transparencylevel
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    78
   * Transparency level (0=opaque, 127=transparent)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    79
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    80
  var $graph_transparencylevel = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    81
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    82
   * GraphMaker::graph_borderwidth
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    83
   * Width of graph border
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    84
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    85
  var $graph_borderwidth = 1;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    86
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    87
   * GraphMaker::graph_bordercolor
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    88
   * Border color of graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    89
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    90
  var $graph_bordercolor = array(218, 218, 239);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    91
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    92
   * GraphMaker::graph_titlecolor
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    93
   * Color of title text of graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    94
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    95
  var $graph_titlecolor = array(99, 88, 78);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    96
  //---------------------------------------------
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    97
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    98
   * GraphMaker::axis_step
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
    99
   * Scale step of axis
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   100
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   101
  var $axis_step = 2;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   102
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   103
   * GraphMaker::axis_bordercolor
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   104
   * Border color of axis
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   105
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   106
  var $axis_bordercolor = array(99, 88, 78);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   107
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   108
   * GraphMaker::axis_bgcolor
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   109
   * Background color of axis
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   110
   */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   111
  var $axis_bgcolor = array(152, 137, 124);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   112
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   113
  /****************************************************************
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   114
                              GRAPH
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   115
  ****************************************************************/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   116
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   117
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   118
   * GraphMaker::SetGraphAreaHeight()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   119
   * Sets graph height (not counting top and bottom margins)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   120
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   121
  function SetGraphAreaHeight($height) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   122
    if ($height > 0) $this->graph_areaheight = $height;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   123
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   124
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   125
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   126
   * GraphMaker::SetGraphPadding()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   127
   * Sets graph padding (margins)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   128
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   129
  function SetGraphPadding($left, $top, $right, $bottom) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   130
    $this->graph_padding = array('left'   => (int) $left,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   131
                                 'top'    => (int) $top,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   132
                                 'right'  => (int) $right,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   133
                                 'bottom' => (int) $bottom);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   134
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   135
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   136
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   137
   * GraphMaker::SetGraphTitle()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   138
   * Set title text
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   139
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   140
  function SetGraphTitle($title) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   141
    $this->graph_title = $title;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   142
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   143
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   144
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   145
   * GraphMaker::SetGraphBorderColor()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   146
   * Sets border color for graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   147
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   148
  function SetGraphBorderColor($red, $green, $blue) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   149
    $this->graph_bordercolor = array($red, $green, $blue);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   150
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   151
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   152
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   153
   * GraphMaker::SetGraphBorderWidth()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   154
   * Set width of border. 0 disables border
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   155
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   156
  function SetGraphBorderWidth($width = 0) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   157
    $this->graph_borderwidth = $width;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   158
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   159
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   160
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   161
   * GraphMaker::SetGraphBackgroundColor()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   162
   * Sets background color for graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   163
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   164
  function SetGraphBackgroundColor($red, $green, $blue) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   165
    $this->graph_bgcolor = array($red, $green, $blue);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   166
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   167
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   168
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   169
   * GraphMaker::SetGraphBackgroundTransparent()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   170
   * Sets background color for graph (and set it transparent)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   171
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   172
  function SetGraphBackgroundTransparent($red, $green, $blue, $addtransparency = 1) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   173
    $this->graph_bgcolor = array($red, $green, $blue);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   174
    $this->graph_bgtransparent = ($addtransparency ? 1 : 0);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   175
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   176
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   177
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   178
   * GraphMaker::SetGraphTitleColor()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   179
   * Sets title color for graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   180
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   181
  function SetGraphTitleColor($red, $green, $blue) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   182
    $this->graph_titlecolor = array($red, $green, $blue);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   183
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   184
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   185
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   186
   * GraphMaker::SetGraphTransparency()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   187
   * Sets transparency for graph
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   188
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   189
  function SetGraphTransparency($percent) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   190
    if ($percent < 0) $percent = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   191
    elseif ($percent > 100) $percent = 127;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   192
    else $percent = $percent * 1.27;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   193
    $this->graph_transparencylevel = $percent;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   194
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   195
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   196
  /****************************************************************
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   197
                               BAR
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   198
  ****************************************************************/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   199
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   200
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   201
   * GraphMaker::SetBarBorderColor()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   202
   * Sets border color for bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   203
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   204
  function SetBarBorderColor($red, $green, $blue) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   205
    $this->bar_bordercolor = array($red, $green, $blue);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   206
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   207
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   208
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   209
   * GraphMaker::SetBarBackgroundColor()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   210
   * Sets background color for bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   211
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   212
  function SetBarBackgroundColor($red, $green, $blue) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   213
    $this->bar_bgcolor = array($red, $green, $blue);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   214
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   215
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   216
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   217
   * GraphMaker::SetBarData()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   218
   * Sets data of graph (parameter should be an array with key
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   219
   * being the name of the bar and the value the value of the bar.
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   220
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   221
  function SetBarData($data) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   222
    if (is_array($data)) $this->bar_data = $data;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   223
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   224
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   225
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   226
   * GraphMaker::SetBarDimensions()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   227
   * Sets with and height of each bar
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   228
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   229
  function SetBarDimensions($width, $height) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   230
    if ($width > 0) $this->bar_width = $width;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   231
    if ($height > 0) $this->bar_height = $height;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   232
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   233
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   234
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   235
   * GraphMaker::SetBarPadding()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   236
   * Sets padding (border) around each bar
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   237
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   238
  function SetBarPadding($padding) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   239
    if ($padding > 0) $this->bar_padding = $padding;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   240
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   241
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   242
  /****************************************************************
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   243
                               AXIS
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   244
  ****************************************************************/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   245
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   246
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   247
   * GraphMaker::SetAxisBorderColor()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   248
   * Sets border color for axis
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   249
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   250
  function SetAxisBorderColor($red, $green, $blue) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   251
    $this->axis_bordercolor = array($red, $green, $blue);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   252
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   253
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   254
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   255
   * GraphMaker::SetAxisBackgroundColor()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   256
   * Sets background color for axis
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   257
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   258
  function SetAxisBackgroundColor($red, $green, $blue) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   259
    $this->axis_bgcolor = array($red, $green, $blue);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   260
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   261
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   262
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   263
   * GraphMaker::SetAxisStep()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   264
   * Sets axis scale step
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   265
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   266
  function SetAxisStep($step) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   267
    if ($step > 0) $this->axis_step = $step;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   268
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   269
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   270
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   271
   * GraphMaker::GetFinalGraphDimensions()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   272
   * From the values already setted, it calculates image
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   273
   * width and height
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   274
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   275
  function GetFinalGraphDimensions() {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   276
    $w = $this->graph_padding['left'] +
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   277
         (count($this->bar_data) * ($this->bar_width + ($this->bar_padding * 2))) +
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   278
         $this->graph_padding['right'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   279
    $h = $this->graph_padding['top'] +
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   280
         $this->graph_areaheight +
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   281
         $this->graph_padding['bottom'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   282
    return array($w, $h);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   283
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   284
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   285
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   286
   * GraphMaker::LoadGraph()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   287
   * Loads definitions from a file
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   288
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   289
  function LoadGraph($path) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   290
    if (($fp = @fopen($path, "r")) !== false) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   291
      $content = "";
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   292
      while (!feof($fp)) {              // I do not use filesize() here
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   293
        $content .= fread($fp, 4096);   // because of remote files. If
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   294
      }                                 // there is no problem with them
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   295
      fclose($fp);                      // please let me know
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   296
      $this->__LoadGraphDefinitions($content);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   297
      return true;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   298
    } else return false;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   299
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   300
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   301
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   302
   * GraphMaker::DrawGraph()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   303
   * Draw all the graph: bg, axis, bars, text.. and output it
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   304
   * Optional file parameter turns output to file, and bool on success
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   305
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   306
  function DrawGraph($file = "") {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   307
    list($w, $h) = $this->GetFinalGraphDimensions();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   308
    $this->graph_width = $w;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   309
    $this->graph_height = $h;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   310
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   311
    $this->im = imagecreatetruecolor($w, $h);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   312
    if ($this->graph_transparencylevel) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   313
      imagealphablending($this->im, true);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   314
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   315
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   316
    $this->__PaintBackground();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   317
    $this->__DrawAxis();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   318
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   319
    $p = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   320
    foreach ($this->bar_data as $name => $value) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   321
      $p++;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   322
      $this->__DrawBarText($p, $name);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   323
      $this->__DrawBar($p, $value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   324
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   325
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   326
    if (strlen($this->graph_title)) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   327
      $this->__AllocateColor("im_graph_titlecolor",
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   328
                             $this->graph_titlecolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   329
                             $this->graph_transparencylevel);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   330
      $this->__DrawText($this->graph_title,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   331
                        floor($this->graph_width / 2),
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   332
                        $this->graph_borderwidth + 2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   333
                        $this->im_graph_titlecolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   334
                        2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   335
                        1);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   336
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   337
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   338
    if (strlen($file)) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   339
      $ret = imagepng($this->im, $file);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   340
    } else {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   341
      header('Content-Type: image/png');
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   342
      imagepng($this->im);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   343
      $ret = true;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   344
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   345
    imagedestroy($this->im);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   346
    return $ret;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   347
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   348
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   349
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   350
   * GraphMaker::PaintBackground()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   351
   * Draw all the graph: bg, axis, bars, text.. and output it
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   352
   * Optional file parameter turns output to file, and bool on success
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   353
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   354
  function __PaintBackground() {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   355
    $this->__AllocateColor("im_graph_bgcolor",
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   356
                           $this->graph_bgcolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   357
                           0);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   358
    imagefilledrectangle($this->im,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   359
                         0,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   360
                         0,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   361
                         $this->graph_width,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   362
                         $this->graph_height,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   363
                         $this->im_graph_bgcolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   364
    if ($this->graph_bgtransparent) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   365
      imagecolortransparent($this->im, $this->im_graph_bgcolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   366
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   367
    if ($this->graph_borderwidth) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   368
      $this->__AllocateColor("im_graph_bordercolor",
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   369
                             $this->graph_bordercolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   370
                             $this->graph_transparencylevel);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   371
      for ($i = 0; $i < $this->graph_borderwidth; $i++) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   372
        imagerectangle($this->im,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   373
                       $i,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   374
                       $i,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   375
                       $this->graph_width - 1 - $i,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   376
                       $this->graph_height - 1 - $i,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   377
                       $this->im_graph_bordercolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   378
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   379
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   380
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   381
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   382
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   383
   * GraphMaker::__DrawAxis()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   384
   * Draws all the axis stuff (and scale steps)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   385
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   386
  function __DrawAxis() {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   387
    $this->__AllocateColor("im_axis_bordercolor",
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   388
                           $this->axis_bordercolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   389
                           $this->graph_transparencylevel);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   390
    $this->__AllocateColor("im_axis_bgcolor",
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   391
                           $this->axis_bgcolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   392
                           $this->graph_transparencylevel);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   393
    $this->__DrawPolygon($this->graph_padding['left'], $this->graph_height - $this->graph_padding['bottom'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   394
                         $this->graph_padding['left'], $this->graph_padding['top'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   395
                         $this->graph_padding['left'] + $this->bar_height - 1, $this->graph_padding['top'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   396
                         $this->graph_padding['left'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   397
                         $this->im_axis_bgcolor, true);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   398
    $this->__DrawPolygon($this->graph_padding['left'], $this->graph_height - $this->graph_padding['bottom'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   399
                         $this->graph_padding['left'], $this->graph_padding['top'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   400
                         $this->graph_padding['left'] + $this->bar_height - 1, $this->graph_padding['top'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   401
                         $this->graph_padding['left'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   402
                         $this->im_axis_bordercolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   403
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   404
    $this->__DrawPolygon($this->graph_padding['left'], $this->graph_height - $this->graph_padding['bottom'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   405
                         $this->graph_padding['left'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   406
                         $this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   407
                         $this->graph_width - $this->graph_padding['right'], $this->graph_height - $this->graph_padding['bottom'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   408
                         $this->im_axis_bgcolor, true);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   409
    $this->__DrawPolygon($this->graph_padding['left'], $this->graph_height - $this->graph_padding['bottom'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   410
                         $this->graph_padding['left'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   411
                         $this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1, $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   412
                         $this->graph_width - $this->graph_padding['right'], $this->graph_height - $this->graph_padding['bottom'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   413
                         $this->im_axis_bordercolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   414
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   415
    // draw lines that separate bars
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   416
    $total_bars = count($this->bar_data);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   417
    for ($i = 1; $i < $total_bars; $i++) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   418
      $offset = $this->graph_padding['left'] +
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   419
                (($this->bar_width + ($this->bar_padding * 2)) * $i);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   420
      imageline($this->im,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   421
                $offset,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   422
                $this->graph_height - $this->graph_padding['bottom'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   423
                $offset + $this->bar_height - 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   424
                $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   425
                $this->im_axis_bordercolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   426
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   427
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   428
    // draw scale steps
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   429
    $max_value = $this->__GetMaxGraphValue();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   430
    if (($max_value % 10) > 0) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   431
      $max_value = $max_value + (10 - ($max_value % 10));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   432
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   433
    $this->axis_max = $max_value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   434
    $y = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   435
    $style = array($this->im_axis_bordercolor, $this->im_graph_bgcolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   436
    imagesetstyle($this->im, $style);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   437
    while ($y <= $max_value) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   438
      if ($max_value == 0) { $max_value=1; } // corrected by Marcelo Trenkenchu
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   439
      $offset = floor($this->graph_height - $this->graph_padding['bottom'] -
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   440
                ($y * $this->graph_areaheight / $max_value));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   441
      imageline($this->im,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   442
                $this->graph_padding['left'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   443
                $offset,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   444
                $this->graph_padding['left'] + $this->bar_height - 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   445
                $offset - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   446
                $this->im_axis_bordercolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   447
      $this->__DrawText($y,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   448
                        $this->graph_padding['left'],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   449
                        $offset,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   450
                        $this->im_axis_bordercolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   451
                        1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   452
                        2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   453
                        1);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   454
      // gridline
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   455
      if ($y > 0) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   456
        imageline($this->im,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   457
                  $this->graph_padding['left'] + $this->bar_height,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   458
                  $offset - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   459
                  $this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   460
                  $offset - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   461
                  IMG_COLOR_STYLED);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   462
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   463
      $y += $this->axis_step;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   464
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   465
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   466
    imageline($this->im,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   467
              $this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   468
              $this->graph_padding['top'] - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   469
              $this->graph_width - $this->graph_padding['right'] + $this->bar_height - 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   470
              $this->graph_height - $this->graph_padding['bottom'] - $this->bar_height,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   471
              IMG_COLOR_STYLED);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   472
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   473
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   474
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   475
   * GraphMaker::__DrawText()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   476
   * Draws text on image with color, size and alignment options
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   477
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   478
  function __DrawText($text, $x, $y, $color, $size = 1, $align = 0, $valign = 0) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   479
    /*
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   480
     * Align: 0=left | 1=center | 2=right
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   481
     */
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   482
    if ($align == 1) $x -= floor(strlen($text) * imagefontwidth($size) / 2);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   483
    elseif ($align == 2) $x -= (strlen($text) * imagefontwidth($size));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   484
    if ($valign == 1) $y -= floor(imagefontheight($size) / 2);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   485
    elseif ($valign == 2) $y -= imagefontheight($size);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   486
    imagestring($this->im,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   487
                $size,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   488
                $x,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   489
                $y,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   490
                $text,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   491
                $color);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   492
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   493
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   494
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   495
   * GraphMaker::__GetMaxGraphValue()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   496
   * Returns max bar value
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   497
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   498
  function __GetMaxGraphValue() {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   499
    $max_value = 0;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   500
    foreach ($this->bar_data as $name => $value) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   501
      if ($value > $max_value) $max_value = $value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   502
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   503
    return $max_value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   504
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   505
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   506
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   507
   * GraphMaker::__DrawBarText()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   508
   * Determines top and left to draw text to a choosen bar
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   509
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   510
  function __DrawBarText($bar, $text) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   511
    $this->__DrawText($text,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   512
                      $this->graph_padding['left'] + (($this->bar_width + ($this->bar_padding * 2)) * ($bar - 0.5)),
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   513
                      $this->graph_height - $this->graph_padding['bottom'] + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   514
                      $this->axis_bordercolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   515
                      1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   516
                      1);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   517
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   518
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   519
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   520
   * GraphMaker::__DrawBar()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   521
   * Draws a choosen bar with it's value
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   522
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   523
  function __DrawBar($bar, $value) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   524
    $x = $this->graph_padding['left'] +
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   525
         (($this->bar_width + ($this->bar_padding * 2)) * ($bar - 1)) +
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   526
         $this->bar_padding;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   527
    if ($this->axis_max == 0) { $this->axis_max = 1; } // corrected by Marcelo Trenkenchu
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   528
    $y = $value * $this->graph_areaheight / $this->axis_max;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   529
    $this->____DrawBar($x,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   530
                       $this->graph_height - $this->graph_padding['bottom'] - $y,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   531
                       $x + $this->bar_width,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   532
                       $this->graph_height - $this->graph_padding['bottom']);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   533
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   534
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   535
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   536
   * GraphMaker::____DrawBar()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   537
   * Draws the actual rectangles that form a bar
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   538
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   539
  function ____DrawBar($x1, $y1, $x2, $y2) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   540
    $this->__AllocateColor("im_bar_bordercolor",
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   541
                           $this->bar_bordercolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   542
                           $this->graph_transparencylevel);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   543
    $this->__AllocateColor("im_bar_bgcolor",
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   544
                           $this->bar_bgcolor,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   545
                           $this->graph_transparencylevel);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   546
    $this->__DrawPolygon($x1,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   547
                         $x2,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   548
                         $x2,                         $y2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   549
                         $x1,                         $y2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   550
                         $this->im_bar_bgcolor,       true);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   551
    $this->__DrawPolygon($x1,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   552
                         $x2,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   553
                         $x2,                         $y2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   554
                         $x1,                         $y2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   555
                         $this->im_bar_bordercolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   556
    $this->__DrawPolygon($x1,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   557
                         $x2,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   558
                         $x2 + $this->bar_height - 1, $y1 - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   559
                         $x1 + $this->bar_height - 1, $y1 - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   560
                         $this->im_bar_bgcolor,       true);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   561
    $this->__DrawPolygon($x1,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   562
                         $x2,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   563
                         $x2 + $this->bar_height - 1, $y1 - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   564
                         $x1 + $this->bar_height - 1, $y1 - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   565
                         $this->im_bar_bordercolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   566
    $this->__DrawPolygon($x2,                         $y2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   567
                         $x2,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   568
                         $x2 + $this->bar_height - 1, $y1 - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   569
                         $x2 + $this->bar_height - 1, $y2 - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   570
                         $this->im_bar_bgcolor,       true);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   571
    $this->__DrawPolygon($x2,                         $y2,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   572
                         $x2,                         $y1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   573
                         $x2 + $this->bar_height - 1, $y1 - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   574
                         $x2 + $this->bar_height - 1, $y2 - $this->bar_height + 1,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   575
                         $this->im_bar_bordercolor);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   576
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   577
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   578
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   579
   * GraphMaker::__DrawPolygon()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   580
   * Draws a (filled) (ir)regular polygon
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   581
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   582
  function __DrawPolygon($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4, $color, $filled = false) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   583
    if ($filled) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   584
      imagefilledpolygon($this->im, array($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4), 4, $color);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   585
    } else {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   586
      imagepolygon($this->im, array($x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4), 4, $color);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   587
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   588
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   589
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   590
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   591
   * GraphMaker::__LoadGraphDefinitions()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   592
   * Loads definitions to a graph from text lines (normaly
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   593
   * they come from a file). This function is called by
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   594
   * GraphMaker::LoadGraph()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   595
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   596
  function __LoadGraphDefinitions($text) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   597
    $text = preg_split("/\r?\n/", $text);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   598
    $data = array();
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   599
    $section = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   600
    for ($i = 0; $i < count($text); $i++) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   601
      if (preg_match("/^\s*#/", $text[$i])) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   602
        //ignore.. it's just a comment
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   603
      } elseif (preg_match("/^\s*\}\s*/", $text[$i])) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   604
        $section = '';
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   605
      } elseif (preg_match("/^\s*(\w+)\s*\{\s*$/", $text[$i], $r)) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   606
        $section = $r[1];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   607
      } else {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   608
        $p = strpos($text[$i], "=");
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   609
        if ($p !== false) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   610
          $data[$section][trim(substr($text[$i], 0, $p))] = trim(substr($text[$i], $p + 1));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   611
        }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   612
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   613
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   614
    if (is_array($data['graph'])) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   615
      $this->__LoadGraphValues($data['graph']);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   616
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   617
    if (is_array($data['bar'])) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   618
      $this->__LoadBarValues($data['bar']);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   619
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   620
    if (is_array($data['axis'])) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   621
      $this->__LoadAxisValues($data['axis']);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   622
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   623
    if (is_array($data['data'])) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   624
      $this->bar_data = $data['data'];
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   625
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   626
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   627
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   628
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   629
   * GraphMaker::__LoadGraphValues()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   630
   * Loads definitions to main graph settings
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   631
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   632
  function __LoadGraphValues($data) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   633
    foreach ($data as $name => $value) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   634
      $name = strtolower($name);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   635
      switch ($name) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   636
        case 'background-color':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   637
          $this->__SetColorToValue("graph_bgcolor", $value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   638
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   639
        case 'border-color':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   640
          $this->__SetColorToValue("graph_bordercolor", $value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   641
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   642
        case 'title-color':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   643
          $this->__SetColorToValue("graph_titlecolor", $value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   644
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   645
        case 'background-transparent':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   646
          $this->graph_bgtransparent = ($value == 1 || $value == 'yes' ? 1 : 0);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   647
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   648
        case 'transparency':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   649
          $this->SetGraphTransparency(str_replace('%', '', $value));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   650
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   651
        case 'title':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   652
          $this->graph_title = $value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   653
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   654
        case 'border-width':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   655
          $this->graph_borderwidth = (int) $value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   656
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   657
        case 'area-height':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   658
          $this->graph_areaheight = (int) $value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   659
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   660
        default:
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   661
          if (substr($name, 0, 8) == 'padding-' && strlen($name) > 8) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   662
            $this->graph_padding[substr($name, 8)] = $value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   663
          }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   664
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   665
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   666
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   667
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   668
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   669
   * GraphMaker::__LoadBarValues()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   670
   * Loads definitions to bar settings
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   671
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   672
  function __LoadBarValues($data) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   673
    foreach ($data as $name => $value) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   674
      $name = strtolower($name);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   675
      switch ($name) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   676
        case 'background-color':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   677
          $this->__SetColorToValue("bar_bgcolor", $value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   678
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   679
        case 'border-color':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   680
          $this->__SetColorToValue("bar_bordercolor", $value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   681
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   682
        case 'padding':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   683
          $this->bar_padding = $value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   684
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   685
        case 'width':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   686
          $this->bar_width = (int) $value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   687
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   688
        case 'height':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   689
          $this->bar_height = (int) $value;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   690
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   691
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   692
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   693
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   694
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   695
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   696
   * GraphMaker::__LoadAxisValues()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   697
   * Loads definitions to axis settings
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   698
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   699
  function __LoadAxisValues($data) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   700
    foreach ($data as $name => $value) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   701
      switch (strtolower($name)) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   702
        case 'step':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   703
          $this->SetAxisStep($value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   704
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   705
        case 'background-color':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   706
          $this->__SetColorToValue("axis_bgcolor", $value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   707
          break;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   708
        case 'border-color':
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   709
          $this->__SetColorToValue("axis_bordercolor", $value);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   710
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   711
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   712
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   713
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   714
  /**
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   715
   * GraphMaker::__SetColorToValue()
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   716
   * Sets a color (rgb or in html format) to a variable
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   717
   **/
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   718
  function __SetColorToValue($varname, $color) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   719
    if ($color[0] == "#") { // if it's hex (html format), change to rgb array
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   720
      if (strlen($color) == 4) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   721
        // if only 3 hex values (I assume it's a shade of grey: #ddd)
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   722
        $color .= substr($color, -3);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   723
      }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   724
      $color = array(hexdec($color[1].$color[2]),
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   725
                     hexdec($color[3].$color[4]),
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   726
                     hexdec($color[5].$color[6]));
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   727
    }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   728
    $this->$varname = $color;
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   729
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   730
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   731
  function __AllocateColor($varname, $color, $alpha) {
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   732
    $this->$varname = imagecolorallocatealpha($this->im,
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   733
                                              $color[0],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   734
                                              $color[1],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   735
                                              $color[2],
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   736
                                              $alpha);
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   737
  }
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   738
}
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   739
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   740
// Graph Generator for PHP
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   741
// Originally located at http://szewo.com/php/graph, but link was broken, so this file was retrieved from:
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   742
// http://web.archive.org/web/20030130065944/szewo.com/php/graph/graph.class.php3.txt
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   743
// License unknown, however sources on the web have shown this to be either GPL or public domain.
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   744
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   745
class GraphMaker_compat {
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   746
  var $_values;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   747
  var $_ShowLabels;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   748
  var $_ShowCounts;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   749
  var $_ShowCountsMode;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   750
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   751
  var $_BarWidth;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   752
  var $_GraphWidth;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   753
  var $_BarImg;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   754
  var $_BarBorderWidth;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   755
  var $_BarBorderColor;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   756
  var $_BarBackgroundColor;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   757
  var $_RowSortMode;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   758
  var $_TDClassHead;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   759
  var $_TDClassLabel;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   760
  var $_TDClassCount;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   761
  var $_GraphTitle;
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   762
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   763
  function __construct() {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   764
    $this->_values = array();
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   765
    $this->_ShowLabels = true;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   766
    $this->_BarWidth = 32;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   767
    $this->_GraphWidth = 360;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   768
    $this->_BarImg = scriptPath . "/images/graphbit.png";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   769
    $this->_BarBorderWidth = 0;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   770
    $this->_BarBorderColor = "red";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   771
    $this->_ShowCountsMode = 2;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   772
    $this->_RowSortMode = 1;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   773
    $this->_TDClassHead = "graph-title";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   774
    $this->_TDClassLabel = "graph-label";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   775
    $this->_TDClassCount = "graph-count";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   776
    $this->_GraphTitle="Graph title";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   777
    $this->_BarBackgroundColor = "#456798";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   778
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   779
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   780
  function GraphMaker_compat() {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   781
    $this->__construct();
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   782
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   783
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   784
  function SetBarBorderWidth($width) {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   785
    $this->_BarBorderWidth = $width;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   786
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   787
  function SetBorderColor($color) {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   788
    $this->_BarBorderColor = $color;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   789
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   790
  
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   791
  function SetBarBackgroundColor($color)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   792
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   793
    $this->_BarBackgroundColor = $color;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   794
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   795
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   796
//  mode = 1 labels asc, 2 label desc
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   797
  function SetSortMode($mode) {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   798
    switch ($mode) {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   799
      case 1:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   800
        asort($this->_values);
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   801
        break;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   802
      case 2:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   803
        arsort($this->_values);
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   804
        break;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   805
      default:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   806
        break;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   807
      }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   808
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   809
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   810
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   811
  function AddValue($labelName, $theValue) {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   812
    array_push($this->_values, array("label" => $labelName, "value" => $theValue));
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   813
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   814
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   815
  function SetBarData($data)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   816
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   817
      foreach ( $data as $name => $value )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   818
      {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   819
          $this->AddValue($name, $value);
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   820
      }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   821
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   822
  function DrawGraph()
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   823
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   824
      $this->BarGraphVert();
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   825
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   826
  function SetBarWidth($width)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   827
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   828
    $this->_BarWidth = $width;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   829
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   830
  function SetBarImg($img)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   831
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   832
    $this->_BarImg = $img;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   833
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   834
  function SetShowLabels($lables)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   835
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   836
    $this->_ShowLabels = $labels;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   837
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   838
  function SetGraphWidth($width)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   839
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   840
    $this->_GraphWidth = $width;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   841
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   842
  function SetGraphTitle($title)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   843
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   844
    $this->_GraphTitle = $title;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   845
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   846
  //mode = percentage or counts
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   847
  function SetShowCountsMode($mode)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   848
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   849
    $this->_ShowCountsMode = $mode;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   850
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   851
  //mode = none(0) label(1) or count(2)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   852
  function SetRowSortMode($sortmode)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   853
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   854
    $this->_RowSortMode = $sortmode;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   855
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   856
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   857
  function SetTDClassHead($class)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   858
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   859
    $this->_TDClassHead = $class;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   860
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   861
  function SetTDClassLabel($class)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   862
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   863
    $this->_TDClassLabel = $class;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   864
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   865
  function SetTDClassCount($class)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   866
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   867
    $this->_TDClassCount = $class;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   868
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   869
  function GetMaxVal()
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   870
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   871
    $maxval = 0;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   872
    foreach ( $this->_values as $value )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   873
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   874
      if ( $maxval < $value["value"] )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   875
      {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   876
        $maxval = $value["value"];
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   877
      }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   878
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   879
    return $maxval;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   880
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   881
  function BarGraphVert()
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   882
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   883
    $maxval = $this->GetMaxVal();
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   884
    foreach($this->_values as $value)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   885
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   886
      $sumval += $value["value"];
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   887
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   888
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   889
    $this->SetSortMode($this->_RowSortMode);
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   890
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   891
    echo "\n<!-- ----------------------------------------- -->\n<div class=\"tblholder\" style=\"width: 100%; clip: rect(0px,auto,auto,0px); overflow: auto;\">\n<table border=\"0\" cellspacing=\"1\" cellpadding=\"4\">\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   892
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   893
    if ( strlen($this->_GraphTitle) > 0 )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   894
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   895
      echo "<tr>\n    <th colspan=\"".count($this->_values)."\" class=\"".$this->_TDClassHead."\">".$this->_GraphTitle."</th>\n  </tr>\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   896
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   897
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   898
    echo "<tr>\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   899
    $css_class = 'row1';
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   900
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   901
    foreach($this->_values as $value)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   902
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   903
      $css_class = ( $css_class == 'row1' ) ? 'row3' : 'row1';
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   904
      echo "  <td valign=\"bottom\" align=\"center\" class=\"$css_class\">\n      ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   905
      $width = $this->_BarWidth;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   906
      $height = ceil( $value["value"] * $this->_GraphWidth / $maxval );
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   907
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   908
      echo "<div style=\"width: {$width}px; height: {$height}px; background-color: {$this->_BarBackgroundColor}; border: ".$this->_BarBorderWidth."px solid ".$this->_BarBorderColor."\">\n      ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   909
      echo "</div>\n    ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   910
      
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   911
      // echo "<img src=\"".$this->_BarImg."\" height=\"$width\" width=\"$height\" ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   912
      // echo "  style=\"border: ".$this->_BarBorderWidth."px solid ".$this->_BarBorderColor."\"";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   913
      // echo ">";
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   914
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   915
      echo "</td>\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   916
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   917
    echo "</tr>\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   918
    if ( $this->_ShowCountsMode > 0 )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   919
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   920
      $css_class = 'row1';
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   921
      echo "<tr>\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   922
      foreach($this->_values as $value)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   923
      {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   924
        $css_class = ( $css_class == 'row1' ) ? 'row3' : 'row1';
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   925
        switch ($this->_ShowCountsMode)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   926
        {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   927
          case 1:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   928
            $count = round ( 100 * $value["value"] / $sumval ) . "%";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   929
            break;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   930
          case 2:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   931
            $count = $value["value"];
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   932
            break;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   933
          default:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   934
            break;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   935
        }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   936
        echo "  <td align=\"center\" class=\"$css_class ".$this->_TDClassCount."\">$count</td>\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   937
      }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   938
      echo "</tr>\n";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   939
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   940
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   941
    if ($this->_ShowLabels)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   942
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   943
      $css_class = 'row1';
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   944
      echo "  <tr>\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   945
      foreach($this->_values as $value)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   946
      {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   947
        $css_class = ( $css_class == 'row1' ) ? 'row3' : 'row1';
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   948
        echo "  <td align=\"center\" class=\"$css_class ".$this->_TDClassLabel."\"";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   949
        echo ">".$value["label"]."</td>\n  ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   950
      }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   951
      echo "</tr>\n";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   952
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   953
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   954
    echo "</table>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   955
  }
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
   956
262
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   957
  function BarGraphHoriz()
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   958
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   959
    $maxval = $this->GetMaxVal();
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   960
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   961
    foreach($this->_values as $value)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   962
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   963
      $sumval += $value["value"];
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   964
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   965
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   966
    $this->SetSortMode($this->_RowSortMode);
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   967
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   968
    echo "<table border=\"0\">";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   969
    
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   970
    if ( strlen($this->_GraphTitle) > 0 )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   971
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   972
      echo "<tr><td ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   973
      if ( $this->_ShowCountsMode > 0 )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   974
      {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   975
        echo " colspan=\"2\"";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   976
      }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   977
      echo " class=\"".$this->_TDClassHead."\">".$this->_GraphTitle."</td></tr>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   978
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   979
    foreach($this->_values as $value)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   980
    {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   981
      if ($this->_ShowLabels)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   982
      {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   983
        echo "<tr>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   984
        echo "<td class=\"".$this->_TDClassLabel."\"";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   985
        if ( $this->_ShowCountsMode > 0 )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   986
        {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   987
          echo " colspan=\"2\"";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   988
        }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   989
        echo ">".$value["label"]."</td></tr>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   990
      }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   991
      echo "<tr>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   992
      if ( $this->_ShowCountsMode > 0 )
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   993
      {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   994
        switch ($this->_ShowCountsMode)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   995
        {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   996
          case 1:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   997
            $count = round(100 * $value["value"] / $sumval )."%";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   998
            break;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
   999
          case 2:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1000
            $count = $value["value"];
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1001
            break;  /* Exit the switch and the while. */
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1002
          default:
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1003
            break;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1004
        }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1005
        echo "<td class=\"".$this->_TDClassCount."\">$count</TD>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1006
      }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1007
      echo "<td>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1008
      $height = $this->_BarWidth;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1009
      $width = ceil( $value["value"] * $this->_GraphWidth / $maxval );
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1010
      echo "<div style=\"width: {$width}px; height: {$height}px; background-color: #456798; border: ".$this->_BarBorderWidth."px solid ".$this->_BarBorderColor."\">\n      ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1011
      echo "</div>\n    ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1012
      //echo "<img SRC=\"".$this->_BarImg."\" height=$height width=$width ";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1013
      //echo "  style=\"border: ".$this->_BarBorderWidth."px solid ".$this->_BarBorderColor."\"";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1014
      //echo ">";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1015
      echo "</td></tr>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1016
    }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1017
    echo "</table>";
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1018
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1019
  /**
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1020
   * Dummy functions for compatibility with the GD version of the class
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1021
   */
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1022
  
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1023
  function SetGraphPadding($a, $b, $c, $d)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1024
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1025
    return true;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1026
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1027
  function SetBarPadding($a)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1028
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1029
    return true;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1030
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1031
  function SetAxisStep($a)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1032
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1033
    return true;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1034
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1035
  function SetGraphBackgroundTransparent($r, $g, $b, $a)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1036
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1037
    return true;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1038
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1039
  function SetGraphTransparency($a)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1040
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1041
    return true;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1042
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1043
  function SetGraphAreaHeight($a)
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1044
  {
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1045
    return true;
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1046
  }
a82133ce2d76 A number of updates to the graphing code (it should actually work now)
Dan
parents: 261
diff changeset
  1047
}
1
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
  1048
fe660c52c48f Adding /includes
dan@scribus.fuhry.local.fuhry.local
parents:
diff changeset
  1049