You can subscribe to this list here.
2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(4) |
Nov
(12) |
Dec
(11) |
---|
From: Ariel G. <ag...@us...> - 2001-12-11 22:33:35
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv7245 Added Files: test2.php Log Message: testing the chart functionality --- NEW FILE: test2.php --- <?php require_once("include/vagrant-2.5/VAGRANT.class"); for ($i = 0; $i <= 10; ++$i) { $x[] = $i; $y1[] = sin($i/3); $y2[] = cos($i/3); $y3[] = sin($i/3) * $i * $i / 10; $x_label[] = "Test $i"; } // for - we are stepping through making data $vagrant = new VAGRANT(500,500); $chart_id = $vagrant->CreateObject('chart', 0, 0, 500, 300); $data1 = $vagrant->AddData($x, $y1, $chart_id); $data3 = $vagrant->AddData($x, $y3, $chart_id, true); $graph_id2 = $vagrant->CreateObject('graph', 0, 300, 500, 200); $data2 = $vagrant->AddData($x, $y2, $graph_id2); $vagrant->CreateColor('dark-blue',0,0,75,255); $vagrant->CreateColor('dark-green',0,75,0,255); $vagrant->SetValue($graph_id2, 'background_color', 'dark-blue'); $vagrant->SetValue($graph_id2, 'axis_color', 'white'); $vagrant->SetValue($graph_id2, 'x_tick_color', 'white'); $vagrant->SetValue($graph_id2, 'y_tick_color', 'white'); $vagrant->SetValue($graph_id2, 'legend_border_color', 'yellow'); $vagrant->SetValue($graph_id2, 'legend_top', LEGEND_GRAPH_TOP); $vagrant->SetValue($graph_id2, 'legend_left', LEGEND_GRAPH_RIGHT); //$vagrant->SetValue($graph_id,'y_min', -.5); $vagrant->SetValue($graph_id2, 'y_max', .6); $vagrant->SetValue($graph_id2, 'y_tick', .5); $vagrant->SetValue($chart_id, 'x_labels', $x_label); $vagrant->SetChartType($chart_id, $data1, "vert_bar", "blue", array('alpha'=>140, 'legend_title' => 'Test Line Graph Title')); $vagrant->SetChartType($chart_id, $data2, "vert_bar", "red", array('alpha'=>140, 'legend_title' => 'Test Line Graph Title')); $vagrant->SetGraphType($graph_id2, $data2, "filled", "red", array('alpha'=>120, 'legend_title' => 'Sweet red on blue')); // Add a highlight to the left side axis // $vagrant->AddHighlight($chart_id, 1, .3, 5, .5, "blue", array('alpha' => 75, 'font_color' => 'red', 'highlight_text' => "test highlight")); // Add a highlight to the right side axis by adding a true to after the options array // $vagrant->AddHighlight($chart_id, 3, 15, 7, 40, "yellow", array('alpha' => 75, 'legend_text' => "axis2 highlight", 'highlight_text' => "Highlight and legend text!" ), true); // If you comment out display image and uncomment the infodump function // you can get an idea of all of the variables that are settable using the // setvalue function. Also, it will show any errors there. // $vagrant->DisplayImage(); //$vagrant->InfoDump(); ?> |
From: Ariel G. <ag...@us...> - 2001-12-11 22:31:16
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv5187 Modified Files: Chart.class Graph.class ImagePrimitives.class VAGRANT.class Log Message: Changed how axis are drawn since both charts and graphs use standard axis but not necessarily both at the same time. I had a better explanation but it didn't get saved... Index: Chart.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Chart.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Chart.class 2001/11/28 18:40:00 1.1.1.1 --- Chart.class 2001/12/11 22:31:13 1.2 *************** *** 2,6 **** require_once(VAGRANT_PATH . "ImagePrimitives.class"); - require_once(VAGRANT_PATH . "ImageData.class"); class Chart extends ImagePrimitives { --- 2,5 ---- *************** *** 10,15 **** $this->InitializePrimitives(); } // function Chart ! } // --- 9,143 ---- $this->InitializePrimitives(); + + $this->DEFAULTS['vert_bar_edge_padding'] = 3; + $this->DEFAULTS['horiz_bar_edge_padding'] = 3; + + $this->DEFAULTS['vert_bar_width'] = 8; + $this->DEFAULTS['horiz_bar_height'] = 8; } // function Chart ! ! ! function DrawChart($dataset_id, $type, $color, $options = array()) { ! if ($type == "vert_bar") { ! $this->DrawVerticalBarGrid(); ! } // if this is a vertical bar chart ! else if ($type == "horiz_bar") { ! $this->DrawHorizontalBarGrid(); ! } // if this is a horizontal bar chart ! ! ! } // function DrawChart ! ! ! function DrawVerticalBarGrid() { ! $this->image_object->DrawFilledRectangle($this->origin_x + $this->GetValue('graph_padding'), $this->origin_y + $this->GetValue('graph_padding'), ! $this->width - 2 * $this->GetValue('graph_padding'), $this->height - 2 * $this->GetValue('graph_padding'), ! $this->GetColor($this->GetValue('background_color'))); ! ! $this->ValidateExtents(); ! ! if (is_array($this->axis2_data) && sizeof($this->axis2_data)) { ! $axis2_data = true; ! } // if we have axis2 data ! else { ! $axis2_data = false; ! } // else no axis2 data ! ! if ($this->GetValue('use_x_labels')) { ! $x_labels = $this->GetValue('x_labels'); ! } // if we are going to use x labels ! else { ! $x_labels = array(); ! } // else we are not using x labels ! ! // The x grid lines for bar charts is non standard since the bars are grouped by a value ! // so every value must be represented: ! // ! // Get all of the x data points ! // ! $this->x_data_points = array(); ! ! @reset($this->datasets); ! while (list($dataset_id, $data) = @each($this->datasets)) { ! @reset($data['x']); ! while (list(, $x_value) = @each($data['x'])) { ! $this->x_data_points["$x_value"] = $x_value; ! } // while we get all of the values ! } // while we step through the ! ! // We need the x min and x max pos to get the spacing for the grid lines ! // ! $this->GetImageLocation($this->GetValue('x_min'),$this->GetValue('y_min'),$x_min_pos, $y_min_pos); ! $this->GetImageLocation($this->GetValue('x_max'),$this->GetValue('y_max'),$x_max_pos, $y_max_pos); ! ! $per_grid_space = ($x_max_pos - $x_min_pos) / sizeof($this->x_data_points); ! ! // Now setup the grid labels ! // ! @asort($this->x_data_points); ! while (list($value, $label) = @each($this->x_data_points)) { ! if (isset($x_labels["$value"])) { ! $label = $x_labels["$value"]; ! } // if this has a label ! else { ! $label = $value; ! } // else no label, use the value ! ! $x_tick_list["$value"] = $this->FormatTextHorizontal($per_grid_space, $label); ! ! $this->x_max_tick_width = max($this->x_max_tick_width, $x_tick_list["$value"]['width']); ! $this->x_max_tick_height = max($this->x_max_tick_height, $x_tick_list["$value"]['height']); ! } // while we step through all unique values ! ! // Now we can set up the y grid ! // ! $this->SetupYGrid($axis2_data); ! ! $this->GetImageLocation($this->GetValue('x_min'),$this->GetValue('y_min'),$x_min_pos, $y_min_pos); ! $this->GetImageLocation($this->GetValue('x_max'),$this->GetValue('y_max'),$x_max_pos, $y_max_pos); ! ! // Let's draw the x axis ! // ! $i = 0; ! while (list($value, $string_info) = @each($x_tick_list)) { ! $x_pos = $x_min_pos + ++$i * $per_grid_space; ! $this->image_object->DrawLine($x_pos, $y_min_pos - ($this->GetValue('x_tick_length') / 2), ! $x_pos, $y_min_pos + ($this->GetValue('x_tick_length') / 2), ! $this->GetColor($this->GetValue('x_tick_color'))); ! ! $this->DrawString($string_info, $x_pos - $per_grid_space / 2, $y_min_pos + $this->GetValue('x_axis_padding'), 'black'); ! } // while - we are stepping through the x data labels ! ! // Now let's draw the y axis ! // ! $this->DrawYGrid($x_min_pos, $x_max_pos); ! ! // This is a non standard x axis so let's set it up here ! // ! ! // echo("<pre>\n");print_r($this->x_data_points);die(); ! ! // Draw the x and y axis ! // ! $this->image_object->DrawLine($x_min_pos, $y_min_pos, $x_min_pos, $y_max_pos, $this->GetColor($this->GetValue('axis_color'))); ! $this->image_object->DrawLine($x_max_pos, $y_min_pos, $x_max_pos, $y_max_pos, $this->GetColor($this->GetValue('axis_color'))); ! $this->image_object->DrawLine($x_min_pos, $y_max_pos, $x_max_pos, $y_max_pos, $this->GetColor($this->GetValue('axis_color'))); ! $this->image_object->DrawLine($x_min_pos, $y_min_pos, $x_max_pos, $y_min_pos, $this->GetColor($this->GetValue('axis_color'))); ! ! $this->DrawTitle(); ! $this->DrawSubtitle(); ! $this->DrawXTitle(); ! $this->DrawYTitle(); ! ! if ($axis2_data) { ! $this->DrawAxis2Title(); ! } // if we have axis2 data ! } // function DrawVertGrid ! ! ! function DrawHorizontalBarGrid() { ! } // function DrawHorizGrid ! ! } // class Chart Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** Graph.class 2001/12/06 22:13:37 1.11 --- Graph.class 2001/12/11 22:31:13 1.12 *************** *** 29,32 **** --- 29,34 ---- $this->InitializePrimitives(); + + $this->DEFAULTS['vert_bar_width'] = 8; } // function Graph *************** *** 45,321 **** $this->ValidateExtents(); - // First let's focus on the x axis. - // If the user has assigned either a max or a minimum, those values will be used at - // the appropriate edge of the graph. Otherwise, "nice" values will be determined for better looking graphs. - // - if ($this->GetValue('use_x_labels')) { - $integer = true; - $x_labels = $this->GetValue('x_labels'); - } // if we are going to use x labels - else { - $integer = false; - $x_labels = array(); - } // else we are not using x labels - - if (!$this->IsUserValue('x_tick') || ($this->GetValue('x_data_diff') / $this->GetValue('x_tick') > ($this->width / $this->text_size['width']))) { - $this->SetValue('num_x_grid', ceil(min($this->GetValue('num_x_grid'), $this->width / $this->text_size['width'])), true); - $this->SetValue('x_tick', $this->GetTick($this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'), $integer)); - } // if a value for x_tick was defined - - if (!$this->IsUserValue('num_x_grid')) { - $this->SetValue('num_x_grid', ceil($this->GetValue('x_data_diff') / $this->GetValue('x_tick'))); - } // else if the number of grid lines is not specified - - if (!$this->IsUserValue('x_min')) { - $this->SetValue('x_min',$this->GetAxisMin($this->GetValue('x_min'), $this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'))); - } // if the user has not assigned a custom x min value - - if (!$this->IsUserValue('x_max')) { - $this->SetValue('x_max', $this->GetValue('x_min') + $this->GetValue('x_tick') * $this->GetValue('num_x_grid')); - } // if the user has not assigned a custom x max value - - // Now let's focus on the y axis. - // - if ($this->GetValue('use_y_labels')) { - $integer = true; - $y_labels = $this->GetValue('y_labels'); - } // if we are going to use y labels - else { - $integer = false; - $y_labels = array(); - } // else we are not using y labels - - if (!$this->IsUserValue('y_tick')) { - $this->SetValue('y_tick', $this->GetTick($this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'), $integer)); - } // if a value for y_tick was defined - - if ($this->GetValue('y_data_diff') / $this->GetValue('y_tick') > ($this->height / $this->text_size['height'])) { - $this->SetValue('num_y_grid', ceil($this->height / $this->text_size['height']), true); - $this->SetValue('y_max', $this->GetValue('y_min') + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); - } // if there are too many grid lines - - if (!$this->IsUserValue('num_y_grid')) { - $this->SetValue('num_y_grid', ceil($this->GetValue('y_data_diff') / $this->GetValue('y_tick'))); - } // else if the number of grid lines is not specified - - if (!$this->IsUserValue('y_min')) { - $this->SetValue('y_min',$this->GetAxisMin($this->GetValue('y_min'), $this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'))); - } // if the user has not assigned a custom y min value - - if (!$this->IsUserValue('y_max')) { - $this->SetValue('y_max', $this->GetValue('y_min') + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); - } // if the user has not assigned a custom y max value - - // Let's get the first points - // - if ($this->GetValue('x_min') < 0) { - $x_round = ROUND_DOWN; - } else { - $x_round = ROUND_UP; - } // if...else... - - if ($this->GetValue('y_min') < 0) { - $y_round = ROUND_DOWN; - } else { - $y_round = ROUND_UP; - } // if...else... - - $x_max_tick_width = 0; - $y_max_tick_width = 0; - - $x_max_tick_height = 0; - - // Now just make sure that the min's and max's line up - // - if (!$this->IsUserValue('x_max')) { - $this->SetXMax($this->GetValue('x_min') + $this->GetValue('x_tick') * $this->GetValue('num_x_grid')); - } // if this is not a user value - - if (!$this->IsUserValue('y_max')) { - $this->SetYMax($this->GetValue('y_min') + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); - } // if this is not a user value - - // We have to wait to calculate axis2 information since it is so dependant on the position of the y grid lines - // if (is_array($this->axis2_data) && sizeof($this->axis2_data)) { ! if ($this->GetValue('use_axis2_labels')) { ! $integer = true; ! $axis2_labels = $this->GetValue('axis2_labels'); ! } // if we are going to use x labels ! else { ! $integer = false; ! $axis2_labels = array(); ! } // else we are not using x labels ! ! // Get the actual number of y grid lines ! // ! $num_y_grid = $this->GetValue('y_data_diff') / $this->GetValue('y_tick'); ! $axis2_data = true; ! ! $this->SetValue('axis2_min', $this->AdjustNum($this->GetValue('axis2_min'), $this->GetValue('axis2_data_diff'), ROUND_DOWN)); ! ! if ($this->IsUserValue('axis2_tick')) { ! $new_axis2_max = $this->GetValue('axis2_min') + $this->GetValue('axis2_tick') * $num_y_grid; ! } // if the user has modified the axis2 tick ! else { ! $axis2_tick = $this->GetTick($this->GetValue('axis2_data_diff'), $num_y_grid, $integer); ! $new_axis2_max = $axis2_tick * $num_y_grid + $this->GetValue('axis2_min'); ! ! $this->SetValue('axis2_tick', $axis2_tick); ! } // else we are creating our own tick ! ! $axis2_tick = $this->GetValue('axis2_min'); ! $this->SetValue('axis2_max', $new_axis2_max); } // if we have axis2 data else { $axis2_data = false; } // else no axis2 data - ! // In order to draw everything right, we need to get the sizes of the tick marks before we display them ! // this way, we can pad the left and right side of the graph accordingly ! // ! $x_tick_list = array(); ! $x_tick_sizes = array(); ! $y_tick_list = array(); ! $y_tick_sizes = array(); ! $axis2_tick_list = array(); ! $axis2_tick_sizes = array(); ! ! $this->GetImageLocation($this->GetValue('x_tick'), 0, $min_tick_pos, $foo_y); ! $this->GetImageLocation(2 * $this->GetValue('x_tick'), 0, $max_tick_pos, $foo_y); ! $tick_pixel_space = $max_tick_pos - $min_tick_pos; ! ! $decimals = max(abs(floor(log10($this->GetValue('x_tick')))), $this->GetValue('grid_precision')); ! for ($x_tick = $this->GetValue('x_min'); round($this->GetValue('x_max') - $x_tick, $decimals) >= 0; $x_tick = round($this->GetValue('x_tick') + $x_tick, $decimals)) { ! if (isset($x_labels["$x_tick"])) { ! $label = $x_labels["$x_tick"]; ! } // if we have a label for this tick ! else if (sizeof($x_labels)) { ! $label = $this->GetValue('no_label_char'); ! } // else if there are other labels ! else { ! $label = $x_tick; ! } // else we don't have a label, use the tick ! ! $x_tick_list["$x_tick"] = $label; ! $x_tick_sizes["$label"] = $this->image_object->GetTextSize($label, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('x_tick_font'))); ! $x_max_tick_height = max($x_max_tick_height, $x_tick_sizes["$label"]['height']); ! $x_max_tick_width = max($x_max_tick_width, $x_tick_sizes["$label"]['width']); ! $last_x_tick = $x_tick; ! } // for ! ! if ($tick_pixel_space) { ! $x_tick_mod = ceil($x_max_tick_width / $tick_pixel_space); ! } else { ! $x_tick_mod = 1; ! } // if...else... make sure that we have a pixel space ! ! $decimals = max(abs(floor(log10($this->GetValue('y_tick')))), $this->GetValue('grid_precision')); ! $decimals2 = max(abs(floor(log10($this->GetValue('axis2_tick')))), $this->GetValue('grid_precision')); ! ! for ($y_tick = $this->GetValue('y_min'); round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { ! if (isset($y_labels["$y_tick"])) { ! $label = $y_labels["$y_tick"]; ! } // if we have a label for this tick ! else if (sizeof($y_labels)) { ! $label = $this->GetValue('no_label_char'); ! } // else if there are other labels ! else { ! $label = $y_tick; ! } // else we don't have a label, use the tick ! ! $y_tick_list["$y_tick"] = $label; ! $y_tick_sizes["$label"] = $this->image_object->GetTextSize($label, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('y_tick_font'))); ! $y_max_tick_width = max($y_max_tick_width, $y_tick_sizes["$label"]['width']); ! $y_max_tick_height = max($y_max_tick_width, $y_tick_sizes["$label"]['height']); ! ! if ($axis2_data) { ! if (isset($axis2_labels["$axis2_tick"])) { ! $label = $axis2_labels["$axis2_tick"]; ! } // if we have a label for this tick ! else if (sizeof($axis2_labels)) { ! $label = $this->GetValue('no_label_char'); ! } // else if there are other labels ! else { ! $label = $axis2_tick; ! } // else we don't have a label, use the tick ! ! $axis2_tick_list["$axis2_tick"] = $label; ! $axis2_tick_sizes["$label"] = $this->image_object->GetTextSize($label, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('axis2_tick_font'))); ! $axis2_max_tick_width = max($axis2_max_tick_width, $axis2_tick_sizes["$label"]['width']); ! $axis2_max_tick_height = max($axis2_max_tick_height, $axis2_tick_sizes["$label"]['height']); ! ! $axis2_tick = round($this->GetValue('axis2_tick') + $axis2_tick, $decimals2); ! } // if we have axis2 data ! } // for ! ! $this->SetValue('y_top_padding', $this->GetValue('y_top_padding') + max($y_max_tick_height, $axis2_max_tick_height) / 2); ! ! if ($axis2_data) { ! $this->SetValue('x_right_padding', 0); ! } // if we have axis2 data, that should push out the graph enough for the text ! else { ! $this->SetValue('x_right_padding', $x_tick_sizes[$x_tick_list["$last_x_tick"]]['width'] / 2); ! } // else we don't have axis2 data so we need to push out the edge of the graph depending on the size of the last legend ! ! $this->y_tick_padding = $y_max_tick_width + $this->GetValue('y_axis_padding') + $this->GetValue('y_tick_length') / 2; ! $this->axis2_tick_padding = $axis2_max_tick_width + $this->GetValue('axis2_padding') + $this->GetValue('axis2_tick_length') / 2; ! $this->x_tick_padding = $x_max_tick_height + $this->GetValue('x_axis_padding'); ! ! // We have to make sure that there are no strange precision errors here ! // $this->GetImageLocation($this->GetValue('x_min'),$this->GetValue('y_min'),$x_min_pos, $y_min_pos); $this->GetImageLocation($this->GetValue('x_max'),$this->GetValue('y_max'),$x_max_pos, $y_max_pos); - - // Draw the x_axis tick marks - // - $count = -1; - while (list($x_tick, $label) = @each($x_tick_list)) { - $text_size = $x_tick_sizes["$label"]; - $this->GetImageLocation($x_tick, $this->GetValue('y_min'), $x_pos, $y_pos); - - $this->image_object->DrawDashedLine($x_pos, $y_min_pos, $x_pos, $y_max_pos, $this->GetValue('y_grid_dash_length'),$this->GetValue('y_grid_dash_space'), $this->GetColor($this->GetValue('grid_color'))); - $this->image_object->DrawLine($x_pos, $y_min_pos + $this->GetValue('x_tick_length') / 2, $x_pos, $y_min_pos - $this->GetValue('x_tick_length') / 2, $this->GetColor($this->GetValue('x_tick_color'))); - - $x_pos -= ($text_size['width'] / 2); - $y_pos = $y_min_pos + $this->GetValue('x_axis_padding'); - - if (++$count % $x_tick_mod == 0) { - $this->image_object->DrawText($this->GetFont($this->GetValue('x_tick_font')), $x_pos, $y_pos, $label, $this->GetColor($this->GetValue('x_tick_color')), TEXT_HORIZONTAL); - } // if we are drawing this tick mark - } // for ! // Draw the y-axis tick marks ! // ! while (list($y_tick, $label) = @each($y_tick_list)) { ! $text_size = $y_tick_sizes["$label"]; ! $this->GetImageLocation($this->GetValue('x_min'), $y_tick, $x_pos, $y_pos); ! ! if ($y_tick > $this->GetValue('y_min')) { ! $this->image_object->DrawDashedLine($x_min_pos, $y_pos, $x_max_pos, $y_pos, $this->GetValue('x_grid_dash_length'),$this->GetValue('x_grid_dash_space'), $this->GetColor($this->GetValue('grid_color'))); ! } // only draw the dashed line if it is not the lowest point ! ! $this->image_object->DrawLine($x_pos - $this->GetValue('y_tick_length') / 2, $y_pos, $x_pos + $this->GetValue('y_tick_length') / 2, $y_pos, $this->GetColor($this->GetValue('y_tick_color'))); ! ! $x_pos -= ($text_size['width'] + $this->GetValue('y_axis_padding') + $this->GetValue('y_tick_length') / 2); ! $y_pos -= ($text_size['height'] / 2); ! ! $this->image_object->DrawText($this->GetFont($this->GetValue('y_tick_font')), $x_pos, $y_pos, $label, $this->GetColor($this->GetValue('y_tick_color')), TEXT_HORIZONTAL); ! } // for ! ! // Draw the y-axis tick marks ! // ! while (list($axis2_tick, $label) = @each($axis2_tick_list)) { ! $text_size = $axis2_tick_sizes["$label"]; ! $this->GetImageLocation($this->GetValue('x_max'), $axis2_tick, $x_pos, $y_pos, true); ! ! $this->image_object->DrawLine($x_pos - $this->GetValue('axis2_tick_length') / 2, $y_pos, $x_pos + $this->GetValue('axis2_tick_length') / 2, $y_pos, $this->GetColor($this->GetValue('axis2_tick_color'))); ! ! $x_pos += $this->GetValue('axis2_padding') + $this->GetValue('axis2_tick_length') / 2; ! $y_pos -= ($text_size['height'] / 2); ! ! $this->image_object->DrawText($this->GetFont($this->GetValue('axis2_tick_font')), $x_pos, $y_pos, $label, $this->GetColor($this->GetValue('axis2_tick_color')), TEXT_HORIZONTAL); ! } // for // Draw the x and y axis --- 47,65 ---- $this->ValidateExtents(); if (is_array($this->axis2_data) && sizeof($this->axis2_data)) { ! $axis2_data = true; } // if we have axis2 data else { $axis2_data = false; } // else no axis2 data ! $this->SetupXGrid($axis2_data); ! $this->SetupYGrid($axis2_data); ! $this->GetImageLocation($this->GetValue('x_min'),$this->GetValue('y_min'),$x_min_pos, $y_min_pos); $this->GetImageLocation($this->GetValue('x_max'),$this->GetValue('y_max'),$x_max_pos, $y_max_pos); ! $this->DrawXGrid($y_min_pos, $y_max_pos); ! $this->DrawYGrid($x_min_pos, $x_max_pos); // Draw the x and y axis *************** *** 334,338 **** $this->DrawAxis2Title(); } // if we have axis2 data - } // function DrawGrid --- 78,81 ---- Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ImagePrimitives.class 2001/12/06 02:32:59 1.9 --- ImagePrimitives.class 2001/12/11 22:31:13 1.10 *************** *** 138,142 **** // $this->DEFAULTS['hide_legend'] = false; - $this->DEFAULTS['vert_bar_width'] = 8; $this->DEFAULTS['dashed_line_length'] = 4; $this->DEFAULTS['dashed_line_space'] = 3; --- 138,141 ---- *************** *** 144,149 **** $this->DEFAULTS['legend_sample_height'] = 10; $this->DEFAULTS['legend_background_alpha'] = 180; ! $this->DEFAULTS['legend_top'] = -1; // it will adjust to the bottom left corner ! $this->DEFAULTS['legend_left'] = -1; // $this->DEFAULTS['no_data_string'] = "No Data Available"; --- 143,148 ---- $this->DEFAULTS['legend_sample_height'] = 10; $this->DEFAULTS['legend_background_alpha'] = 180; ! $this->DEFAULTS['legend_top'] = LEGEND_GRAPH_BOTTOM; // it will adjust to the bottom left corner ! $this->DEFAULTS['legend_left'] = LEGEND_GRAPH_LEFT; // $this->DEFAULTS['no_data_string'] = "No Data Available"; *************** *** 294,298 **** } // if we have an y_title ! $horizontal_space = 2 * $this->GetValue('x_padding') + $this->GetValue('y_tick_padding') + $y_title_padding + $axis2_padding + $axis2_title_padding + $this->GetValue('x_right_padding'); $vertical_space = $this->GetValue('y_padding') + $this->GetValue('y_top_padding') + $this->GetValue('y_bottom_padding') + $this->GetValue('x_tick_padding') + $title_padding + $x_title_padding; --- 293,297 ---- } // if we have an y_title ! $horizontal_space = 2 * $this->GetValue('x_padding') + $this->GetValue('y_tick_padding') + $y_title_padding + $axis2_padding + max($axis2_title_padding, $this->GetValue('x_right_padding')); $vertical_space = $this->GetValue('y_padding') + $this->GetValue('y_top_padding') + $this->GetValue('y_bottom_padding') + $this->GetValue('x_tick_padding') + $title_padding + $x_title_padding; *************** *** 434,438 **** } // else just point to the specified y_max ! if ((!$y_min >= $this->GetValue($axis_max)) || ($y_max <= $this->GetValue($axis_min)) || ($x_min >= $this->GetValue('x_max')) || ($x_max <= $this->GetValue('x_min'))) { $this->drawn_highlights[$highlight_id] = false; return false; --- 433,437 ---- } // else just point to the specified y_max ! if (($y_min >= $this->GetValue($axis_max)) || ($y_max <= $this->GetValue($axis_min)) || ($x_min >= $this->GetValue('x_max')) || ($x_max <= $this->GetValue('x_min'))) { $this->drawn_highlights[$highlight_id] = false; return false; *************** *** 1378,1381 **** --- 1377,1723 ---- } // while we step through the legend map } // function DrawLegend + + + /** + * SetupXGrid sets up a standard x axis with normally spaced tick marks that represent exact + * values (for graphs, not charts where groups of data have a value) + * + * @author Ariel Garza (ag...@va...) + */ + function SetupXGrid() { + // First let's focus on the x axis. + // If the user has assigned either a max or a minimum, those values will be used at + // the appropriate edge of the graph. Otherwise, "nice" values will be determined for better looking graphs. + // + if ($this->GetValue('use_x_labels')) { + $integer = true; + $x_labels = $this->GetValue('x_labels'); + } // if we are going to use x labels + else { + $integer = false; + $x_labels = array(); + } // else we are not using x labels + + if (!$this->IsUserValue('x_tick') || ($this->GetValue('x_data_diff') / $this->GetValue('x_tick') > ($this->width / $this->text_size['width']))) { + $this->SetValue('num_x_grid', ceil(min($this->GetValue('num_x_grid'), $this->width / $this->text_size['width'])), true); + $this->SetValue('x_tick', $this->GetTick($this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'), $integer)); + } // if a value for x_tick was defined + + if (!$this->IsUserValue('num_x_grid')) { + $this->SetValue('num_x_grid', ceil($this->GetValue('x_data_diff') / $this->GetValue('x_tick'))); + } // else if the number of grid lines is not specified + + if (!$this->IsUserValue('x_min')) { + $this->SetValue('x_min',$this->GetAxisMin($this->GetValue('x_min'), $this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'))); + } // if the user has not assigned a custom x min value + + if (!$this->IsUserValue('x_max')) { + $this->SetValue('x_max', $this->GetValue('x_min') + $this->GetValue('x_tick') * $this->GetValue('num_x_grid')); + } // if the user has not assigned a custom x max value + + $this->x_max_tick_width = 0; + $this->x_max_tick_height = 0; + + // Now just make sure that the min's and max's line up + // + if (!$this->IsUserValue('x_max')) { + $this->SetXMax($this->GetValue('x_min') + $this->GetValue('x_tick') * $this->GetValue('num_x_grid')); + } // if this is not a user value + + // Set up the tick arrays + // + $this->x_tick_list = array(); + $this->x_tick_sizes = array(); + + $this->GetImageLocation($this->GetValue('x_tick'), 0, $min_tick_pos, $foo_y); + $this->GetImageLocation(2 * $this->GetValue('x_tick'), 0, $max_tick_pos, $foo_y); + $tick_pixel_space = $max_tick_pos - $min_tick_pos; + + $decimals = max(abs(floor(log10($this->GetValue('x_tick')))), $this->GetValue('grid_precision')); + for ($x_tick = $this->GetValue('x_min'); round($this->GetValue('x_max') - $x_tick, $decimals) >= 0; $x_tick = round($this->GetValue('x_tick') + $x_tick, $decimals)) { + if (isset($x_labels["$x_tick"])) { + $label = $x_labels["$x_tick"]; + } // if we have a label for this tick + else if (sizeof($x_labels)) { + $label = $this->GetValue('no_label_char'); + } // else if there are other labels + else { + $label = $x_tick; + } // else we don't have a label, use the tick + + $this->x_tick_list["$x_tick"] = $label; + $this->x_tick_sizes["$label"] = $this->image_object->GetTextSize($label, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('x_tick_font'))); + $this->x_max_tick_height = max($this->x_max_tick_height, $this->x_tick_sizes["$label"]['height']); + $this->x_max_tick_width = max($this->x_max_tick_width, $this->x_tick_sizes["$label"]['width']); + $last_x_tick = $x_tick; + } // for + + if ($tick_pixel_space) { + $x_tick_mod = ceil($this->x_max_tick_width / $tick_pixel_space); + } else { + $x_tick_mod = 1; + } // if...else... make sure that we have a pixel space + + if ($axis2_data) { + $this->SetValue('x_right_padding', 0); + } // if we have axis2 data, that should push out the graph enough for the text + else { + $this->SetValue('x_right_padding', $this->x_tick_sizes[$this->x_tick_list["$last_x_tick"]]['width'] / 2); + } // else we don't have axis2 data so we need to push out the edge of the graph depending on the size of the last legend + + } // function SetupXGrid + + + /** + * SetupYGrid sets up a standard y axis (with axis2) with normally spaced tick marks that represent exact + * values (for graphs, not charts with horizontal bars) + * + * @author Ariel Garza (ag...@va...) + */ + function SetupYGrid($axis2_data) { + if ($this->GetValue('use_y_labels')) { + $integer = true; + $y_labels = $this->GetValue('y_labels'); + } // if we are going to use y labels + else { + $integer = false; + $y_labels = array(); + } // else we are not using y labels + + if (!$this->IsUserValue('y_tick')) { + $this->SetValue('y_tick', $this->GetTick($this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'), $integer)); + } // if a value for y_tick was defined + + if ($this->GetValue('y_data_diff') / $this->GetValue('y_tick') > ($this->height / $this->text_size['height'])) { + $this->SetValue('num_y_grid', ceil($this->height / $this->text_size['height']), true); + $this->SetValue('y_max', $this->GetValue('y_min') + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); + } // if there are too many grid lines + + if (!$this->IsUserValue('num_y_grid')) { + $this->SetValue('num_y_grid', ceil($this->GetValue('y_data_diff') / $this->GetValue('y_tick'))); + } // else if the number of grid lines is not specified + + if (!$this->IsUserValue('y_min')) { + $this->SetValue('y_min',$this->GetAxisMin($this->GetValue('y_min'), $this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'))); + } // if the user has not assigned a custom y min value + + if (!$this->IsUserValue('y_max')) { + $this->SetValue('y_max', $this->GetValue('y_min') + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); + } // if the user has not assigned a custom y max value + + $y_max_tick_width = 0; + + if (!$this->IsUserValue('y_max')) { + $this->SetYMax($this->GetValue('y_min') + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); + } // if this is not a user value + + // We have to wait to calculate axis2 information since it is so dependant on the position of the y grid lines + // + if ($axis2_data) { + if ($this->GetValue('use_axis2_labels')) { + $integer = true; + $axis2_labels = $this->GetValue('axis2_labels'); + } // if we are going to use x labels + else { + $integer = false; + $axis2_labels = array(); + } // else we are not using x labels + + // Get the actual number of y grid lines + // + $num_y_grid = $this->GetValue('y_data_diff') / $this->GetValue('y_tick'); + + $this->SetValue('axis2_min', $this->AdjustNum($this->GetValue('axis2_min'), $this->GetValue('axis2_data_diff'), ROUND_DOWN)); + + if ($this->IsUserValue('axis2_tick')) { + $new_axis2_max = $this->GetValue('axis2_min') + $this->GetValue('axis2_tick') * $num_y_grid; + } // if the user has modified the axis2 tick + else { + $axis2_tick = $this->GetTick($this->GetValue('axis2_data_diff'), $num_y_grid, $integer); + $new_axis2_max = $axis2_tick * $num_y_grid + $this->GetValue('axis2_min'); + + $this->SetValue('axis2_tick', $axis2_tick); + } // else we are creating our own tick + + $axis2_tick = $this->GetValue('axis2_min'); + $this->SetValue('axis2_max', $new_axis2_max); + } // if we have axis2 data + else { + $axis2_data = false; + } // else no axis2 data + + + // In order to draw everything right, we need to get the sizes of the tick marks before we display them + // this way, we can pad the left and right side of the graph accordingly + // + $this->y_tick_list = array(); + $this->y_tick_sizes = array(); + $this->axis2_tick_list = array(); + $this->axis2_tick_sizes = array(); + + $decimals = max(abs(floor(log10($this->GetValue('y_tick')))), $this->GetValue('grid_precision')); + $decimals2 = max(abs(floor(log10($this->GetValue('axis2_tick')))), $this->GetValue('grid_precision')); + + for ($y_tick = $this->GetValue('y_min'); round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { + if (isset($y_labels["$y_tick"])) { + $label = $y_labels["$y_tick"]; + } // if we have a label for this tick + else if (sizeof($y_labels)) { + $label = $this->GetValue('no_label_char'); + } // else if there are other labels + else { + $label = $y_tick; + } // else we don't have a label, use the tick + + $this->y_tick_list["$y_tick"] = $label; + $this->y_tick_sizes["$label"] = $this->image_object->GetTextSize($label, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('y_tick_font'))); + $y_max_tick_width = max($y_max_tick_width, $this->y_tick_sizes["$label"]['width']); + $y_max_tick_height = max($y_max_tick_width, $this->y_tick_sizes["$label"]['height']); + + if ($axis2_data) { + if (isset($axis2_labels["$axis2_tick"])) { + $label = $axis2_labels["$axis2_tick"]; + } // if we have a label for this tick + else if (sizeof($axis2_labels)) { + $label = $this->GetValue('no_label_char'); + } // else if there are other labels + else { + $label = $axis2_tick; + } // else we don't have a label, use the tick + + $this->axis2_tick_list["$axis2_tick"] = $label; + $this->axis2_tick_sizes["$label"] = $this->image_object->GetTextSize($label, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('axis2_tick_font'))); + $axis2_max_tick_width = max($axis2_max_tick_width, $this->axis2_tick_sizes["$label"]['width']); + $axis2_max_tick_height = max($axis2_max_tick_height, $this->axis2_tick_sizes["$label"]['height']); + + $axis2_tick = round($this->GetValue('axis2_tick') + $axis2_tick, $decimals2); + } // if we have axis2 data + } // for + + $this->SetValue('y_top_padding', $this->GetValue('y_top_padding') + max($y_max_tick_height, $axis2_max_tick_height) / 2); + + $this->y_tick_padding = $y_max_tick_width + $this->GetValue('y_axis_padding') + $this->GetValue('y_tick_length') / 2; + $this->axis2_tick_padding = $axis2_max_tick_width + $this->GetValue('axis2_padding') + $this->GetValue('axis2_tick_length') / 2; + $this->x_tick_padding = $this->GetValue('x_max_tick_height') + $this->GetValue('x_axis_padding'); + } // function SetupYGrid + + + /** + * Draws the standard x grid + */ + function DrawXGrid($y_min_pos, $y_max_pos) { + // Draw the x_axis tick marks + // + $count = -1; + while (list($x_tick, $label) = @each($this->x_tick_list)) { + $text_size = $this->x_tick_sizes["$label"]; + $this->GetImageLocation($x_tick, $this->GetValue('y_min'), $x_pos, $y_pos); + + $this->image_object->DrawDashedLine($x_pos, $y_min_pos, $x_pos, $y_max_pos, $this->GetValue('y_grid_dash_length'),$this->GetValue('y_grid_dash_space'), $this->GetColor($this->GetValue('grid_color'))); + $this->image_object->DrawLine($x_pos, $y_min_pos + $this->GetValue('x_tick_length') / 2, $x_pos, $y_min_pos - $this->GetValue('x_tick_length') / 2, $this->GetColor($this->GetValue('x_tick_color'))); + + $x_pos -= ($text_size['width'] / 2); + $y_pos = $y_min_pos + $this->GetValue('x_axis_padding'); + + if (++$count % $x_tick_mod == 0) { + $this->image_object->DrawText($this->GetFont($this->GetValue('x_tick_font')), $x_pos, $y_pos, $label, $this->GetColor($this->GetValue('x_tick_color')), TEXT_HORIZONTAL); + } // if we are drawing this tick mark + } // for + } // function DrawXGrid + + + /** + * DrawYGrid draws the standard y-axis/axis2 grid lines + * + */ + function DrawYGrid($x_min_pos, $x_max_pos) { + // Draw the y-axis tick marks + // + while (list($y_tick, $label) = @each($this->y_tick_list)) { + $text_size = $this->y_tick_sizes["$label"]; + $this->GetImageLocation($this->GetValue('x_min'), $y_tick, $x_pos, $y_pos); + + if ($y_tick > $this->GetValue('y_min')) { + $this->image_object->DrawDashedLine($x_min_pos, $y_pos, $x_max_pos, $y_pos, $this->GetValue('x_grid_dash_length'),$this->GetValue('x_grid_dash_space'), $this->GetColor($this->GetValue('grid_color'))); + } // only draw the dashed line if it is not the lowest point + + $this->image_object->DrawLine($x_pos - $this->GetValue('y_tick_length') / 2, $y_pos, $x_pos + $this->GetValue('y_tick_length') / 2, $y_pos, $this->GetColor($this->GetValue('y_tick_color'))); + + $x_pos -= ($text_size['width'] + $this->GetValue('y_axis_padding') + $this->GetValue('y_tick_length') / 2); + $y_pos -= ($text_size['height'] / 2); + + $this->image_object->DrawText($this->GetFont($this->GetValue('y_tick_font')), $x_pos, $y_pos, $label, $this->GetColor($this->GetValue('y_tick_color')), TEXT_HORIZONTAL); + } // for + + // Draw the y-axis tick marks + // + while (list($axis2_tick, $label) = @each($this->axis2_tick_list)) { + $text_size = $this->axis2_tick_sizes["$label"]; + $this->GetImageLocation($this->GetValue('x_max'), $axis2_tick, $x_pos, $y_pos, true); + + $this->image_object->DrawLine($x_pos - $this->GetValue('axis2_tick_length') / 2, $y_pos, $x_pos + $this->GetValue('axis2_tick_length') / 2, $y_pos, $this->GetColor($this->GetValue('axis2_tick_color'))); + + $x_pos += $this->GetValue('axis2_padding') + $this->GetValue('axis2_tick_length') / 2; + $y_pos -= ($text_size['height'] / 2); + + $this->image_object->DrawText($this->GetFont($this->GetValue('axis2_tick_font')), $x_pos, $y_pos, $label, $this->GetColor($this->GetValue('axis2_tick_color')), TEXT_HORIZONTAL); + } // for + } // function DrawYGrid + + + function FormatTextHorizontal($width, $string, $font = VAGRANT_DEFAULT_FONT) { + $lines = array(); + $heights = array(); + $words = explode(" ", $string); + $space = $this->image_object->GetTextSize(" ", TEXT_HORIZONTAL, $this->GetFont($font)); + + $max_width = 0; + $line_num = 0; + while (list(,$word) = @each($words)) { + $word_size = $this->image_object->GetTextSize($word, TEXT_HORIZONTAL, $this->GetFont($font)); + + if (!$max_height) { + $max_height = $word_size['height']; + } // if we have not set the height yet + + if (($lines[$line_num]['width'] + $space['width'] + $word_size['width']) > $width) { + // TODO: If the word alone is too long, split it up + // + ++$line_num; + $prefix = ""; + $prefix_space = 0; + } // if the existing line with this word is too long + else { + $prefix = " "; + $prefix_space = $space['width']; + } // else + + $lines[$line_num]['text'] .= $prefix . $word; + $lines[$line_num]['width'] += $word_size['width'] + $prefix_space; + $lines[$line_num]['height'] = max($word_size['height'], $lines[$line_num]['height']); + + $heights[$line_num] = $lines[$line_num]['height']; + $max_width = max($max_width, $lines[$line_num]['width']); + } // while we step through all of the words in this string + + return array('direction' => TEXT_HORIZONTAL, + 'font' => $font, + 'text' => $lines, + 'width' => $max_width, + 'height' => array_sum($heights)); + } // function FormatTextHorizontal + + + function DrawString($text_info, $x_center, $y_top, $color) { + $y_pos = $y_top; + + while (list(, $line_text) = @each($text_info['text'])) { + $x_pos = $x_center - ($line_text['width'] / 2); + $this->image_object->DrawText($this->GetFont($text_info['font']), $x_pos, $y_pos, $line_text['text'], + $this->GetColor($color), $text_info['direction']); + + $y_pos += $line_text['height']; + } // while we step through the lines of text + } // function DrawString } // class ImagePrimitives Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/VAGRANT.class,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** VAGRANT.class 2001/12/03 23:51:14 1.6 --- VAGRANT.class 2001/12/11 22:31:13 1.7 *************** *** 337,340 **** --- 337,366 ---- } // if we have graphs to draw + if (is_array($this->charts) && sizeof($this->charts)) { + @reset($this->charts); + while (list($chart_id,) = each($this->charts)) { + if ($this->added_data['charts'][$chart_id]) { + if ($this->charts[$chart_id]->ValidData()) { + while (list($dataset_id, $map) = @each($this->chart_map[$chart_id])) { + $this->charts[$chart_id]->DrawChart($dataset_id, $map['type'], $map['color'], $map['options']); + } // while we step through the data in this chart + + if (is_array($this->highlight_map[$chart_id]) && sizeof($this->highlight_map[$chart_id])) { + while (list($highlight_id,) = @each($this->highlight_map[$chart_id])) { + $this->charts[$chart_id]->DrawHighlight($highlight_id); + } // while we step through the highlights for this chart + } // if we have highlights to show + + if (is_array($this->legend_map[$chart_id]) && sizeof($this->legend_map[$chart_id])) { + $this->charts[$chart_id]->DrawLegend($this->legend_map[$chart_id]); + } // if we have legends to show + } // if this chart has valid data + } // if this chart had data added to it + else { + $this->charts[$chart_id]->ShowNoData($object_id); + } // else show that no data was added + } // while we step through the charts + } // if we have charts to draw + $this->image_object->DrawImage(); } // function DisplayImage *************** *** 388,391 **** --- 414,447 ---- } // if this is a valid object id } // function SetGraphType + + + /** + * SetChartType is where the options for the graph are actually set up. + * These options include color, graph type, and legend title + * + * @author Ariel Garza (ag...@va...) + * @param string $chart_id The id of the chart you are adding data for + * @param string $dataset_id The dataset that this chart is for + * @param string $type The type of chart that will represent the data + * @param string $color The color of the chart that will represent the data + * @param array $options Any options you wish to include for the chart. Valid options include: + * alpha (integer) -> The alpha value for the color being used in the chart + * legend_title (string) -> The title to be displayed in the legend + * legend_color (string) -> The color for the title to be displayed in the legend + * shape (string) -> If type is "scatter", this is the shape to use (circle, triangle, rect) default is rect + */ + function SetChartType($chart_id, $dataset_id, $type, $color, $options = array()) { + $object_array = $this->GetObjectArrayFromID($chart_id); + + if ($object_array && $dataset_id) { + $this->chart_map[$chart_id][$dataset_id]['type'] = $type; + $this->chart_map[$chart_id][$dataset_id]['color'] = $color; + $this->chart_map[$chart_id][$dataset_id]['options'] = $options; + + if ($options['legend_title']) { + $this->legend_map[$chart_id][$dataset_id] = &$this->chart_map[$chart_id][$dataset_id]; + } // if we are adding this to the legend + } // if this is a valid object id + } // function SetChartType } // class VAGRANT |
From: Ariel G. <ag...@us...> - 2001-12-06 22:13:39
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv18416 Modified Files: Graph.class Log Message: label's were checking for if () instead of if (isset()) so that labels that were 0 evaluated to false instead of true. Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** Graph.class 2001/12/06 19:39:10 1.10 --- Graph.class 2001/12/06 22:13:37 1.11 *************** *** 189,193 **** $decimals = max(abs(floor(log10($this->GetValue('x_tick')))), $this->GetValue('grid_precision')); for ($x_tick = $this->GetValue('x_min'); round($this->GetValue('x_max') - $x_tick, $decimals) >= 0; $x_tick = round($this->GetValue('x_tick') + $x_tick, $decimals)) { ! if ($x_labels["$x_tick"]) { $label = $x_labels["$x_tick"]; } // if we have a label for this tick --- 189,193 ---- $decimals = max(abs(floor(log10($this->GetValue('x_tick')))), $this->GetValue('grid_precision')); for ($x_tick = $this->GetValue('x_min'); round($this->GetValue('x_max') - $x_tick, $decimals) >= 0; $x_tick = round($this->GetValue('x_tick') + $x_tick, $decimals)) { ! if (isset($x_labels["$x_tick"])) { $label = $x_labels["$x_tick"]; } // if we have a label for this tick *************** *** 216,220 **** for ($y_tick = $this->GetValue('y_min'); round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { ! if ($y_labels["$y_tick"]) { $label = $y_labels["$y_tick"]; } // if we have a label for this tick --- 216,220 ---- for ($y_tick = $this->GetValue('y_min'); round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { ! if (isset($y_labels["$y_tick"])) { $label = $y_labels["$y_tick"]; } // if we have a label for this tick *************** *** 232,236 **** if ($axis2_data) { ! if ($axis2_labels["$axis2_tick"]) { $label = $axis2_labels["$axis2_tick"]; } // if we have a label for this tick --- 232,236 ---- if ($axis2_data) { ! if (isset($axis2_labels["$axis2_tick"])) { $label = $axis2_labels["$axis2_tick"]; } // if we have a label for this tick |
From: Ariel G. <ag...@us...> - 2001-12-06 19:39:14
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv2529 Modified Files: Graph.class Log Message: this should fix y-axis and axis2 tick issues Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** Graph.class 2001/12/06 02:32:58 1.9 --- Graph.class 2001/12/06 19:39:10 1.10 *************** *** 86,96 **** } // else we are not using y labels ! if (!$this->IsUserValue('y_tick') || ($this->GetValue('y_data_diff') / $this->GetValue('y_tick') > ($this->height / $this->text_size['height']))) { ! $this->SetValue('num_y_grid', ceil(min($this->GetValue('num_y_grid'), $this->height / $this->text_size['height'])), true); $this->SetValue('y_tick', $this->GetTick($this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'), $integer)); } // if a value for y_tick was defined if (!$this->IsUserValue('num_y_grid')) { ! $this->SetValue('num_y_grid', floor($this->GetValue('y_data_diff') / $this->GetValue('y_tick'))); } // else if the number of grid lines is not specified --- 86,100 ---- } // else we are not using y labels ! if (!$this->IsUserValue('y_tick')) { $this->SetValue('y_tick', $this->GetTick($this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'), $integer)); } // if a value for y_tick was defined + if ($this->GetValue('y_data_diff') / $this->GetValue('y_tick') > ($this->height / $this->text_size['height'])) { + $this->SetValue('num_y_grid', ceil($this->height / $this->text_size['height']), true); + $this->SetValue('y_max', $this->GetValue('y_min') + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); + } // if there are too many grid lines + if (!$this->IsUserValue('num_y_grid')) { ! $this->SetValue('num_y_grid', ceil($this->GetValue('y_data_diff') / $this->GetValue('y_tick'))); } // else if the number of grid lines is not specified *************** *** 146,175 **** // Get the actual number of y grid lines // ! $axis2_max_mod = $this->GetValue('y_data_diff') / $this->GetValue('y_tick'); ! $num_y_grid = floor($axis2_max_mod); ! ! // Set the modifier that will adjust the axis2 max in case the top grid line doesn't correspond to y max ! // ! $axis2_max_mod = $axis2_max_mod / $num_y_grid; ! $axis2_data = true; ! $new_axis2_min = $this->AdjustNum($this->GetValue('axis2_min'), $this->GetValue('axis2_data_diff'), ROUND_DOWN); if ($this->IsUserValue('axis2_tick')) { ! $axis2_mod = ceil(($this->GetValue('axis2_max') - $new_axis2_min) / ($this->GetValue('axis2_tick') * ($this->GetValue('num_y_grid') - 1))); ! $this->SetValue('axis2_tick', $this->GetValue('axis2_tick') * $axis2_mod); ! $new_axis2_max = $new_axis2_min + $this->GetValue('axis2_tick') * ($this->GetValue('num_y_grid')); } // if the user has modified the axis2 tick else { ! $new_axis2_max = $this->AdjustNum($this->GetValue('axis2_max'), $this->GetValue('axis2_data_diff'), ROUND_UP); ! $axis2_tick = $this->GetTick($new_axis2_max - $new_axis2_min, $this->GetValue('num_y_grid') - 1, $integer); ! $new_axis2_max = $new_axis2_min + $axis2_tick * $this->GetValue('num_y_grid'); $this->SetValue('axis2_tick', $axis2_tick); } // else we are creating our own tick ! $axis2_tick = $new_axis2_min; // this will be used for the axis labels on the right side of the grid ! $this->SetValue('axis2_min', $new_axis2_min); ! $this->SetValue('axis2_max', $new_axis2_max * $axis2_max_mod); } // if we have axis2 data else { --- 150,170 ---- // Get the actual number of y grid lines // ! $num_y_grid = $this->GetValue('y_data_diff') / $this->GetValue('y_tick'); $axis2_data = true; ! ! $this->SetValue('axis2_min', $this->AdjustNum($this->GetValue('axis2_min'), $this->GetValue('axis2_data_diff'), ROUND_DOWN)); if ($this->IsUserValue('axis2_tick')) { ! $new_axis2_max = $this->GetValue('axis2_min') + $this->GetValue('axis2_tick') * $num_y_grid; } // if the user has modified the axis2 tick else { ! $axis2_tick = $this->GetTick($this->GetValue('axis2_data_diff'), $num_y_grid, $integer); ! $new_axis2_max = $axis2_tick * $num_y_grid + $this->GetValue('axis2_min'); $this->SetValue('axis2_tick', $axis2_tick); } // else we are creating our own tick ! $axis2_tick = $this->GetValue('axis2_min'); ! $this->SetValue('axis2_max', $new_axis2_max); } // if we have axis2 data else { |
From: Ariel G. <ag...@us...> - 2001-12-06 02:33:01
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv22638 Modified Files: Graph.class ImagePrimitives.class Log Message: fixing various tick bugs. axis2 ticks are better but not right still (they don't run too high anymore but they are still off) Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** Graph.class 2001/12/04 19:24:34 1.8 --- Graph.class 2001/12/06 02:32:58 1.9 *************** *** 59,66 **** if (!$this->IsUserValue('x_tick') || ($this->GetValue('x_data_diff') / $this->GetValue('x_tick') > ($this->width / $this->text_size['width']))) { ! $this->SetValue('num_x_grid', ceil(min($this->GetValue('num_x_grid'), $this->width / $this->text_size['width']))); $this->SetValue('x_tick', $this->GetTick($this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'), $integer)); } // if a value for x_tick was defined if (!$this->IsUserValue('x_min')) { $this->SetValue('x_min',$this->GetAxisMin($this->GetValue('x_min'), $this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'))); --- 59,70 ---- if (!$this->IsUserValue('x_tick') || ($this->GetValue('x_data_diff') / $this->GetValue('x_tick') > ($this->width / $this->text_size['width']))) { ! $this->SetValue('num_x_grid', ceil(min($this->GetValue('num_x_grid'), $this->width / $this->text_size['width'])), true); $this->SetValue('x_tick', $this->GetTick($this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'), $integer)); } // if a value for x_tick was defined + if (!$this->IsUserValue('num_x_grid')) { + $this->SetValue('num_x_grid', ceil($this->GetValue('x_data_diff') / $this->GetValue('x_tick'))); + } // else if the number of grid lines is not specified + if (!$this->IsUserValue('x_min')) { $this->SetValue('x_min',$this->GetAxisMin($this->GetValue('x_min'), $this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'))); *************** *** 83,90 **** if (!$this->IsUserValue('y_tick') || ($this->GetValue('y_data_diff') / $this->GetValue('y_tick') > ($this->height / $this->text_size['height']))) { ! $this->SetValue('num_y_grid', ceil(min($this->GetValue('num_y_grid'), $this->height / $this->text_size['height']))); $this->SetValue('y_tick', $this->GetTick($this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'), $integer)); } // if a value for y_tick was defined if (!$this->IsUserValue('y_min')) { $this->SetValue('y_min',$this->GetAxisMin($this->GetValue('y_min'), $this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'))); --- 87,98 ---- if (!$this->IsUserValue('y_tick') || ($this->GetValue('y_data_diff') / $this->GetValue('y_tick') > ($this->height / $this->text_size['height']))) { ! $this->SetValue('num_y_grid', ceil(min($this->GetValue('num_y_grid'), $this->height / $this->text_size['height'])), true); $this->SetValue('y_tick', $this->GetTick($this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'), $integer)); } // if a value for y_tick was defined + if (!$this->IsUserValue('num_y_grid')) { + $this->SetValue('num_y_grid', floor($this->GetValue('y_data_diff') / $this->GetValue('y_tick'))); + } // else if the number of grid lines is not specified + if (!$this->IsUserValue('y_min')) { $this->SetValue('y_min',$this->GetAxisMin($this->GetValue('y_min'), $this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'))); *************** *** 95,100 **** } // if the user has not assigned a custom y max value ! // If we have axis2 data // if (is_array($this->axis2_data) && sizeof($this->axis2_data)) { if ($this->GetValue('use_axis2_labels')) { --- 103,137 ---- } // if the user has not assigned a custom y max value ! // Let's get the first points ! // ! if ($this->GetValue('x_min') < 0) { ! $x_round = ROUND_DOWN; ! } else { ! $x_round = ROUND_UP; ! } // if...else... ! ! if ($this->GetValue('y_min') < 0) { ! $y_round = ROUND_DOWN; ! } else { ! $y_round = ROUND_UP; ! } // if...else... ! ! $x_max_tick_width = 0; ! $y_max_tick_width = 0; ! ! $x_max_tick_height = 0; ! ! // Now just make sure that the min's and max's line up // + if (!$this->IsUserValue('x_max')) { + $this->SetXMax($this->GetValue('x_min') + $this->GetValue('x_tick') * $this->GetValue('num_x_grid')); + } // if this is not a user value + + if (!$this->IsUserValue('y_max')) { + $this->SetYMax($this->GetValue('y_min') + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); + } // if this is not a user value + + // We have to wait to calculate axis2 information since it is so dependant on the position of the y grid lines + // if (is_array($this->axis2_data) && sizeof($this->axis2_data)) { if ($this->GetValue('use_axis2_labels')) { *************** *** 107,132 **** } // else we are not using x labels ! $axis2_data = true; $new_axis2_min = $this->AdjustNum($this->GetValue('axis2_min'), $this->GetValue('axis2_data_diff'), ROUND_DOWN); if ($this->IsUserValue('axis2_tick')) { ! $axis2_mod = ceil(($this->GetValue('axis2_max') - $new_axis2_min) / ($this->GetValue('axis2_tick') * $this->GetValue('num_y_grid'))); $this->SetValue('axis2_tick', $this->GetValue('axis2_tick') * $axis2_mod); ! $new_axis2_max = $new_axis2_min + $this->GetValue('axis2_tick') * $this->GetValue('num_y_grid'); } // if the user has modified the axis2 tick else { $new_axis2_max = $this->AdjustNum($this->GetValue('axis2_max'), $this->GetValue('axis2_data_diff'), ROUND_UP); ! ! $axis2_tick = $this->GetTick($new_axis2_max - $new_axis2_min, $this->GetValue('num_y_grid'), $integer); $new_axis2_max = $new_axis2_min + $axis2_tick * $this->GetValue('num_y_grid'); $this->SetValue('axis2_tick', $axis2_tick); - - $axis2_tick = $new_axis2_min; // this will be used for the axis labels on the right side of the grid } // else we are creating our own tick $this->SetValue('axis2_min', $new_axis2_min); ! $this->SetValue('axis2_max', $new_axis2_max); } // if we have axis2 data else { --- 144,175 ---- } // else we are not using x labels ! // Get the actual number of y grid lines ! // ! $axis2_max_mod = $this->GetValue('y_data_diff') / $this->GetValue('y_tick'); ! $num_y_grid = floor($axis2_max_mod); + // Set the modifier that will adjust the axis2 max in case the top grid line doesn't correspond to y max + // + $axis2_max_mod = $axis2_max_mod / $num_y_grid; + + $axis2_data = true; $new_axis2_min = $this->AdjustNum($this->GetValue('axis2_min'), $this->GetValue('axis2_data_diff'), ROUND_DOWN); if ($this->IsUserValue('axis2_tick')) { ! $axis2_mod = ceil(($this->GetValue('axis2_max') - $new_axis2_min) / ($this->GetValue('axis2_tick') * ($this->GetValue('num_y_grid') - 1))); $this->SetValue('axis2_tick', $this->GetValue('axis2_tick') * $axis2_mod); ! $new_axis2_max = $new_axis2_min + $this->GetValue('axis2_tick') * ($this->GetValue('num_y_grid')); } // if the user has modified the axis2 tick else { $new_axis2_max = $this->AdjustNum($this->GetValue('axis2_max'), $this->GetValue('axis2_data_diff'), ROUND_UP); ! $axis2_tick = $this->GetTick($new_axis2_max - $new_axis2_min, $this->GetValue('num_y_grid') - 1, $integer); $new_axis2_max = $new_axis2_min + $axis2_tick * $this->GetValue('num_y_grid'); $this->SetValue('axis2_tick', $axis2_tick); } // else we are creating our own tick + $axis2_tick = $new_axis2_min; // this will be used for the axis labels on the right side of the grid $this->SetValue('axis2_min', $new_axis2_min); ! $this->SetValue('axis2_max', $new_axis2_max * $axis2_max_mod); } // if we have axis2 data else { *************** *** 134,176 **** } // else no axis2 data - // Let's get the first points - // - if ($this->GetValue('x_min') < 0) { - $x_round = ROUND_DOWN; - } else { - $x_round = ROUND_UP; - } // if...else... - if ($this->GetValue('y_min') < 0) { - $y_round = ROUND_DOWN; - } else { - $y_round = ROUND_UP; - } // if...else... - - $x_start = $this->AdjustNum($this->GetValue('x_min'), $this->GetValue('x_data_diff'), $x_round); - $x_max_tick_width = 0; - $x_max_tick_height = 0; - - $y_start = $this->AdjustNum($this->GetValue('y_min'), $this->GetValue('y_data_diff'), $y_round); - $y_max_tick_width = 0; - - // Now just make sure that the min's and max's line up - // - if (!$this->IsUserValue('x_min')) { - $this->SetXMin($x_start); - } // if this is not a user value - - if (!$this->IsUserValue('x_max')) { - $this->SetXMax($x_start + $this->GetValue('x_tick') * $this->GetValue('num_x_grid')); - } // if this is not a user value - - if (!$this->IsUserValue('y_min')) { - $this->SetYMin($y_start); - } // if this is not a user value - - if (!$this->IsUserValue('y_max')) { - $this->SetYMax($y_start + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); - } // if this is not a user value - // In order to draw everything right, we need to get the sizes of the tick marks before we display them // this way, we can pad the left and right side of the graph accordingly --- 177,181 ---- *************** *** 188,192 **** $decimals = max(abs(floor(log10($this->GetValue('x_tick')))), $this->GetValue('grid_precision')); ! for ($x_tick = $x_start; round($this->GetValue('x_max') - $x_tick, $decimals) >= 0; $x_tick = round($this->GetValue('x_tick') + $x_tick, $decimals)) { if ($x_labels["$x_tick"]) { $label = $x_labels["$x_tick"]; --- 193,197 ---- $decimals = max(abs(floor(log10($this->GetValue('x_tick')))), $this->GetValue('grid_precision')); ! for ($x_tick = $this->GetValue('x_min'); round($this->GetValue('x_max') - $x_tick, $decimals) >= 0; $x_tick = round($this->GetValue('x_tick') + $x_tick, $decimals)) { if ($x_labels["$x_tick"]) { $label = $x_labels["$x_tick"]; *************** *** 215,219 **** $decimals2 = max(abs(floor(log10($this->GetValue('axis2_tick')))), $this->GetValue('grid_precision')); ! for ($y_tick = $y_start; round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { if ($y_labels["$y_tick"]) { $label = $y_labels["$y_tick"]; --- 220,224 ---- $decimals2 = max(abs(floor(log10($this->GetValue('axis2_tick')))), $this->GetValue('grid_precision')); ! for ($y_tick = $this->GetValue('y_min'); round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { if ($y_labels["$y_tick"]) { $label = $y_labels["$y_tick"]; Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ImagePrimitives.class 2001/12/04 19:24:34 1.8 --- ImagePrimitives.class 2001/12/06 02:32:59 1.9 *************** *** 301,312 **** } // if we have a difference in the data else { ! $x_pixel = $this->GetValue('y_tick_padding') + $this->GetValue('x_padding') + (($x_value - $this->GetValue('x_min')) / $this->GetValue('x_data_diff')) * ($this->GetValue('width') - $horizontal_space); } ! if ($y_data_diff) { $y_pixel = $this->GetValue('y_padding') + (1 - (($y_value - $this->GetValue($axis_name . '_min')) / $this->GetValue($axis_name . '_data_diff'))) * ($this->GetValue('height') - $vertical_space); } // if we have a difference in data else { ! $y_pixel = $this->GetValue('y_padding') + (1 - (($y_value - $this->GetValue($axis_name . '_min')) / $this->GetValue($axis_name . '_data_diff'))) * ($this->GetValue('height') - $vertical_space); } --- 301,312 ---- } // if we have a difference in the data else { ! $x_pixel = 0; } ! if ($this->GetValue($axis_name . '_data_diff')) { $y_pixel = $this->GetValue('y_padding') + (1 - (($y_value - $this->GetValue($axis_name . '_min')) / $this->GetValue($axis_name . '_data_diff'))) * ($this->GetValue('height') - $vertical_space); } // if we have a difference in data else { ! $y_pixel = 0; } *************** *** 602,613 **** if (!$this->GetValue('axis2_data_diff')) { if (!$this->IsUserValue('axis2_min')) { ! $this->SetValue('axis2_min', $this->GetValue('axis2_min')); } if (!$this->IsUserValue('axis2_max')) { ! $this->SetValue('axis2_max', $this->GetValue('axis2_max')); } } // if we had no y diff } // if we have axis2 data } // function ValidateExtents --- 602,614 ---- if (!$this->GetValue('axis2_data_diff')) { if (!$this->IsUserValue('axis2_min')) { ! $this->SetValue('axis2_min', $this->GetValue('axis2_min') - .5); } if (!$this->IsUserValue('axis2_max')) { ! $this->SetValue('axis2_max', $this->GetValue('axis2_max') + .5); } } // if we had no y diff } // if we have axis2 data + } // function ValidateExtents *************** *** 715,720 **** * @param string $value The value you wish to assign. Could be an array, boolean, int, string ,... */ ! function SetValue($name, $value) { ! $this->USER_VALUES[$name] = $value; switch($name) { --- 716,726 ---- * @param string $value The value you wish to assign. Could be an array, boolean, int, string ,... */ ! function SetValue($name, $value, $internal = false) { ! if ($internal) { ! $this->DEFAULTS[$name] = $value; ! } // if this is internal ! else { ! $this->USER_VALUES[$name] = $value; ! } // else this is a user value switch($name) { *************** *** 735,746 **** case('y_min'): case('y_max'): ! $this->SetXDataDiff(0); ! $this->SetYDataDiff(0); break; case('axis2_min'): case('axis2_max'): ! $this->SetAxis2DataDiff(0); ! $this->SetAxis2DataDiff(0); break; --- 741,752 ---- case('y_min'): case('y_max'): ! $this->SetXDataDiff($internal); ! $this->SetYDataDiff($internal); break; case('axis2_min'): case('axis2_max'): ! $this->SetAxis2DataDiff($internal); ! $this->SetAxis2DataDiff($internal); break; |
From: Ariel G. <ag...@us...> - 2001-12-04 19:28:25
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv5448 Modified Files: VAGRANT.imlib.class Log Message: force dash line length to be at least 1 Index: VAGRANT.imlib.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/VAGRANT.imlib.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** VAGRANT.imlib.class 2001/11/28 18:39:59 1.1.1.1 --- VAGRANT.imlib.class 2001/12/04 19:28:22 1.2 *************** *** 97,101 **** // Get the length of the line in pixels // ! $line_length = round(ceil (sqrt(pow(($x2 - $x1),2) + pow(($y2 - $y1),2)) ),2); $cosTheta = ($x2 - $x1) / $line_length; --- 97,101 ---- // Get the length of the line in pixels // ! $line_length = max(round(ceil (sqrt(pow(($x2 - $x1),2) + pow(($y2 - $y1),2)) ),2), 1); $cosTheta = ($x2 - $x1) / $line_length; |
From: Ariel G. <ag...@us...> - 2001-12-04 19:24:37
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv3918 Modified Files: Graph.class ImagePrimitives.class Log Message: Tick marks are now set at grid time instead of setvalue(min/max) time. This means that if there are more tick marks than would fit with one character worth of text, the number of tick marks is adjusted accordingly. Also, the axis2 tick marks can be user set correctly but if you choose tick marks that don't exceed the axis2_max in the given number of grid lines, the tick value is multiplied but whatever integer makes the new max greater than the current axis2_max. Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Graph.class 2001/12/03 23:51:14 1.7 --- Graph.class 2001/12/04 19:24:34 1.8 *************** *** 57,62 **** $x_labels = array(); } // else we are not using x labels ! if (!$this->IsUserValue('x_tick')) { ! $this->x_tick = $this->GetTick($this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'), $integer); } // if a value for x_tick was defined --- 57,64 ---- $x_labels = array(); } // else we are not using x labels ! ! if (!$this->IsUserValue('x_tick') || ($this->GetValue('x_data_diff') / $this->GetValue('x_tick') > ($this->width / $this->text_size['width']))) { ! $this->SetValue('num_x_grid', ceil(min($this->GetValue('num_x_grid'), $this->width / $this->text_size['width']))); ! $this->SetValue('x_tick', $this->GetTick($this->GetValue('x_data_diff'), $this->GetValue('num_x_grid'), $integer)); } // if a value for x_tick was defined *************** *** 79,84 **** $y_labels = array(); } // else we are not using y labels ! if (!$this->IsUserValue('y_tick')) { ! $this->y_tick = $this->GetTick($this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'), $integer); } // if a value for y_tick was defined --- 81,88 ---- $y_labels = array(); } // else we are not using y labels ! ! if (!$this->IsUserValue('y_tick') || ($this->GetValue('y_data_diff') / $this->GetValue('y_tick') > ($this->height / $this->text_size['height']))) { ! $this->SetValue('num_y_grid', ceil(min($this->GetValue('num_y_grid'), $this->height / $this->text_size['height']))); ! $this->SetValue('y_tick', $this->GetTick($this->GetValue('y_data_diff'), $this->GetValue('num_y_grid'), $integer)); } // if a value for y_tick was defined *************** *** 106,120 **** $new_axis2_min = $this->AdjustNum($this->GetValue('axis2_min'), $this->GetValue('axis2_data_diff'), ROUND_DOWN); - $new_axis2_max = $this->AdjustNum($this->GetValue('axis2_max'), $this->GetValue('axis2_data_diff'), ROUND_UP); ! $axis2_tick = $this->GetTick($new_axis2_max - $new_axis2_min, $this->GetValue('num_y_grid'), $integer); ! $new_axis2_max = $new_axis2_min + $axis2_tick * $this->GetValue('num_y_grid'); ! $this->SetValue('axis2_min', $new_axis2_min); ! $this->SetValue('axis2_max', $new_axis2_max); ! $this->axis2_tick = $axis2_tick; ! $axis2_tick = $new_axis2_min; // this will be used for the axis labels on the right side of the grid } // if we have axis2 data else { --- 110,132 ---- $new_axis2_min = $this->AdjustNum($this->GetValue('axis2_min'), $this->GetValue('axis2_data_diff'), ROUND_DOWN); ! if ($this->IsUserValue('axis2_tick')) { ! $axis2_mod = ceil(($this->GetValue('axis2_max') - $new_axis2_min) / ($this->GetValue('axis2_tick') * $this->GetValue('num_y_grid'))); ! $this->SetValue('axis2_tick', $this->GetValue('axis2_tick') * $axis2_mod); ! $new_axis2_max = $new_axis2_min + $this->GetValue('axis2_tick') * $this->GetValue('num_y_grid'); ! } // if the user has modified the axis2 tick ! else { ! $new_axis2_max = $this->AdjustNum($this->GetValue('axis2_max'), $this->GetValue('axis2_data_diff'), ROUND_UP); ! $axis2_tick = $this->GetTick($new_axis2_max - $new_axis2_min, $this->GetValue('num_y_grid'), $integer); ! $new_axis2_max = $new_axis2_min + $axis2_tick * $this->GetValue('num_y_grid'); ! $this->SetValue('axis2_tick', $axis2_tick); ! $axis2_tick = $new_axis2_min; // this will be used for the axis labels on the right side of the grid ! } // else we are creating our own tick ! ! $this->SetValue('axis2_min', $new_axis2_min); ! $this->SetValue('axis2_max', $new_axis2_max); } // if we have axis2 data else { *************** *** 200,204 **** } // if...else... make sure that we have a pixel space ! $decimals = max(abs(floor(log10($this->GetValue('y_tick')))), $this->GetValue('grid_precision')); for ($y_tick = $y_start; round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { if ($y_labels["$y_tick"]) { --- 212,218 ---- } // if...else... make sure that we have a pixel space ! $decimals = max(abs(floor(log10($this->GetValue('y_tick')))), $this->GetValue('grid_precision')); ! $decimals2 = max(abs(floor(log10($this->GetValue('axis2_tick')))), $this->GetValue('grid_precision')); ! for ($y_tick = $y_start; round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { if ($y_labels["$y_tick"]) { *************** *** 233,237 **** $axis2_max_tick_height = max($axis2_max_tick_height, $axis2_tick_sizes["$label"]['height']); ! $axis2_tick += $this->GetValue('axis2_tick'); } // if we have axis2 data } // for --- 247,251 ---- $axis2_max_tick_height = max($axis2_max_tick_height, $axis2_tick_sizes["$label"]['height']); ! $axis2_tick = round($this->GetValue('axis2_tick') + $axis2_tick, $decimals2); } // if we have axis2 data } // for Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ImagePrimitives.class 2001/12/03 23:51:14 1.7 --- ImagePrimitives.class 2001/12/04 19:24:34 1.8 *************** *** 580,596 **** function ValidateExtents() { if (!$this->GetValue('x_data_diff')) { ! $this->SetValue('x_min', $this->GetValue('x_min') - .5); ! $this->SetValue('x_max', $this->GetValue('x_max') + .5); } // if we had no x diff if (!$this->GetValue('y_data_diff')) { ! $this->SetValue('y_min', $this->GetValue('y_min') - .5); ! $this->SetValue('y_max', $this->GetValue('y_max') + .5); } // if we had no y diff if (is_array($this->axis2_data) && sizeof($this->axis2_data)) { if (!$this->GetValue('axis2_data_diff')) { ! $this->SetValue('y_min', $this->GetValue('axis2_min')); ! $this->SetValue('y_max', $this->GetValue('axis2_max')); } // if we had no y diff } // if we have axis2 data --- 580,611 ---- function ValidateExtents() { if (!$this->GetValue('x_data_diff')) { ! if (!$this->IsUserValue('x_min')) { ! $this->SetValue('x_min', $this->GetValue('x_min') - .5); ! } // if this is not a user value ! ! if (!$this->IsUserValue('x_max')) { ! $this->SetValue('x_max', $this->GetValue('x_max') + .5); ! } // if this is not a user value } // if we had no x diff if (!$this->GetValue('y_data_diff')) { ! if (!$this->IsUserValue('y_min')) { ! $this->SetValue('y_min', $this->GetValue('y_min') - .5); ! } ! ! if (!$this->IsUserValue('y_max')) { ! $this->SetValue('y_max', $this->GetValue('y_max') + .5); ! } } // if we had no y diff if (is_array($this->axis2_data) && sizeof($this->axis2_data)) { if (!$this->GetValue('axis2_data_diff')) { ! if (!$this->IsUserValue('axis2_min')) { ! $this->SetValue('axis2_min', $this->GetValue('axis2_min')); ! } ! ! if (!$this->IsUserValue('axis2_max')) { ! $this->SetValue('axis2_max', $this->GetValue('axis2_max')); ! } } // if we had no y diff } // if we have axis2 data *************** *** 732,741 **** case('x_tick'): $value = max(1, $value); ! $this->USER_VALUES['num_x_grid'] = ceil($this->GetValue('x_data_diff') / $value); break; case('y_tick'): $value = max(1, $value); ! $this->USER_VALUES['num_y_grid'] = ceil($this->GetValue('y_data_diff') / $value); break; --- 747,756 ---- case('x_tick'): $value = max(1, $value); ! //$this->USER_VALUES['num_x_grid'] = ceil(min($this->GetValue('x_data_diff') / $value, $this->width / $this->text_size['width'])); break; case('y_tick'): $value = max(1, $value); ! //$this->USER_VALUES['num_y_grid'] = ceil(min($this->GetValue('y_data_diff') / $value, $this->height / $this->text_size['height'])); break; *************** *** 1219,1225 **** while (list($highlight_id,) = @each($this->highlights)) { if ((!$this->highlights[$highlight_id]['options']['legend_text']) || !$this->drawn_highlights[$highlight_id]) { - if ($this->highlights[$highlight_id]['options']['legend_text']) { - print_r($this->drawn_highlights);die(); - } continue; } // if this is not a real dataset for this object, skip it --- 1234,1237 ---- |
From: Ariel G. <ag...@us...> - 2001-12-03 23:51:17
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv32015 Modified Files: ImagePrimitives.class Graph.class VAGRANT.class Log Message: Now handles empty datasets (by disregarding them) and validates mins and maxes to prevent multiple divide by zero errors. If a single datapoint is entered and no max or mins are specified by the user, the mins are .5 less than the value of the data and the maxes are .5 higher. Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** ImagePrimitives.class 2001/12/03 18:21:05 1.6 --- ImagePrimitives.class 2001/12/03 23:51:14 1.7 *************** *** 62,77 **** // Font Defaults // ! $this->DEFAULTS['default_font'] = VAGRANT_DEFAULT_FONT; ! $this->DEFAULTS['x_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['x_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['y_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['y_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['axis2_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['axis2_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['title_font'] = VAGRANT_DEFAULT_LARGE_FONT; ! $this->DEFAULTS['subtitle_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['highlight_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['legend_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['legend_title_font'] = VAGRANT_DEFAULT_SMALL_FONT; // Various padding parameters --- 62,78 ---- // Font Defaults // ! $this->DEFAULTS['default_font'] = VAGRANT_DEFAULT_FONT; ! $this->DEFAULTS['x_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['x_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['y_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['y_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['axis2_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['axis2_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['title_font'] = VAGRANT_DEFAULT_LARGE_FONT; ! $this->DEFAULTS['subtitle_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['highlight_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['legend_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['legend_title_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['no_data_string_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; // Various padding parameters *************** *** 105,123 **** // Set up colors // ! $this->DEFAULTS['background_color'] = 'white'; ! $this->DEFAULTS['axis_color'] = 'black'; ! $this->DEFAULTS['grid_color'] = 'gray'; ! $this->DEFAULTS['x_tick_color'] = 'black'; ! $this->DEFAULTS['x_title_color'] = 'black'; ! $this->DEFAULTS['y_tick_color'] = 'black'; ! $this->DEFAULTS['y_title_color'] = 'black'; ! $this->DEFAULTS['axis2_tick_color'] = 'black'; ! $this->DEFAULTS['axis2_title_color'] = 'black'; ! $this->DEFAULTS['title_color'] = 'black'; ! $this->DEFAULTS['subtitle_color'] = 'black'; ! $this->DEFAULTS['legend_background'] = 'white'; ! $this->DEFAULTS['legend_title_color'] = 'black'; ! $this->DEFAULTS['legend_text_color'] = 'black'; ! $this->DEFAULTS['legend_border_color'] = 'black'; // Grid parameters --- 106,125 ---- // Set up colors // ! $this->DEFAULTS['background_color'] = 'white'; ! $this->DEFAULTS['axis_color'] = 'black'; ! $this->DEFAULTS['grid_color'] = 'gray'; ! $this->DEFAULTS['x_tick_color'] = 'black'; ! $this->DEFAULTS['x_title_color'] = 'black'; ! $this->DEFAULTS['y_tick_color'] = 'black'; ! $this->DEFAULTS['y_title_color'] = 'black'; ! $this->DEFAULTS['axis2_tick_color'] = 'black'; ! $this->DEFAULTS['axis2_title_color'] = 'black'; ! $this->DEFAULTS['title_color'] = 'black'; ! $this->DEFAULTS['subtitle_color'] = 'black'; ! $this->DEFAULTS['legend_background'] = 'white'; ! $this->DEFAULTS['legend_title_color'] = 'black'; ! $this->DEFAULTS['legend_text_color'] = 'black'; ! $this->DEFAULTS['legend_border_color'] = 'black'; ! $this->DEFAULTS['no_data_string_color'] = "red"; // Grid parameters *************** *** 144,147 **** --- 146,150 ---- $this->DEFAULTS['legend_top'] = -1; // it will adjust to the bottom left corner $this->DEFAULTS['legend_left'] = -1; // + $this->DEFAULTS['no_data_string'] = "No Data Available"; } // function InitializePrimitives *************** *** 259,268 **** if ($axis2) { ! $y_min = $this->GetValue('axis2_min'); ! $y_data_diff = $this->GetValue('axis2_data_diff'); } // if we are using axis2 values else { ! $y_min = $this->GetValue('y_min'); ! $y_data_diff = $this->GetValue('y_data_diff'); } // else use the y axis for the translation --- 262,269 ---- if ($axis2) { ! $axis_name = 'axis2'; } // if we are using axis2 values else { ! $axis_name = 'y'; } // else use the y axis for the translation *************** *** 296,301 **** $vertical_space = $this->GetValue('y_padding') + $this->GetValue('y_top_padding') + $this->GetValue('y_bottom_padding') + $this->GetValue('x_tick_padding') + $title_padding + $x_title_padding; ! $x_pixel = $this->GetValue('y_tick_padding') + $this->GetValue('x_padding') + (($x_value - $this->GetValue('x_min')) / $this->GetValue('x_data_diff')) * ($this->GetValue('width') - $horizontal_space); ! $y_pixel = $this->GetValue('y_padding') + (1 - (($y_value - $y_min) / $y_data_diff)) * ($this->GetValue('height') - $vertical_space); $x_pixel += $this->GetValue('origin_x') + $y_title_padding; --- 297,313 ---- $vertical_space = $this->GetValue('y_padding') + $this->GetValue('y_top_padding') + $this->GetValue('y_bottom_padding') + $this->GetValue('x_tick_padding') + $title_padding + $x_title_padding; ! if ($this->GetValue('x_data_diff')) { ! $x_pixel = $this->GetValue('y_tick_padding') + $this->GetValue('x_padding') + (($x_value - $this->GetValue('x_min')) / $this->GetValue('x_data_diff')) * ($this->GetValue('width') - $horizontal_space); ! } // if we have a difference in the data ! else { ! $x_pixel = $this->GetValue('y_tick_padding') + $this->GetValue('x_padding') + (($x_value - $this->GetValue('x_min')) / $this->GetValue('x_data_diff')) * ($this->GetValue('width') - $horizontal_space); ! } ! ! if ($y_data_diff) { ! $y_pixel = $this->GetValue('y_padding') + (1 - (($y_value - $this->GetValue($axis_name . '_min')) / $this->GetValue($axis_name . '_data_diff'))) * ($this->GetValue('height') - $vertical_space); ! } // if we have a difference in data ! else { ! $y_pixel = $this->GetValue('y_padding') + (1 - (($y_value - $this->GetValue($axis_name . '_min')) / $this->GetValue($axis_name . '_data_diff'))) * ($this->GetValue('height') - $vertical_space); ! } $x_pixel += $this->GetValue('origin_x') + $y_title_padding; *************** *** 507,510 **** --- 519,523 ---- */ function GetTick($data_diff, $num_grid, $integer = false) { + $num_grid = max($num_grid, 1); $tick_guess = $data_diff / $num_grid; $tick = $this->AdjustNum($tick_guess, $data_diff); *************** *** 537,545 **** $multiplier = pow(10, $this->GetValue('grid_precision')); - $decimals = floor(log10($data_diff)); - $divisor = pow(10,$decimals); - $num = $round_func($num / $divisor * $multiplier) * $divisor / $multiplier; - return $num; } // function AdjustNum --- 550,557 ---- $multiplier = pow(10, $this->GetValue('grid_precision')); + $decimals = floor(log10($data_diff)); + $divisor = pow(10,$decimals); + $num = $round_func($num / $divisor * $multiplier) * $divisor / $multiplier; return $num; } // function AdjustNum *************** *** 554,557 **** --- 566,618 ---- /** + * ValidData makes checks whether or not this graph contains any datasets + * + * @author Ariel Garza (ag...@va...) + */ + function ValidData() { + return sizeof($this->datasets); + } // function ValidData + + + /** + * ValidateExtents makes sure that we always have a max greater than the min for each axis + */ + function ValidateExtents() { + if (!$this->GetValue('x_data_diff')) { + $this->SetValue('x_min', $this->GetValue('x_min') - .5); + $this->SetValue('x_max', $this->GetValue('x_max') + .5); + } // if we had no x diff + + if (!$this->GetValue('y_data_diff')) { + $this->SetValue('y_min', $this->GetValue('y_min') - .5); + $this->SetValue('y_max', $this->GetValue('y_max') + .5); + } // if we had no y diff + + if (is_array($this->axis2_data) && sizeof($this->axis2_data)) { + if (!$this->GetValue('axis2_data_diff')) { + $this->SetValue('y_min', $this->GetValue('axis2_min')); + $this->SetValue('y_max', $this->GetValue('axis2_max')); + } // if we had no y diff + } // if we have axis2 data + } // function ValidateExtents + + + /** + * ShowNoData shows a no data string + * + * @author Ariel Garza (ag...@va...) + */ + function ShowNoData() { + $text_size = $this->image_object->GetTextSize($this->GetValue('no_data_string'), TEXT_HORIZONTAL, $this->GetFont($this->GetValue('no_data_string_font'))); + + $x_pos = $this->width / 2 + $this->origin_x - $text_size['width'] / 2; + $y_pos = $this->height / 2 + $this->origin_x - $text_size['height'] / 2; + + $this->image_object->DrawText($this->GetFont($this->GetValue('no_data_string_font')), $x_pos, $y_pos, $this->GetValue('no_data_string'), + $this->GetColor($this->GetValue('no_data_string_color')), TEXT_HORIZONTAL); + } // function ShowNoData + + + /** * AddData adds a dataset to this object. The dataset itself should just be a pointer to the real data set * to conserve memory. *************** *** 563,566 **** --- 624,633 ---- */ function AddData($id, $dataset, $axis2 = false) { + if (!is_array($dataset['x']) || !is_array($dataset['y']) || + !sizeof($dataset['x']) || !sizeof($dataset['y'])) { + + return false; + } // if + $this->datasets[$id] = $dataset; *************** *** 664,671 **** --- 731,740 ---- case('x_tick'): + $value = max(1, $value); $this->USER_VALUES['num_x_grid'] = ceil($this->GetValue('x_data_diff') / $value); break; case('y_tick'): + $value = max(1, $value); $this->USER_VALUES['num_y_grid'] = ceil($this->GetValue('y_data_diff') / $value); break; *************** *** 860,864 **** } // if...else... are we setting an internal or user value? ! return $this->GetValue('x_data_diff'); } // function SetXDataDiff --- 929,933 ---- } // if...else... are we setting an internal or user value? ! return $this->GetValue('x_data_diff', $internal); } // function SetXDataDiff *************** *** 879,883 **** } // if...else... are we setting an internal or user value? ! return $this->y_data_diff; } // function SetYDataDiff --- 948,952 ---- } // if...else... are we setting an internal or user value? ! return $this->GetValue('y_data_diff', $internal); } // function SetYDataDiff *************** *** 898,902 **** } // if...else... are we setting an internal or user value? ! return $this->axis2_data_diff; } // function SetAxis2DataDiff --- 967,971 ---- } // if...else... are we setting an internal or user value? ! return $this->GetValue('axis2_data_diff', $internal); } // function SetAxis2DataDiff *************** *** 966,970 **** return false; - //return array(array('x' => $start_point['x'], 'y' => $this->GetValue($axis_max)), array('x' => $end_point['x'], 'y' => $this->GetValue($axis_max))); } --- 1035,1038 ---- Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Graph.class 2001/12/01 00:52:09 1.6 --- Graph.class 2001/12/03 23:51:14 1.7 *************** *** 43,46 **** --- 43,48 ---- $this->GetColor($this->GetValue('background_color'))); + $this->ValidateExtents(); + // First let's focus on the x axis. // If the user has assigned either a max or a minimum, those values will be used at *************** *** 314,318 **** $this->DrawXTitle(); $this->DrawYTitle(); ! $this->DrawAxis2Title(); } // function DrawGrid --- 316,323 ---- $this->DrawXTitle(); $this->DrawYTitle(); ! ! if ($axis2_data) { ! $this->DrawAxis2Title(); ! } // if we have axis2 data } // function DrawGrid Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/VAGRANT.class,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** VAGRANT.class 2001/12/01 00:53:54 1.5 --- VAGRANT.class 2001/12/03 23:51:14 1.6 *************** *** 75,78 **** --- 75,79 ---- $this->image_object->InitImage(); + $this->added_data = array(); $this->highlight_map = array(); $this->legend_map = array(); *************** *** 148,152 **** function AddData($x_data, $y_data, $object_id = "", $axis2 = false) { ! $dataset_id = sizeof($this->datasets); $this->datasets[$dataset_id]['x'] = $x_data; --- 149,157 ---- function AddData($x_data, $y_data, $object_id = "", $axis2 = false) { ! if (!is_array($x_data) || !is_array($y_data) || !sizeof($x_data) || !sizeof($y_data)) { ! return false; ! } // if we have a dataset ! ! $dataset_id = "dataset-" . sizeof($this->datasets); $this->datasets[$dataset_id]['x'] = $x_data; *************** *** 156,160 **** $this->AddObjectData($object_id, $dataset_id, $axis2); } // if there was an object_id passed in ! return $dataset_id; } // function AddData --- 161,165 ---- $this->AddObjectData($object_id, $dataset_id, $axis2); } // if there was an object_id passed in ! return $dataset_id; } // function AddData *************** *** 228,236 **** $object_array = $this->GetObjectArrayFromID($object_id); ! if ($object_array) { ! $this->data_map[$object_id][$dataset_id] = $dataset_id; ! ! $this->{$object_array}[$object_id]->AddData($dataset_id, &$this->datasets[$dataset_id], $axis2); ! return true; } // if we are adding data to a chart --- 233,245 ---- $object_array = $this->GetObjectArrayFromID($object_id); ! if ($object_array && ("$dataset_id" !== "")) { ! if ($this->{$object_array}[$object_id]->AddData($dataset_id, &$this->datasets[$dataset_id], $axis2)) { ! $this->data_map[$object_id][$dataset_id] = $dataset_id; ! $this->added_data[$object_array][$object_id] = 1; ! return true; ! } // if we added the data successfully ! else { ! return false; ! } // else we could not add the data } // if we are adding data to a chart *************** *** 303,321 **** @reset($this->graphs); while (list($graph_id,) = each($this->graphs)) { ! $this->graphs[$graph_id]->DrawGrid(); ! while (list($dataset_id, $map) = @each($this->graph_map[$graph_id])) { ! $this->graphs[$graph_id]->DrawGraph($dataset_id, $map['type'], $map['color'], $map['options']); ! } // while we step through the data in this graph ! if (is_array($this->highlight_map[$graph_id]) && sizeof($this->highlight_map[$graph_id])) { ! while (list($highlight_id,) = @each($this->highlight_map[$graph_id])) { ! $this->graphs[$graph_id]->DrawHighlight($highlight_id); ! } // while we step through the highlights for this graph ! } // if we have highlights to show ! if (is_array($this->legend_map[$graph_id]) && sizeof($this->legend_map[$graph_id])) { ! $this->graphs[$graph_id]->DrawLegend($this->legend_map[$graph_id]); ! } // if we have legends to show } // while we step through the charts } // if we have graphs to draw --- 312,337 ---- @reset($this->graphs); while (list($graph_id,) = each($this->graphs)) { ! if ($this->added_data['graphs'][$graph_id]) { ! $this->graphs[$graph_id]->DrawGrid(); ! if ($this->graphs[$graph_id]->ValidData()) { ! while (list($dataset_id, $map) = @each($this->graph_map[$graph_id])) { ! $this->graphs[$graph_id]->DrawGraph($dataset_id, $map['type'], $map['color'], $map['options']); ! } // while we step through the data in this graph ! if (is_array($this->highlight_map[$graph_id]) && sizeof($this->highlight_map[$graph_id])) { ! while (list($highlight_id,) = @each($this->highlight_map[$graph_id])) { ! $this->graphs[$graph_id]->DrawHighlight($highlight_id); ! } // while we step through the highlights for this graph ! } // if we have highlights to show ! if (is_array($this->legend_map[$graph_id]) && sizeof($this->legend_map[$graph_id])) { ! $this->graphs[$graph_id]->DrawLegend($this->legend_map[$graph_id]); ! } // if we have legends to show ! } // if this graph has valid data ! } // if this graph had data added to it ! else { ! $this->graphs[$graph_id]->ShowNoData($object_id); ! } // else show that no data was added } // while we step through the charts } // if we have graphs to draw *************** *** 362,366 **** $object_array = $this->GetObjectArrayFromID($graph_id); ! if ($object_array) { $this->graph_map[$graph_id][$dataset_id]['type'] = $type; $this->graph_map[$graph_id][$dataset_id]['color'] = $color; --- 378,382 ---- $object_array = $this->GetObjectArrayFromID($graph_id); ! if ($object_array && $dataset_id) { $this->graph_map[$graph_id][$dataset_id]['type'] = $type; $this->graph_map[$graph_id][$dataset_id]['color'] = $color; |
From: Ariel G. <ag...@us...> - 2001-12-03 18:21:08
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv28772 Modified Files: ImagePrimitives.class Log Message: you can hide the legend by setting hide_legend to true Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ImagePrimitives.class 2001/12/01 00:52:09 1.5 --- ImagePrimitives.class 2001/12/03 18:21:05 1.6 *************** *** 135,138 **** --- 135,139 ---- // Basic drawing parameters // + $this->DEFAULTS['hide_legend'] = false; $this->DEFAULTS['vert_bar_width'] = 8; $this->DEFAULTS['dashed_line_length'] = 4; *************** *** 1121,1125 **** */ function DrawLegend(&$legend_map) { ! if (!is_array($legend_map) || !sizeof($legend_map)) { return false; } // if we have no data no legendify, return false --- 1122,1126 ---- */ function DrawLegend(&$legend_map) { ! if ($this->GetValue('hide_legend') || !is_array($legend_map) || !sizeof($legend_map)) { return false; } // if we have no data no legendify, return false |
From: Ariel G. <ag...@us...> - 2001-12-01 00:53:57
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv23907 Modified Files: VAGRANT.class Log Message: Place errors and warnings at the top of the infodump Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/VAGRANT.class,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** VAGRANT.class 2001/12/01 00:52:09 1.4 --- VAGRANT.class 2001/12/01 00:53:54 1.5 *************** *** 268,279 **** echo("<TABLE border=\"0\" cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#000000\"><TR><TD><TABLE border=\"0\" bgcolor=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"3\">\n"); echo("<TR bgcolor=\"#555555\"><TH colspan=\"2\"><FONT color=\"#FFFFFF\">Graph: $key</FONT></TH></TR>"); - echo("<TR valign=\"top\"><TD bgcolor=\"#DDDDDD\"><font size=\"-1\"><B>Defaults:</B></font></TD><TD><pre>\n");print_r($this->graphs[$key]->DEFAULTS);echo("</pre></TD></TR>\n"); - echo("<TR><TD colspan=\"2\"><HR size=\"1\" noshade></TD></TR>\n"); - echo("<TR valign=\"top\"><TD bgcolor=\"#DDDDDD\"><font size=\"-1\"><B>User Values:</B></font></TD><TD><pre>\n");print_r($this->graphs[$key]->USER_VALUES);echo("</pre></TD></TR>\n"); - echo("<TR><TD colspan=\"2\"><HR size=\"1\" noshade></TD></TR>\n"); echo("<TR valign=\"top\"><TD bgcolor=\"#DDDDDD\"><font size=\"-1\"><B>Errors:</B></font></TD><TD><pre>\n");print_r($this->errors);echo("</pre></TD></TR>\n"); echo("<TR><TD colspan=\"2\"><HR size=\"1\" noshade></TD></TR>\n"); echo("<TR valign=\"top\"><TD bgcolor=\"#DDDDDD\"><font size=\"-1\"><B>Warnings:</B></font></TD><TD><pre>\n");print_r($this->warnings);echo("</pre></TD></TR>\n"); ! echo("</TABLE></TD></TR></TABLE>\n"); } // while --- 268,279 ---- echo("<TABLE border=\"0\" cellpadding=\"1\" cellspacing=\"0\" bgcolor=\"#000000\"><TR><TD><TABLE border=\"0\" bgcolor=\"#FFFFFF\" cellspacing=\"0\" cellpadding=\"3\">\n"); echo("<TR bgcolor=\"#555555\"><TH colspan=\"2\"><FONT color=\"#FFFFFF\">Graph: $key</FONT></TH></TR>"); echo("<TR valign=\"top\"><TD bgcolor=\"#DDDDDD\"><font size=\"-1\"><B>Errors:</B></font></TD><TD><pre>\n");print_r($this->errors);echo("</pre></TD></TR>\n"); echo("<TR><TD colspan=\"2\"><HR size=\"1\" noshade></TD></TR>\n"); echo("<TR valign=\"top\"><TD bgcolor=\"#DDDDDD\"><font size=\"-1\"><B>Warnings:</B></font></TD><TD><pre>\n");print_r($this->warnings);echo("</pre></TD></TR>\n"); ! echo("<TR><TD colspan=\"2\"><HR size=\"1\" noshade></TD></TR>\n"); ! echo("<TR valign=\"top\"><TD bgcolor=\"#DDDDDD\"><font size=\"-1\"><B>Defaults:</B></font></TD><TD><pre>\n");print_r($this->graphs[$key]->DEFAULTS);echo("</pre></TD></TR>\n"); ! echo("<TR><TD colspan=\"2\"><HR size=\"1\" noshade></TD></TR>\n"); ! echo("<TR valign=\"top\"><TD bgcolor=\"#DDDDDD\"><font size=\"-1\"><B>User Values:</B></font></TD><TD><pre>\n");print_r($this->graphs[$key]->USER_VALUES);echo("</pre></TD></TR>\n"); ! echo("</TABLE></TD></TR></TABLE><P>\n"); } // while |
From: Ariel G. <ag...@us...> - 2001-12-01 00:52:13
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv23652 Modified Files: Graph.class ImagePrimitives.class VAGRANT.class test.php Log Message: Added scatter graphs Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** Graph.class 2001/11/30 19:18:32 1.5 --- Graph.class 2001/12/01 00:52:09 1.6 *************** *** 324,328 **** * @author Ariel Garza (ag...@va...) * @param string $dataset_id The id of the dataset you are graphing ! * @param string $type The type of graph you are drawing * @param string $color What color do you want to draw the graph * @param array $options is an array containing graph options. Valid options are: --- 324,328 ---- * @author Ariel Garza (ag...@va...) * @param string $dataset_id The id of the dataset you are graphing ! * @param string $type The type of graph you are drawing (bar, filled, line, dashed, scatter) * @param string $color What color do you want to draw the graph * @param array $options is an array containing graph options. Valid options are: *************** *** 373,379 **** $this->GetImageLocation($coords['x'], min($coords['y'], $this->GetValue($max_axis)), $x_pos, $y_pos, $axis2); $this->image_object->DrawGradientRectangle($x_pos - $this->GetValue('vert_bar_width') / 2, $y_pos, $this->GetValue('vert_bar_width'), $y_min_pos - $y_pos, $this->GetColor($color, $options['alpha'])); } // if we are drawing a bar graph else if (!$last_point) { - $this->GetImageLocation($coords['x'], $coords['y'], $last_x_pos, $last_y_pos, $axis2); $last_point = $coords; continue; --- 373,388 ---- $this->GetImageLocation($coords['x'], min($coords['y'], $this->GetValue($max_axis)), $x_pos, $y_pos, $axis2); $this->image_object->DrawGradientRectangle($x_pos - $this->GetValue('vert_bar_width') / 2, $y_pos, $this->GetValue('vert_bar_width'), $y_min_pos - $y_pos, $this->GetColor($color, $options['alpha'])); + + continue; } // if we are drawing a bar graph + else if ($type == "scatter") { + if ($this->IsDrawable($coords, $axis2)) { + $this->GetImageLocation($coords['x'], $coords['y'], $x_pos, $y_pos, $axis2); + $this->image_object->DrawBrush($x_pos, $y_pos, $options['shape'], $this->GetColor($color, $options['alpha'])); + } // if this is on the graph + + continue; + } // else if this is a scatter point else if (!$last_point) { $last_point = $coords; continue; *************** *** 462,466 **** } // if this is a filled graph ! if (($type != "bar") && ($type != "filled") && ($line_coords = $this->GetGraphicalCoords($last_point, $coords, $axis2))) { $this->GetImageLocation($line_coords[0]['x'], $line_coords[0]['y'], $x_start_pos, $y_start_pos, $axis2); $this->GetImageLocation($line_coords[1]['x'], $line_coords[1]['y'], $x_end_pos, $y_end_pos, $axis2); --- 471,475 ---- } // if this is a filled graph ! if ($line_coords = $this->GetGraphicalCoords($last_point, $coords, $axis2)) { $this->GetImageLocation($line_coords[0]['x'], $line_coords[0]['y'], $x_start_pos, $y_start_pos, $axis2); $this->GetImageLocation($line_coords[1]['x'], $line_coords[1]['y'], $x_end_pos, $y_end_pos, $axis2); Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ImagePrimitives.class 2001/11/30 19:24:47 1.4 --- ImagePrimitives.class 2001/12/01 00:52:09 1.5 *************** *** 3,7 **** /** * Contains ImagePrimitives class. ! * @version $Id$ * @author Ariel Garza (ag...@va...) */ --- 3,7 ---- /** * Contains ImagePrimitives class. ! * @version $Id$ * @author Ariel Garza (ag...@va...) */ *************** *** 1252,1255 **** --- 1252,1259 ---- $this->GetValue('legend_sample_width'), $this->GetValue('legend_sample_height'), $this->GetColor($this->GetValue('legend_border_color'))); + break; + + case("scatter"): + $this->image_object->DrawBrush($x_pos + $this->GetValue('legend_sample_width') / 2, $y_pos + $y_pad, $legend_map[$dataset_id]['options']['shape'], $legend_color); break; Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/VAGRANT.class,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** VAGRANT.class 2001/11/30 19:25:25 1.3 --- VAGRANT.class 2001/12/01 00:52:09 1.4 *************** *** 4,7 **** --- 4,8 ---- * VAGRANT 2.5 * + * @version $Id$ * @author Ariel Garza (ag...@va...) */ *************** *** 356,359 **** --- 357,361 ---- * legend_title (string) -> The title to be displayed in the legend * legend_color (string) -> The color for the title to be displayed in the legend + * shape (string) -> If type is "scatter", this is the shape to use (circle, triangle, rect) default is rect */ function SetGraphType($graph_id, $dataset_id, $type, $color, $options = array()) { Index: test.php =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/test.php,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test.php 2001/11/29 23:34:28 1.2 --- test.php 2001/12/01 00:52:09 1.3 *************** *** 53,56 **** --- 53,57 ---- $vagrant->CreateColor('dark-blue',0,0,75,255); + $vagrant->CreateColor('dark-green',0,75,0,255); $vagrant->SetValue($graph_id2, 'background_color', 'dark-blue'); $vagrant->SetValue($graph_id2, 'axis_color', 'white'); *************** *** 62,67 **** $vagrant->SetValue($graph_id2, 'y_tick', .5); ! //$vagrant->SetValue($graph_id,'axis2_min', -20); ! //$vagrant->SetValue($graph_id,'axis2_max', 20); //$vagrant->SetValue($graph_id,'x_min', 7); --- 63,68 ---- $vagrant->SetValue($graph_id2, 'y_tick', .5); ! $vagrant->SetValue($graph_id,'axis2_min', -20); ! $vagrant->SetValue($graph_id,'axis2_max', 20); //$vagrant->SetValue($graph_id,'x_min', 7); *************** *** 71,75 **** $vagrant->SetValue($graph_id, 'x_tick', 1); ! $vagrant->SetGraphType($graph_id, $data3, "filled", "green", array('alpha'=>140, 'legend_title' => 'Test Bar Graph Title')); $vagrant->SetGraphType($graph_id, $data1, "line", "blue", array('alpha'=>140, 'legend_title' => 'Test Line Graph Title')); $vagrant->SetGraphType($graph_id, $data2, "line", "red", array('alpha'=>140, 'legend_title' => 'Test Line Graph Title')); --- 72,76 ---- $vagrant->SetValue($graph_id, 'x_tick', 1); ! $vagrant->SetGraphType($graph_id, $data3, "scatter", "dark-green", array('alpha'=>200, 'legend_title' => 'Test Bar Graph Title','shape'=>'circle')); $vagrant->SetGraphType($graph_id, $data1, "line", "blue", array('alpha'=>140, 'legend_title' => 'Test Line Graph Title')); $vagrant->SetGraphType($graph_id, $data2, "line", "red", array('alpha'=>140, 'legend_title' => 'Test Line Graph Title')); *************** *** 82,86 **** // Add a highlight to the right side axis by adding a true to after the options array // ! $vagrant->AddHighlight($graph_id, 3, 40, 7, "", "yellow", array('alpha' => 75, 'legend_text' => "axis2 highlight", 'highlight_text' => "Highlight and legend text!" ), true); // If you comment out display image and uncomment the infodump function --- 83,87 ---- // Add a highlight to the right side axis by adding a true to after the options array // ! $vagrant->AddHighlight($graph_id, 3, 15, 7, 40, "yellow", array('alpha' => 75, 'legend_text' => "axis2 highlight", 'highlight_text' => "Highlight and legend text!" ), true); // If you comment out display image and uncomment the infodump function |
From: Ariel G. <ag...@us...> - 2001-11-30 19:25:28
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv4434 Modified Files: VAGRANT.class Log Message: Highlights need to be drawn before the legend so that the legend knows if a highlight was actually displayed. Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/VAGRANT.class,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** VAGRANT.class 2001/11/29 23:34:28 1.2 --- VAGRANT.class 2001/11/30 19:25:25 1.3 *************** *** 308,315 **** } // while we step through the data in this graph - if (is_array($this->legend_map[$graph_id]) && sizeof($this->legend_map[$graph_id])) { - $this->graphs[$graph_id]->DrawLegend($this->legend_map[$graph_id]); - } // if we have legends to show - if (is_array($this->highlight_map[$graph_id]) && sizeof($this->highlight_map[$graph_id])) { while (list($highlight_id,) = @each($this->highlight_map[$graph_id])) { --- 308,311 ---- *************** *** 317,320 **** --- 313,320 ---- } // while we step through the highlights for this graph } // if we have highlights to show + + if (is_array($this->legend_map[$graph_id]) && sizeof($this->legend_map[$graph_id])) { + $this->graphs[$graph_id]->DrawLegend($this->legend_map[$graph_id]); + } // if we have legends to show } // while we step through the charts } // if we have graphs to draw |
From: Ariel G. <ag...@us...> - 2001-11-30 19:24:50
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv2970 Modified Files: ImagePrimitives.class Log Message: Highlights could be added outside of a graphs drawable extents. This caused bad results so now highlights are checked for drawability. if they are not drawable, they are marked as such so that they don't show up in the legend. Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** ImagePrimitives.class 2001/11/29 23:34:28 1.3 --- ImagePrimitives.class 2001/11/30 19:24:47 1.4 *************** *** 39,44 **** */ function InitializePrimitives() { ! $this->text_size = $this->image_object->GetTextSize('M',TEXT_HORIZONTAL); ! $this->highlights = array(); $this->DEFAULTS = array(); --- 39,45 ---- */ function InitializePrimitives() { ! $this->text_size = $this->image_object->GetTextSize('M',TEXT_HORIZONTAL); ! $this->highlights = array(); ! $this->drawn_highlights = array(); // Since you can change the extents of a graph, it is possible for the highlights to not be drawable $this->DEFAULTS = array(); *************** *** 396,400 **** } // if the x_min is not numerical, make it min of the graph else { ! $x_min = &$this->highlights[$highlight_id]['x_min']; } // else just point to the specified x_min --- 397,401 ---- } // if the x_min is not numerical, make it min of the graph else { ! $x_min = max(&$this->highlights[$highlight_id]['x_min'], $this->GetValue('x_min')); } // else just point to the specified x_min *************** *** 403,407 **** } // if the x_max is not numerical, make it max of the graph else { ! $x_max = &$this->highlights[$highlight_id]['x_max']; } // else just point to the specified x_min --- 404,408 ---- } // if the x_max is not numerical, make it max of the graph else { ! $x_max = min(&$this->highlights[$highlight_id]['x_max'], $this->GetValue('x_max')); } // else just point to the specified x_min *************** *** 410,414 **** } // if the y_min is not numerical, make it min of the graph else { ! $y_min = &$this->highlights[$highlight_id]['y_min']; } // else just point to the specified y_min --- 411,415 ---- } // if the y_min is not numerical, make it min of the graph else { ! $y_min = max($this->highlights[$highlight_id]['y_min'], $this->GetValue($axis_min)); } // else just point to the specified y_min *************** *** 417,423 **** } // if the y_max is not numerical, make it max of the graph else { ! $y_max = &$this->highlights[$highlight_id]['y_max']; } // else just point to the specified y_max $this->GetImageLocation($x_min, $y_min, $x_min_pos, $y_min_pos, $this->highlights[$highlight_id]['axis2']); $this->GetImageLocation($x_max, $y_max, $x_max_pos, $y_max_pos, $this->highlights[$highlight_id]['axis2']); --- 418,432 ---- } // if the y_max is not numerical, make it max of the graph else { ! $y_max = min($this->highlights[$highlight_id]['y_max'], $this->GetValue($axis_max)); } // else just point to the specified y_max + if ((!$y_min >= $this->GetValue($axis_max)) || ($y_max <= $this->GetValue($axis_min)) || ($x_min >= $this->GetValue('x_max')) || ($x_max <= $this->GetValue('x_min'))) { + $this->drawn_highlights[$highlight_id] = false; + return false; + } // if the extents of this are are not visible to the user + else { + $this->drawn_highlights[$highlight_id] = true; + } // else we can draw this correctly + $this->GetImageLocation($x_min, $y_min, $x_min_pos, $y_min_pos, $this->highlights[$highlight_id]['axis2']); $this->GetImageLocation($x_max, $y_max, $x_max_pos, $y_max_pos, $this->highlights[$highlight_id]['axis2']); *************** *** 1140,1144 **** reset($this->highlights); while (list($highlight_id,) = @each($this->highlights)) { ! if (!$this->highlights[$highlight_id]['options']['legend_text']) { continue; } // if this is not a real dataset for this object, skip it --- 1149,1156 ---- reset($this->highlights); while (list($highlight_id,) = @each($this->highlights)) { ! if ((!$this->highlights[$highlight_id]['options']['legend_text']) || !$this->drawn_highlights[$highlight_id]) { ! if ($this->highlights[$highlight_id]['options']['legend_text']) { ! print_r($this->drawn_highlights);die(); ! } continue; } // if this is not a real dataset for this object, skip it |
From: Ariel G. <ag...@us...> - 2001-11-30 19:18:35
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv2700 Modified Files: Graph.class Log Message: when grid is drawn, the x labels are checked for width and only draw the amount of tick labels that fit nicely on the graph. There will still be the normal amount of tick marks, just not the same amount of labels (could draw every other label or every 3rd label instead if that's what fits best) Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Graph.class 2001/11/28 19:57:44 1.4 --- Graph.class 2001/11/30 19:18:32 1.5 *************** *** 135,139 **** $x_start = $this->AdjustNum($this->GetValue('x_min'), $this->GetValue('x_data_diff'), $x_round); ! $x_max_tick_width = 0; $y_start = $this->AdjustNum($this->GetValue('y_min'), $this->GetValue('y_data_diff'), $y_round); --- 135,140 ---- $x_start = $this->AdjustNum($this->GetValue('x_min'), $this->GetValue('x_data_diff'), $x_round); ! $x_max_tick_width = 0; ! $x_max_tick_height = 0; $y_start = $this->AdjustNum($this->GetValue('y_min'), $this->GetValue('y_data_diff'), $y_round); *************** *** 168,171 **** --- 169,176 ---- $axis2_tick_sizes = array(); + $this->GetImageLocation($this->GetValue('x_tick'), 0, $min_tick_pos, $foo_y); + $this->GetImageLocation(2 * $this->GetValue('x_tick'), 0, $max_tick_pos, $foo_y); + $tick_pixel_space = $max_tick_pos - $min_tick_pos; + $decimals = max(abs(floor(log10($this->GetValue('x_tick')))), $this->GetValue('grid_precision')); for ($x_tick = $x_start; round($this->GetValue('x_max') - $x_tick, $decimals) >= 0; $x_tick = round($this->GetValue('x_tick') + $x_tick, $decimals)) { *************** *** 183,189 **** --- 188,201 ---- $x_tick_sizes["$label"] = $this->image_object->GetTextSize($label, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('x_tick_font'))); $x_max_tick_height = max($x_max_tick_height, $x_tick_sizes["$label"]['height']); + $x_max_tick_width = max($x_max_tick_width, $x_tick_sizes["$label"]['width']); $last_x_tick = $x_tick; } // for + if ($tick_pixel_space) { + $x_tick_mod = ceil($x_max_tick_width / $tick_pixel_space); + } else { + $x_tick_mod = 1; + } // if...else... make sure that we have a pixel space + $decimals = max(abs(floor(log10($this->GetValue('y_tick')))), $this->GetValue('grid_precision')); for ($y_tick = $y_start; round($this->GetValue('y_max') - $y_tick,$decimals) >= 0; $y_tick = round($this->GetValue('y_tick') + $y_tick, $decimals)) { *************** *** 243,246 **** --- 255,259 ---- // Draw the x_axis tick marks // + $count = -1; while (list($x_tick, $label) = @each($x_tick_list)) { $text_size = $x_tick_sizes["$label"]; *************** *** 251,257 **** $x_pos -= ($text_size['width'] / 2); ! $y_pos = $y_min_pos + $this->GetValue('x_axis_padding'); ! $this->image_object->DrawText($this->GetFont($this->GetValue('x_tick_font')), $x_pos, $y_pos, $label, $this->GetColor($this->GetValue('x_tick_color')), TEXT_HORIZONTAL); } // for --- 264,272 ---- $x_pos -= ($text_size['width'] / 2); ! $y_pos = $y_min_pos + $this->GetValue('x_axis_padding'); ! if (++$count % $x_tick_mod == 0) { ! $this->image_object->DrawText($this->GetFont($this->GetValue('x_tick_font')), $x_pos, $y_pos, $label, $this->GetColor($this->GetValue('x_tick_color')), TEXT_HORIZONTAL); ! } // if we are drawing this tick mark } // for *************** *** 410,414 **** $verts[] = $vert1; } // if we have custom vertices ! else { // We need to get one pixel to the right of the last point // --- 425,429 ---- $verts[] = $vert1; } // if we have custom vertices ! else if ($x_end_pos != $x_start_pos) { // We need to get one pixel to the right of the last point // *************** *** 420,425 **** $verts[] = array('x' => $x_start_pos, 'y' => $y_min_pos - 1); ! } // else ! $verts[] = array('x' => $x_start_pos, 'y' => $y_start_pos); --- 435,445 ---- $verts[] = array('x' => $x_start_pos, 'y' => $y_min_pos - 1); ! } ! else { ! $x_start_pos += 1; ! ! $verts[] = array('x' => $x_start_pos, 'y' => $y_min_pos - 1); ! } // else if for some reason the start and end positions are the same ! $verts[] = array('x' => $x_start_pos, 'y' => $y_start_pos); |
From: Ariel G. <ag...@us...> - 2001-11-30 01:44:24
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv15405 Added Files: license Log Message: gpl license file --- NEW FILE: license --- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. <one line to give the program's name and a brief idea of what it does.> Copyright (C) 19yy <name of author> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. <signature of Ty Coon>, 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. |
From: Ariel G. <ag...@us...> - 2001-11-29 23:34:30
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv3496 Modified Files: ImagePrimitives.class VAGRANT.class test.php Log Message: added legends and changed test file to show the uses Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ImagePrimitives.class 2001/11/28 19:40:24 1.2 --- ImagePrimitives.class 2001/11/29 23:34:28 1.3 *************** *** 10,13 **** --- 10,18 ---- define('ROUND_DOWN', 2); + define('LEGEND_GRAPH_LEFT', -1); // Use so that the left side of the legend lines up with the x_min + define('LEGEND_GRAPH_RIGHT', -2); // Use so that the right side of the legend lines up with the x_max + define('LEGEND_GRAPH_TOP', -3); // Use so that the top of the legend lines up with the y_max + define('LEGEND_GRAPH_BOTTOM', -4); // Use so that the bottom of the legend lines up with the y_min + /** * ImagePrimitives is the base class that contains data manipulating functions, *************** *** 56,85 **** // Font Defaults // ! $this->DEFAULTS['default_font'] = VAGRANT_DEFAULT_FONT; ! $this->DEFAULTS['x_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['x_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['y_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['y_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['axis2_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['axis2_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['title_font'] = VAGRANT_DEFAULT_LARGE_FONT; ! $this->DEFAULTS['subtitle_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['highlight_font'] = VAGRANT_DEFAULT_SMALL_FONT; // Various padding parameters // ! $this->DEFAULTS['graph_padding'] = 5; // padding on all sides of graph ! $this->DEFAULTS['x_padding'] = 10; ! $this->DEFAULTS['x_right_padding'] = 5; ! $this->DEFAULTS['y_top_padding'] = 5; ! $this->DEFAULTS['y_bottom_padding'] = 10; ! $this->DEFAULTS['x_axis_padding'] = 3; ! $this->DEFAULTS['y_axis_padding'] = 5; ! $this->DEFAULTS['axis2_padding'] = 5; ! $this->DEFAULTS['x_title_padding'] = 4; ! $this->DEFAULTS['y_title_padding'] = 4; ! $this->DEFAULTS['axis2_title_padding'] = 4; ! $this->DEFAULTS['title_padding'] = 2; ! $this->DEFAULTS['subtitle_padding'] = 2; // Set Up Titles --- 61,95 ---- // Font Defaults // ! $this->DEFAULTS['default_font'] = VAGRANT_DEFAULT_FONT; ! $this->DEFAULTS['x_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['x_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['y_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['y_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['axis2_tick_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['axis2_title_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['title_font'] = VAGRANT_DEFAULT_LARGE_FONT; ! $this->DEFAULTS['subtitle_font'] = VAGRANT_DEFAULT_MEDIUM_FONT; ! $this->DEFAULTS['highlight_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['legend_font'] = VAGRANT_DEFAULT_SMALL_FONT; ! $this->DEFAULTS['legend_title_font'] = VAGRANT_DEFAULT_SMALL_FONT; // Various padding parameters // ! $this->DEFAULTS['graph_padding'] = 5; // padding on all sides of graph ! $this->DEFAULTS['x_padding'] = 10; ! $this->DEFAULTS['x_right_padding'] = 5; ! $this->DEFAULTS['y_top_padding'] = 5; ! $this->DEFAULTS['y_bottom_padding'] = 10; ! $this->DEFAULTS['x_axis_padding'] = 3; ! $this->DEFAULTS['y_axis_padding'] = 5; ! $this->DEFAULTS['axis2_padding'] = 5; ! $this->DEFAULTS['x_title_padding'] = 4; ! $this->DEFAULTS['y_title_padding'] = 4; ! $this->DEFAULTS['axis2_title_padding'] = 4; ! $this->DEFAULTS['title_padding'] = 2; ! $this->DEFAULTS['subtitle_padding'] = 2; ! $this->DEFAULTS['legend_padding'] = 3; // The padding around the legend text ! $this->DEFAULTS['legend_line_padding'] = 3; ! $this->DEFAULTS['legend_sample_padding'] = 5; // Set Up Titles *************** *** 90,107 **** $this->SetValue('y_title', ''); $this->SetValue('axis2_title', ''); // Set up colors // ! $this->DEFAULTS['background_color'] = 'white'; ! $this->DEFAULTS['axis_color'] = 'black'; ! $this->DEFAULTS['grid_color'] = 'gray'; ! $this->DEFAULTS['x_tick_color'] = 'black'; ! $this->DEFAULTS['x_title_color'] = 'black'; ! $this->DEFAULTS['y_tick_color'] = 'black'; ! $this->DEFAULTS['y_title_color'] = 'black'; ! $this->DEFAULTS['axis2_tick_color'] = 'black'; ! $this->DEFAULTS['axis2_title_color'] = 'black'; ! $this->DEFAULTS['title_color'] = 'black'; ! $this->DEFAULTS['subtitle_color'] = 'black'; // Grid parameters --- 100,122 ---- $this->SetValue('y_title', ''); $this->SetValue('axis2_title', ''); + $this->SetValue('legend_title', 'Legend:'); // Set up colors // ! $this->DEFAULTS['background_color'] = 'white'; ! $this->DEFAULTS['axis_color'] = 'black'; ! $this->DEFAULTS['grid_color'] = 'gray'; ! $this->DEFAULTS['x_tick_color'] = 'black'; ! $this->DEFAULTS['x_title_color'] = 'black'; ! $this->DEFAULTS['y_tick_color'] = 'black'; ! $this->DEFAULTS['y_title_color'] = 'black'; ! $this->DEFAULTS['axis2_tick_color'] = 'black'; ! $this->DEFAULTS['axis2_title_color'] = 'black'; ! $this->DEFAULTS['title_color'] = 'black'; ! $this->DEFAULTS['subtitle_color'] = 'black'; ! $this->DEFAULTS['legend_background'] = 'white'; ! $this->DEFAULTS['legend_title_color'] = 'black'; ! $this->DEFAULTS['legend_text_color'] = 'black'; ! $this->DEFAULTS['legend_border_color'] = 'black'; // Grid parameters *************** *** 119,125 **** // Basic drawing parameters // ! $this->DEFAULTS['vert_bar_width'] = 8; ! $this->DEFAULTS['dashed_line_length'] = 4; ! $this->DEFAULTS['dashed_line_space'] = 3; } // function InitializePrimitives --- 134,145 ---- // Basic drawing parameters // ! $this->DEFAULTS['vert_bar_width'] = 8; ! $this->DEFAULTS['dashed_line_length'] = 4; ! $this->DEFAULTS['dashed_line_space'] = 3; ! $this->DEFAULTS['legend_sample_width'] = 10; ! $this->DEFAULTS['legend_sample_height'] = 10; ! $this->DEFAULTS['legend_background_alpha'] = 180; ! $this->DEFAULTS['legend_top'] = -1; // it will adjust to the bottom left corner ! $this->DEFAULTS['legend_left'] = -1; // } // function InitializePrimitives *************** *** 330,339 **** * @param integer $x_min The x_min of the highlighted region. A blank or non-numeric value means the min of the graph * @param array $options An array of options for the highlighted region. options include: ! * alpha (integer) -> An alpha value for the highlighted region ! * legend_text (boolean) -> Should the highlighted region show up in the legend instead of the highlight? ! * font_color (string) -> The color of the text in this highlight block (defaults to black) * @param boolean $axis2 Do the y values refer to the right hand axis? */ ! function AddHighlight($x_min, $y_min, $x_max, $y_max, $color, $text = "", $options = array(), $axis2 = false) { if (!is_array($this->highlights)) { $this->highlights = array(); --- 350,360 ---- * @param integer $x_min The x_min of the highlighted region. A blank or non-numeric value means the min of the graph * @param array $options An array of options for the highlighted region. options include: ! * alpha (integer) -> An alpha value for the highlighted region ! * highlight_text (string) -> What text do you want in the highlighted region? ! * legend_text (string) -> What text do you want in the legend for this highlight? ! * font_color (string) -> The color of the text in this highlight block (defaults to black) * @param boolean $axis2 Do the y values refer to the right hand axis? */ ! function AddHighlight($x_min, $y_min, $x_max, $y_max, $color, $options = array(), $axis2 = false) { if (!is_array($this->highlights)) { $this->highlights = array(); *************** *** 348,352 **** $this->highlights[$highlight_id] = array('x_min' => $x_min, 'y_min' => $y_min, 'x_max' => $x_max, 'y_max' => $y_max, ! 'color' => $color, 'text' => $text, 'axis2' => $axis2, 'options' => $options); return $highlight_id; --- 369,373 ---- $this->highlights[$highlight_id] = array('x_min' => $x_min, 'y_min' => $y_min, 'x_max' => $x_max, 'y_max' => $y_max, ! 'color' => $color, 'options' => $options, 'axis2' => $axis2); return $highlight_id; *************** *** 405,414 **** $this->GetColor($this->highlights[$highlight_id]['color'], $this->highlights[$highlight_id]['options']['alpha'])); ! if ((!$this->highlights[$highlight_id]['options']['legend_text']) && $this->highlights[$highlight_id]['text']) { $text_color = $this->highlights[$highlight_id]['options']['font_color'] ? $this->highlights[$highlight_id]['options']['font_color'] : 'black'; ! $text_size = $this->image_object->GetTextSize($this->highlights[$highlight_id]['text'], TEXT_HORIZONTAL, $this->GetFont($this->GetValue('highlight_font'))); $y_pos = ($y_max_pos + $y_min_pos - $text_size['height']) / 2; ! $this->image_object->DrawText($this->GetFont($this->GetValue('highlight_font')), $x_min_pos + 2, $y_pos, $this->highlights[$highlight_id]['text'], $this->GetColor($text_color), TEXT_HORIZONTAL); } // if this text does not go in the legend } // if this highlight exists --- 426,436 ---- $this->GetColor($this->highlights[$highlight_id]['color'], $this->highlights[$highlight_id]['options']['alpha'])); ! if ($this->highlights[$highlight_id]['options']['highlight_text']) { $text_color = $this->highlights[$highlight_id]['options']['font_color'] ? $this->highlights[$highlight_id]['options']['font_color'] : 'black'; ! $text_size = $this->image_object->GetTextSize($this->highlights[$highlight_id]['options']['highlight_text'], TEXT_HORIZONTAL, $this->GetFont($this->GetValue('highlight_font'))); $y_pos = ($y_max_pos + $y_min_pos - $text_size['height']) / 2; ! $this->image_object->DrawText($this->GetFont($this->GetValue('highlight_font')), $x_min_pos + 2, $y_pos, ! $this->highlights[$highlight_id]['options']['highlight_text'], $this->GetColor($text_color), TEXT_HORIZONTAL); } // if this text does not go in the legend } // if this highlight exists *************** *** 608,611 **** --- 630,634 ---- case('subtitle'): case('x_title'): + case('legend_title'): $this->SetFontSize($name, $value); break; *************** *** 991,995 **** ************************************************************** *** *** ! *** Title Drawing Functions *** *** *** ************************************************************** --- 1014,1018 ---- ************************************************************** *** *** ! *** Various Drawing Functions *** *** *** ************************************************************** *************** *** 1080,1083 **** --- 1103,1278 ---- } // if we have a title to draw } // function DrawYTitle + + + /** + * DrawLegend draws a legend based on the supplied array of datasets. + * + * @author Ariel Garza (ag...@va...) + * @param array $legend_map An array containing the dataset_ids, legend titles and graph info + */ + function DrawLegend(&$legend_map) { + if (!is_array($legend_map) || !sizeof($legend_map)) { + return false; + } // if we have no data no legendify, return false + + $title_size = $this->GetValue('legend_title_size'); + $max_legend_width = 0; + $legend_height = 0; + $legend_list = array(); + + @reset($legend_map); // since it is coming in by reference + while (list($dataset_id, $legend_info) = @each($legend_map)) { + if (!$this->datasets[$dataset_id] || !$legend_info['options']['legend_title']) { + continue; + } // if this is not a real dataset for this object, skip it + + $legend_title = $legend_info['options']['legend_title']; // just easier to manipulate as a seperate var + $legend_list[$dataset_id] = $dataset_id; + $legend_size["$legend_title"] = $this->image_object->GetTextSize($legend_title, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('legend_font'))); + + $max_legend_width = max($max_legend_width, $legend_size["$legend_title"]['width']); + $legend_height += max($legend_size["$legend_title"]['height'], $this->GetValue('legend_sample_height')) + $this->GetValue('legend_line_padding'); + } // while we step through the legend map + + // Check to see if any highlights are being added to the legend + // + if (is_array($this->highlights) && sizeof($this->highlights)) { + reset($this->highlights); + while (list($highlight_id,) = @each($this->highlights)) { + if (!$this->highlights[$highlight_id]['options']['legend_text']) { + continue; + } // if this is not a real dataset for this object, skip it + + $legend_title = $this->highlights[$highlight_id]['options']['legend_text']; // just easier to manipulate as a seperate var + $legend_list[$highlight_id] = $highlight_id; + $legend_size["$legend_title"] = $this->image_object->GetTextSize($legend_title, TEXT_HORIZONTAL, $this->GetFont($this->GetValue('legend_font'))); + + $max_legend_width = max($max_legend_width, $legend_size["$legend_title"]['width']); + $legend_height += max($legend_size["$legend_title"]['height'], $this->GetValue('legend_sample_height')) + $this->GetValue('legend_line_padding'); + } // while we step through the highlights + } // if we had highlights in this graph + + if (!$legend_height) { + return false; + } // if we had nothing to draw in the end, do nothing + + $this->GetImageLocation($this->GetValue('x_min'), $this->GetValue('y_min'), $x_min_pos, $y_min_pos); + $this->GetImageLocation($this->GetValue('x_max'), $this->GetValue('y_max'), $x_max_pos, $y_max_pos); + + $legend_width = $max_legend_width + $this->GetValue('legend_sample_padding') + $this->GetValue('legend_sample_width') + 2 * $this->GetValue('legend_padding'); + $legend_height += $title_size['height'] + 3 * $legend_line_padding + 1; // add 1 for the legend underscore + + if ($this->GetValue('legend_left') < 0) { + switch ($this->GetValue('legend_left')) { + case (LEGEND_GRAPH_LEFT): + $x_pos = $x_min_pos; + break; + + case (LEGEND_GRAPH_RIGHT): + $x_pos = $x_max_pos - $legend_width; + break; + + default: + $x_pos = $this->origin_x + $this->GetValue('graph_padding'); + } // switch + } // if this is not defined, make it the origin_x position + else { + $x_pos = $this->GetValue('legend_left'); + } // else it is whatever it is + + if ($this->GetValue('legend_top') < 0) { + switch($this->GetValue('legend_top')) { + case (LEGEND_GRAPH_TOP): + $y_pos = $y_max_pos; + break; + + case (LEGEND_GRAPH_BOTTOM): + $y_pos = $y_min_pos - $legend_height; + break; + + default: + $y_pos = $this->origin_y + $this->height - $legend_height - $this->GetValue('graph_padding'); + } // switch what is the legend top? + } // if this is not defined, make it the origin_x position + else { + $y_pos = $this->GetValue('legend_top'); + } // else it is whatever it is + + $this->image_object->DrawFilledRectangle($x_pos, $y_pos, $legend_width, $legend_height, $this->GetColor($this->GetValue('legend_background'), $this->GetValue('legend_background_alpha'))); + $this->image_object->DrawLine($x_pos, $y_pos, $x_pos, $y_pos + $legend_height, $this->GetColor($this->GetValue('legend_border_color'))); + $this->image_object->DrawLine($x_pos + $legend_width, $y_pos, $x_pos + $legend_width, $y_pos + $legend_height, $this->GetColor($this->GetValue('legend_border_color'))); + $this->image_object->DrawLine($x_pos, $y_pos, $x_pos + $legend_width, $y_pos, $this->GetColor($this->GetValue('legend_border_color'))); + $this->image_object->DrawLine($x_pos, $y_pos + $legend_height, $x_pos + $legend_width, $y_pos + $legend_height, $this->GetColor($this->GetValue('legend_border_color'))); + + $x_pos += $this->GetValue('legend_padding'); + + $this->image_object->DrawText($this->GetFont($this->GetValue('legend_title_font')), $x_pos , $y_pos, + $this->GetValue('legend_title'), $this->GetColor($this->GetValue('legend_title_color')), TEXT_HORIZONTAL); + + $this->image_object->DrawLine($x_pos, $y_pos + $title_size['height'], $x_pos + $title_size['width'], $y_pos + $title_size['height'], $this->GetColor($this->GetValue('legend_title_color'))); + + $y_pos = $y_pos + $title_size['height'] + 1 + $this->GetValue('legend_line_padding'); + + while (list(,$dataset_id) = @each($legend_list)) { + if ($this->datasets[$dataset_id]) { + $legend_title = $legend_map[$dataset_id]['options']['legend_title']; + $legend_color = $this->GetColor($legend_map[$dataset_id]['color'], $legend_map[$dataset_id]['options']['alpha']); + $legend_type = $legend_map[$dataset_id]['type']; + $highlight = false; + } // if this is a dataset + else if ($this->highlights[$dataset_id]) { + $legend_title = $this->highlights[$dataset_id]['options']['legend_text']; + $legend_color = $this->GetColor($this->highlights[$dataset_id]['color'], $this->highlights[$dataset_id]['options']['alpha']); + $legend_type = "filled"; + $highlight = true; + } // this is a highlight + else { + continue; + } // else its something else, get out of here + + $y_pad = max($legend_size["$legend_title"]['height'], $this->GetValue('legend_sample_height')) / 2; + + switch ($legend_type) { + case("filled"): + $this->image_object->DrawFilledRectangle($x_pos + $x_pad, $y_pos + $y_pad / 2, + $this->GetValue('legend_sample_width'), $this->GetValue('legend_sample_height'), $legend_color); + $this->image_object->DrawRectangle($x_pos + $x_pad, $y_pos + $y_pad / 2, + $this->GetValue('legend_sample_width'), $this->GetValue('legend_sample_height'), + $this->GetColor($this->GetValue('legend_border_color'))); + break; + + case("bar"): + $bar_width = min($this->GetValue('legend_sample_width'), $this->GetValue('vert_bar_width')); + $x_pad = ceil(($this->GetValue('legend_sample_width') - $bar_width) / 2); + + $this->image_object->DrawGradientRectangle($x_pos + $x_pad, $y_pos + $y_pad / 2, + $bar_width, $this->GetValue('legend_sample_height'), $legend_color); + break; + + case("dashed"): + $this->image_object->DrawDashedLine($x_pos, $y_pos + $y_pad, $x_pos + $this->GetValue('legend_sample_width'), $y_pos + $y_pad, $legend_color); + break; + + case("line"): + default: + $this->image_object->DrawLine($x_pos, $y_pos + $y_pad, $x_pos + $this->GetValue('legend_sample_width'), $y_pos + $y_pad, $legend_color); + break; + } // switch what type of graph was this? + + // Show the title for this data + // + if ($legend_map[$dataset_id]['options']['legend_color']) { + $color = $this->GetColor($legend_map[$dataset_id]['options']['legend_color']); + } // if + else { + $color = $this->GetColor($this->GetValue('legend_text_color')); + } // if...else... what color should this legend text be? + + $this->image_object->DrawText($this->GetFont($this->GetValue('legend_font')), $x_pos + $this->GetValue('legend_sample_width') + $this->GetValue('legend_sample_padding'), $y_pos, + $legend_title, $color, TEXT_HORIZONTAL); + + $y_pos += max($legend_size["$legend_title"]['height'], $this->GetValue('legend_sample_height')) + $this->GetValue('legend_line_padding'); + } // while we step through the legend map + } // function DrawLegend } // class ImagePrimitives Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/VAGRANT.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** VAGRANT.class 2001/11/28 18:39:59 1.1.1.1 --- VAGRANT.class 2001/11/29 23:34:28 1.2 *************** *** 75,78 **** --- 75,80 ---- $this->highlight_map = array(); + $this->legend_map = array(); + $this->graph_map = array(); $this->data_map = array(); $this->datasets = array(); *************** *** 306,309 **** --- 308,315 ---- } // while we step through the data in this graph + if (is_array($this->legend_map[$graph_id]) && sizeof($this->legend_map[$graph_id])) { + $this->graphs[$graph_id]->DrawLegend($this->legend_map[$graph_id]); + } // if we have legends to show + if (is_array($this->highlight_map[$graph_id]) && sizeof($this->highlight_map[$graph_id])) { while (list($highlight_id,) = @each($this->highlight_map[$graph_id])) { *************** *** 327,335 **** */ ! function AddHighlight($object_id, $x_min, $y_min, $x_max, $y_max, $color, $text = "", $options = array(), $axis2 = false) { $object_array = $this->GetObjectArrayFromID($object_id); if ($object_array) { ! $highlight_id = $this->{$object_array}[$object_id]->AddHighlight($x_min, $y_min, $x_max, $y_max, $color, $text, $options, $axis2); $this->highlight_map[$object_id][$highlight_id] = $highlight_id; } // if we got an object array --- 333,341 ---- */ ! function AddHighlight($object_id, $x_min, $y_min, $x_max, $y_max, $color, $options = array(), $axis2 = false) { $object_array = $this->GetObjectArrayFromID($object_id); if ($object_array) { ! $highlight_id = $this->{$object_array}[$object_id]->AddHighlight($x_min, $y_min, $x_max, $y_max, $color, $options, $axis2); $this->highlight_map[$object_id][$highlight_id] = $highlight_id; } // if we got an object array *************** *** 337,340 **** --- 343,360 ---- + /** + * SetGraphType is where the options for the graph are actually set up. + * These options include color, graph type, and legend title + * + * @author Ariel Garza (ag...@va...) + * @param string $graph_id The id of the graph you are adding data for + * @param string $dataset_id The dataset that this graph is for + * @param string $type The type of graph that will represent the data + * @param string $color The color of the graph that will represent the data + * @param array $options Any options you wish to include for the graph. Valid options include: + * alpha (integer) -> The alpha value for the color being used in the graph + * legend_title (string) -> The title to be displayed in the legend + * legend_color (string) -> The color for the title to be displayed in the legend + */ function SetGraphType($graph_id, $dataset_id, $type, $color, $options = array()) { $object_array = $this->GetObjectArrayFromID($graph_id); *************** *** 344,347 **** --- 364,371 ---- $this->graph_map[$graph_id][$dataset_id]['color'] = $color; $this->graph_map[$graph_id][$dataset_id]['options'] = $options; + + if ($options['legend_title']) { + $this->legend_map[$graph_id][$dataset_id] = &$this->graph_map[$graph_id][$dataset_id]; + } // if we are adding this to the legend } // if this is a valid object id } // function SetGraphType Index: test.php =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/test.php,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** test.php 2001/11/28 18:39:59 1.1.1.1 --- test.php 2001/11/29 23:34:28 1.2 *************** *** 15,20 **** $vagrant = new VAGRANT(500,500); ! $graph_id = $vagrant->CreateObject('graph', 0, 0, 500, 250); ! $graph_id2 = $vagrant->CreateObject('graph', 0, 250, 500, 250); // Here is where we will add data --- 15,20 ---- $vagrant = new VAGRANT(500,500); ! $graph_id = $vagrant->CreateObject('graph', 0, 0, 500, 300); ! $graph_id2 = $vagrant->CreateObject('graph', 0, 300, 500, 200); // Here is where we will add data *************** *** 31,34 **** --- 31,35 ---- // $data2 = $vagrant->AddData($x, $y2, $graph_id2); + $vagrant->AddObjectData($graph_id, $data2); // To add data to the right hand axis, just add a true after the $graph_id *************** *** 36,40 **** $data3 = $vagrant->AddData($x, $y3, $graph_id, true); ! $vagrant->SetValue($graph_id, 'title', "Give your graphs titles here"); $vagrant->SetValue($graph_id, 'subtitle', "You may also add subtitles"); $vagrant->SetValue($graph_id, 'x_title', "We have an x title!"); --- 37,49 ---- $data3 = $vagrant->AddData($x, $y3, $graph_id, true); ! $vagrant->SetValue($graph_id, 'legend_title', 'New legend title'); ! $vagrant->SetValue($graph_id, 'legend_top', LEGEND_GRAPH_BOTTOM); ! $vagrant->SetValue($graph_id, 'legend_left', LEGEND_GRAPH_RIGHT); ! ! $vagrant->SetValue($graph_id2, 'legend_border_color', 'yellow'); ! $vagrant->SetValue($graph_id2, 'legend_top', LEGEND_GRAPH_TOP); ! $vagrant->SetValue($graph_id2, 'legend_left', LEGEND_GRAPH_RIGHT); ! ! $vagrant->SetValue($graph_id, 'title', "Give your graph's titles here"); $vagrant->SetValue($graph_id, 'subtitle', "You may also add subtitles"); $vagrant->SetValue($graph_id, 'x_title', "We have an x title!"); *************** *** 50,54 **** //$vagrant->SetValue($graph_id,'y_min', -.5); ! //$vagrant->SetValue($graph_id,'y_max', .5); //$vagrant->SetValue($graph_id,'axis2_min', -20); --- 59,64 ---- //$vagrant->SetValue($graph_id,'y_min', -.5); ! $vagrant->SetValue($graph_id2, 'y_max', .6); ! $vagrant->SetValue($graph_id2, 'y_tick', .5); //$vagrant->SetValue($graph_id,'axis2_min', -20); *************** *** 61,75 **** $vagrant->SetValue($graph_id, 'x_tick', 1); ! $vagrant->SetGraphType($graph_id, $data3, "bar", "green", array('alpha'=>120)); ! $vagrant->SetGraphType($graph_id, $data1, "line", "blue"); ! $vagrant->SetGraphType($graph_id2, $data2, "filled", "red", array('alpha'=>120)); // Add a highlight to the left side axis // ! $vagrant->AddHighlight($graph_id, 1, .3, 5, .5, "blue", "test highlight", array('alpha' => 75, 'font_color' => 'red')); // Add a highlight to the right side axis by adding a true to after the options array // ! $vagrant->AddHighlight($graph_id, 3, 40, 7, "", "yellow", "axis2 highlight", array('alpha' => 75), true); // If you comment out display image and uncomment the infodump function --- 71,86 ---- $vagrant->SetValue($graph_id, 'x_tick', 1); ! $vagrant->SetGraphType($graph_id, $data3, "filled", "green", array('alpha'=>140, 'legend_title' => 'Test Bar Graph Title')); ! $vagrant->SetGraphType($graph_id, $data1, "line", "blue", array('alpha'=>140, 'legend_title' => 'Test Line Graph Title')); ! $vagrant->SetGraphType($graph_id, $data2, "line", "red", array('alpha'=>140, 'legend_title' => 'Test Line Graph Title')); ! $vagrant->SetGraphType($graph_id2, $data2, "filled", "red", array('alpha'=>120, 'legend_title' => 'Sweet red on blue')); // Add a highlight to the left side axis // ! $vagrant->AddHighlight($graph_id, 1, .3, 5, .5, "blue", array('alpha' => 75, 'font_color' => 'red', 'highlight_text' => "test highlight")); // Add a highlight to the right side axis by adding a true to after the options array // ! $vagrant->AddHighlight($graph_id, 3, 40, 7, "", "yellow", array('alpha' => 75, 'legend_text' => "axis2 highlight", 'highlight_text' => "Highlight and legend text!" ), true); // If you comment out display image and uncomment the infodump function |
From: Ariel G. <ag...@us...> - 2001-11-28 19:57:47
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv28531 Modified Files: Graph.class Log Message: forgot to close comment Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** Graph.class 2001/11/28 19:56:46 1.3 --- Graph.class 2001/11/28 19:57:44 1.4 *************** *** 23,27 **** * @param integer $width The width of the graph * @param integer $height The height of the graph ! * function Graph($image_object, $width, $height) { $this->SetLibraryObject($image_object); --- 23,27 ---- * @param integer $width The width of the graph * @param integer $height The height of the graph ! */ function Graph($image_object, $width, $height) { $this->SetLibraryObject($image_object); |
From: Ariel G. <ag...@us...> - 2001-11-28 19:56:49
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv28212 Modified Files: Graph.class Log Message: commented functions (forgot to comment output though) Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** Graph.class 2001/11/28 19:28:38 1.2 --- Graph.class 2001/11/28 19:56:46 1.3 *************** *** 1,8 **** --- 1,27 ---- <?php + /** + * Contains the Graph object. + * @version $Id$ + * @author Ariel Garza (ag...@va...) + */ + require_once(VAGRANT_PATH . "ImagePrimitives.class"); + /** + * Graph object. This is the object that is actually reponsible for graph specific + * functions like graphing and drawing a grid + */ class Graph extends ImagePrimitives { + /** + * Graph is the class constructor. It sets up the image library object, the size of the graph space + * and initializs the image primitives. + * + * @author Ariel Garza (ag...@va...) + * @param object $image_object A reference to the image object created by the VAGRANT.class file + * @param integer $width The width of the graph + * @param integer $height The height of the graph + * function Graph($image_object, $width, $height) { $this->SetLibraryObject($image_object); *************** *** 13,16 **** --- 32,41 ---- + /** + * DrawGrid draws the grid for the graph. It makes sure that the extents of the graph make sense + * checks the tick sizes, draws the axis, performs label substitution... + * + * @author Ariel Garza (ag...@va...) + */ function DrawGrid() { $this->image_object->DrawFilledRectangle($this->origin_x + $this->GetValue('graph_padding'), $this->origin_y + $this->GetValue('graph_padding'), *************** *** 279,282 **** --- 304,317 ---- + /** + * DrawGraph draws the graph of a specified dataset. + * + * @author Ariel Garza (ag...@va...) + * @param string $dataset_id The id of the dataset you are graphing + * @param string $type The type of graph you are drawing + * @param string $color What color do you want to draw the graph + * @param array $options is an array containing graph options. Valid options are: + * alpha (integer) -> The alpha value of the given color + */ function DrawGraph($dataset_id, $type, $color, $options = array()) { if (!is_array($options)) { *************** *** 425,431 **** } // while we step through the points } // DrawGraph - - function LineGraph($dataset_id, $color) { - } // function LineGraph } // class Graph --- 460,463 ---- |
From: Ariel G. <ag...@us...> - 2001-11-28 19:45:05
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv22670 Modified Files: ImagePrimitives.class Log Message: commented functions (forgot to comment output though) Index: ImagePrimitives.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/ImagePrimitives.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** ImagePrimitives.class 2001/11/28 18:40:00 1.1.1.1 --- ImagePrimitives.class 2001/11/28 19:40:24 1.2 *************** *** 1,7 **** --- 1,18 ---- <?php + /** + * Contains ImagePrimitives class. + * @version $Id$ + * @author Ariel Garza (ag...@va...) + */ + define('ROUND_UP', 1); define('ROUND_DOWN', 2); + /** + * ImagePrimitives is the base class that contains data manipulating functions, + * constants, variable editing/fetching functions and other things that will be useful + * to anything drawn inside of the vagrant image. + */ class ImagePrimitives { *************** *** 16,19 **** --- 27,36 ---- + /** + * InitializePrimitives sets up the variables that will be used throughout the final object. + * These include padding variables, font variable, titles, colors... + * + * @author Ariel Garza (ag...@va...) + */ function InitializePrimitives() { $this->text_size = $this->image_object->GetTextSize('M',TEXT_HORIZONTAL); *************** *** 109,112 **** --- 126,139 ---- + /** + * GetColor looks up a color and returns the color array to the caller. If an alpha + * value was passed in, it overrides the color's original alpha value. This makes it + * easier for things that would otherwise require a new color to be created. If the + * color is not found, gray is returned. + * + * @author Ariel Garza (ag...@va...) + * @param string $name The name of the color. + * @param integer $alpha_level A custom alpha value to use with the RGB values. + */ function &GetColor($name, $alpha_level = 0) { if (!$GLOBALS['colors'][$name]) { *************** *** 126,129 **** --- 153,163 ---- + /** + * SetOrigin + * + * @author Ariel Garza (ag...@va...) + * @param integer $left The absolute image left coordinate of this graph + * @param integer $top The absolute image top coordinate of this graph + */ function SetOrigin($left, $top) { $this->origin_x = $left; *************** *** 132,152 **** ! function SetImageSize($width, $height) { $this->image_width = $width; $this->image_height = $height; } // function SetImageSize - - function SetXPadding($x_padding) { - $this->USER_VALUES['x_padding'] = $x_padding; - } // function SetXPadding - ! function SetYPadding($y_padding) { ! $this->USER_VALUES['y_padding'] = $y_padding; ! } // function SetYPadding ! ! ! function SetSize($width, $height) { $this->SetWidth(min($this->image_object->image_width - $this->origin_x, $width)); $this->SetHeight(min($this->image_object->image_height - $this->origin_y, $height)); --- 166,191 ---- ! /** ! * SetImageSize ! * ! * @author Ariel Garza (ag...@va...) ! * @param integer $width The width of the encompassing image ! * @param integer $height The height of the encompassing image ! */ ! function SetImageSize($width, $height) { $this->image_width = $width; $this->image_height = $height; } // function SetImageSize ! /** ! * SetSize sets the size of the graph to either the size specified, or the largest size that fits ! * given the graphs origin coordinates. ! * ! * @author Ariel Garza (ag...@va...) ! * @param integer $width The width value to set the width of the graph to ! * @param integer $height The height value to set the height of the graph to ! */ ! function SetSize($width, $height) { $this->SetWidth(min($this->image_object->image_width - $this->origin_x, $width)); $this->SetHeight(min($this->image_object->image_height - $this->origin_y, $height)); *************** *** 154,168 **** ! function SetWidth($width) { $this->width = $width; } // function SetWidth ! function SetHeight($height) { $this->height = $height; } // function SetHeight ! function GetImageLocation($x_value, $y_value, &$x_pixel, &$y_pixel, $axis2 = false) { $title_size = $this->GetValue('title_size'); $subtitle_size = $this->GetValue('subtitle_size'); --- 193,230 ---- ! /** ! * SetWidth sets the width regardless of value ! * ! * @author Ariel Garza (ag...@va...) ! * @param integer $width Sets the width of the graph ! */ ! function SetWidth($width) { $this->width = $width; } // function SetWidth ! /** ! * SetHeight sets the height regardless of value ! * ! * @author Ariel Garza (ag...@va...) ! * @param integer $height Sets the width of the graph ! */ ! function SetHeight($height) { $this->height = $height; } // function SetHeight ! /** ! * GetImageLocation takes a point in data space and converts it into coordinates in pixel space. ! * All points output by this are relative to the origin of the image, not the graph. ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $x_value The x value that you are looking for a position for ! * @param float $y_value The y value that you are looking for a position for ! * @param integer $x_pixel Taken by reference it is altered to be the corresponding x location to the x_value ! * @param integer $y_pixel Taken by reference it is altered to be the corresponding y location to the y_value ! * @param boolean $axis2 Is this being translated based on the axis2 extents ! */ ! function GetImageLocation($x_value, $y_value, &$x_pixel, &$y_pixel, $axis2 = false) { $title_size = $this->GetValue('title_size'); $subtitle_size = $this->GetValue('subtitle_size'); *************** *** 223,236 **** - function SetFont($type, $font) { - $this->fonts[$type] = $font; - } // function SetFont - /** * GetFont gets a font for display. This seems to crash badly if the font is invalid so * make sure that your font requests are accurate. */ ! function GetFont($type) { if (!$type) { $type = $this->GetValue('default_font'); --- 285,297 ---- /** * GetFont gets a font for display. This seems to crash badly if the font is invalid so * make sure that your font requests are accurate. + * + * @author Ariel Garza (ag...@va...) + * @param string $type This is a font specifier based on your image library (like ./ARIAL/8 for 8 point ARIAL in imlib2) */ ! function GetFont($type) { if (!$type) { $type = $this->GetValue('default_font'); *************** *** 293,297 **** ! function DrawHighlight($highlight_id) { if (is_array($this->highlights) && $this->highlights[$highlight_id]) { if ($this->highlights[$highlight_id]['axis2']) { --- 354,364 ---- ! /** ! * DrawHighlight draws the specified highlighted region ! * ! * @author Ariel Garza (ag...@va...) ! * @param string $highlight_id The id of the highlight region you want to draw ! */ ! function DrawHighlight($highlight_id) { if (is_array($this->highlights) && $this->highlights[$highlight_id]) { if ($this->highlights[$highlight_id]['axis2']) { *************** *** 357,399 **** **************************************************************/ ! function SetGridPrecision($precision) { $this->USER_VALUES['grid_precision'] = abs($precision); } // function SetGridPrecision - - function SetNumXGridLines($num_grid) { - $this->USER_VALUES['num_x_grid'] = max($num_grid, 1); - } // function SetNumXGridLines - - - function SetNumYGridLines($num_grid) { - $this->USER_VALUES['num_y_grid'] = max($num_grid, 1); - } // function SetNumYGridLines - - - function SetXTick($x_tick) { - if ($x_tick) { - $this->USER_VALUES['x_tick'] = $x_tick; - - return true; - } // if - else { - return false; - } - } // function SetXTick - ! function SetYTick($y_tick) { ! if ($y_tick) { ! $this->USER_VALUES['y_tick'] = $y_tick; ! return true; ! } ! else { ! return false; ! } ! } // function SetYTick ! ! ! function GetAxisMin($axis_min, $data_diff, $num_grid) { $new_min = $this->AdjustNum($axis_min, $data_diff, ROUND_DOWN); --- 424,448 ---- **************************************************************/ ! /** ! * SetGridPrecision sets the decimal precision to use in the grid. ! * Tick marks will be rounded according to the level of decimal precision here. ! * ! * @author Ariel Garza (ag...@va...) ! * @param integer $precision The number of decimal places to round to. ! */ ! function SetGridPrecision($precision) { $this->USER_VALUES['grid_precision'] = abs($precision); } // function SetGridPrecision ! /** ! * GetAxisMin gets a value that is usable as an axis minimum (always rounding down) ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $axis_min The current axis minimum ! * @param float $data_diff The difference between the current axis max and axis min ! * @param integer $num_grid How many grid lines are being used? This has affect due to grid precision ! */ ! function GetAxisMin($axis_min, $data_diff, $num_grid) { $new_min = $this->AdjustNum($axis_min, $data_diff, ROUND_DOWN); *************** *** 402,406 **** ! function GetAxisMax($axis_max, $data_diff, $num_grid) { $new_max = $this->AdjustNum($axis_max, $data_diff, ROUND_UP); --- 451,463 ---- ! /** ! * GetAxisMax gets a value that is suitable as an axis maximum (always rounds up) ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $axis_max The current axis maximum ! * @param float $data_diff The difference between the current axis max and axis min ! * @param integer $num_grid How many grid lines are being used? This has affect due to grid precision ! */ ! function GetAxisMax($axis_max, $data_diff, $num_grid) { $new_max = $this->AdjustNum($axis_max, $data_diff, ROUND_UP); *************** *** 409,413 **** ! function GetTick($data_diff, $num_grid, $integer = false) { $tick_guess = $data_diff / $num_grid; $tick = $this->AdjustNum($tick_guess, $data_diff); --- 466,478 ---- ! /** ! * GetTick gets the tick value for an axis based on data span, grid lines and grid precision ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $data_diff The difference between the current axis max and axis min ! * @param integer $num_grid How many grid lines are being used? This has affect due to grid precision ! * @param boolean $integer Are we only looking for integers? ! */ ! function GetTick($data_diff, $num_grid, $integer = false) { $tick_guess = $data_diff / $num_grid; $tick = $this->AdjustNum($tick_guess, $data_diff); *************** *** 421,425 **** ! function AdjustNum($num, $data_diff, $round = ROUND_UP) { if ($round == ROUND_UP) { $round_func = 'ceil'; --- 486,501 ---- ! /** ! * AdjustNum adjust numbers to be "viewer friendly" taking into account data diff and grid precision. ! * Grid precision is used after the number of decimals in data_diff. If you have a min of 4.2 and a ! * max of 4.20005, the data diff is .00005 so if the grid precision is 2, you can have tick marks that ! * are 4.2000115. ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $num The number you want adjusted ! * @param float $data_diff The difference between the min and max data of interest (could be axis extents or consecutive ticks) ! * @param integer $round What direction are you going to round in? ! */ ! function AdjustNum($num, $data_diff, $round = ROUND_UP) { if ($round == ROUND_UP) { $round_func = 'ceil'; *************** *** 445,449 **** **************************************************************/ ! function AddData($id, $dataset, $axis2 = false) { $this->datasets[$id] = $dataset; --- 521,534 ---- **************************************************************/ ! /** ! * AddData adds a dataset to this object. The dataset itself should just be a pointer to the real data set ! * to conserve memory. ! * ! * @author Ariel Garza (ag...@va...) ! * @param string $id The dataset id as seen by the VAGRANT.class file ! * @param array $dataset The dataset that you are adding to this graph ! * @param boolean $axis2 Is this dataset being added to axis2? ! */ ! function AddData($id, $dataset, $axis2 = false) { $this->datasets[$id] = $dataset; *************** *** 474,478 **** ! function &GetValue($name, $internal_value = 0) { if (!$internal_value && $this->IsUserValue($name)) { return $this->USER_VALUES[$name]; --- 559,572 ---- ! /** ! * &GetValue gets the highest level of value desired (default, user or last ditch) ! * Most values start out int he DEFAULTS array and get added to the USER_VALUES array ! * when it is edited. Somethings (like origin_x) are just object vars so those are checked last. ! * ! * @author Ariel Garza (ag...@va...) ! * @param string $name The name of the variable that you want to fetch ! * @param boolean $internal_value If you want to ignore the user value, pass in true or something here. ! */ ! function &GetValue($name, $internal_value = false) { if (!$internal_value && $this->IsUserValue($name)) { return $this->USER_VALUES[$name]; *************** *** 487,496 **** ! function IsUserValue($name) { return isset($this->USER_VALUES[$name]); } // function IsUserValue ! function SetValue($name, $value) { $this->USER_VALUES[$name] = $value; --- 581,605 ---- ! /** ! * IsUserValue checks to see if a given variable has been modified from the default ! * ! * @author Ariel Garza (ag...@va...) ! * @param string $name The name of the variable that you are checking on. ! */ ! function IsUserValue($name) { return isset($this->USER_VALUES[$name]); } // function IsUserValue ! /** ! * SetValue is the meat of the variable system. It takes a variable name and value and checks a ! * switch statement to see if that variable requires more to be done than a simple value update. ! * All values updated through this function are placed in the USER_VALUES array. ! * ! * @author Ariel Garza (ag...@va...) ! * @param string $name The name of the variable that you are setting ! * @param string $value The value you wish to assign. Could be an array, boolean, int, string ,... ! */ ! function SetValue($name, $value) { $this->USER_VALUES[$name] = $value; *************** *** 547,551 **** ! function SetFontSize($name, $value, $direction = TEXT_HORIZONTAL) { if ($value == '') { $this->USER_VALUES[$name . '_size'] = array('width' => 0, 'height' => 0); --- 656,669 ---- ! /** ! * SetFontSize sets the font size for a given font and string. ! * If there is no string present, it forces a value of 0 for height and width. ! * ! * @author Ariel Garza (ag...@va...) ! * @param string $name The name of the font variable (eg. x_tick_font) ! * @param string $value The text string being sized ! * @param integer $direction The direction that the string being sized is being drawn. Defaults to horizontal ! */ ! function SetFontSize($name, $value, $direction = TEXT_HORIZONTAL) { if ($value == '') { $this->USER_VALUES[$name . '_size'] = array('width' => 0, 'height' => 0); *************** *** 556,560 **** ! function SetXMax($x_max, $internal = 0) { if ($internal) { $this->x_max = max($x_max, $this->x_max); --- 674,685 ---- ! /** ! * SetXMax sets the max of the x axis for the graph. It also appropriately resets the data_diff ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $x_max The value to set the x max to ! * @param boolean $internal Is this being set for the user or for the graph? ! */ ! function SetXMax($x_max, $internal = false) { if ($internal) { $this->x_max = max($x_max, $this->x_max); *************** *** 570,574 **** ! function SetXMin($x_min, $internal = 0) { if ($internal) { if (!isset($this->x_min)) { --- 695,706 ---- ! /** ! * SetXMin sets the min of the x axis for the graph. It also appropriately resets the data_diff ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $x_min The value to set the x min to ! * @param boolean $internal Is this being set for the user or for the graph? ! */ ! function SetXMin($x_min, $internal = 0) { if ($internal) { if (!isset($this->x_min)) { *************** *** 588,592 **** ! function SetYMax($y_max, $internal = 0) { if ($internal) { $this->y_max = max($y_max, $this->y_max); --- 720,731 ---- ! /** ! * SetYMax sets the max of the y axis for the graph. It also appropriately resets the data_diff ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $y_max The value to set the y max to ! * @param boolean $internal Is this being set for the user or for the graph? ! */ ! function SetYMax($y_max, $internal = 0) { if ($internal) { $this->y_max = max($y_max, $this->y_max); *************** *** 602,606 **** ! function SetYMin($y_min, $internal = 0) { if ($internal) { if (!isset($this->y_min)) { --- 741,752 ---- ! /** ! * SetYMin sets the min of the y axis for the graph. It also appropriately resets the data_diff ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $y_min The value to set the y min to ! * @param boolean $internal Is this being set for the user or for the graph? ! */ ! function SetYMin($y_min, $internal = 0) { if ($internal) { if (!isset($this->y_min)) { *************** *** 620,624 **** ! function SetAxis2Max($axis2_max, $internal = 0) { if ($internal) { $this->axis2_max = max($axis2_max, $this->axis2_max); --- 766,777 ---- ! /** ! * SetAxis2Max sets the max of the axis2 axis for the graph. It also appropriately resets the data_diff ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $axis2_max The value to set the axis2 max to ! * @param boolean $internal Is this being set for the user or for the graph? ! */ ! function SetAxis2Max($axis2_max, $internal = 0) { if ($internal) { $this->axis2_max = max($axis2_max, $this->axis2_max); *************** *** 634,638 **** ! function SetAxis2Min($axis2_min, $internal = 0) { if ($internal) { if (!isset($this->axis2_min)) { --- 787,798 ---- ! /** ! * SetAxis2Min sets the min of the axis2 axis for the graph. It also appropriately resets the data_diff ! * ! * @author Ariel Garza (ag...@va...) ! * @param float $axis2_min The value to set the axis2 min to ! * @param boolean $internal Is this being set for the user or for the graph? ! */ ! function SetAxis2Min($axis2_min, $internal = 0) { if ($internal) { if (!isset($this->axis2_min)) { *************** *** 652,656 **** ! function SetXDataDiff($internal) { $x_data_diff = $this->GetValue('x_max', $internal) - $this->GetValue('x_min', $internal); --- 812,822 ---- ! /** ! * SetXDataDiff sets the datadiff for the x axis. ! * ! * @author Ariel Garza (ag...@va...) ! * @param boolean $internal Change the internal data_diff or external? ! */ ! function SetXDataDiff($internal) { $x_data_diff = $this->GetValue('x_max', $internal) - $this->GetValue('x_min', $internal); *************** *** 665,669 **** ! function SetYDataDiff($internal) { $y_data_diff = $this->GetValue('y_max', $internal) - $this->GetValue('y_min', $internal); --- 831,841 ---- ! /** ! * SetYDataDiff sets the datadiff for the y axis. ! * ! * @author Ariel Garza (ag...@va...) ! * @param boolean $internal Change the internal data_diff or external? ! */ ! function SetYDataDiff($internal) { $y_data_diff = $this->GetValue('y_max', $internal) - $this->GetValue('y_min', $internal); *************** *** 678,682 **** ! function SetAxis2DataDiff($internal) { $axis2_data_diff = $this->GetValue('axis2_max', $internal) - $this->GetValue('axis2_min', $internal); --- 850,860 ---- ! /** ! * SetAxis2DataDiff sets the datadiff for axis2. ! * ! * @author Ariel Garza (ag...@va...) ! * @param boolean $internal Change the internal data_diff or external? ! */ ! function SetAxis2DataDiff($internal) { $axis2_data_diff = $this->GetValue('axis2_max', $internal) - $this->GetValue('axis2_min', $internal); *************** *** 691,695 **** ! function IsDrawable($coord, $axis2 = false) { if ($axis2) { $axis_min = "axis2_min"; --- 869,880 ---- ! /** ! * IsDrawable checks a coordinate and sees if it is within the bounds of the graph ! * ! * @author Ariel Garza (ag...@va...) ! * @param array $coord The coordinate to check. Contains x and y keys that are in the data space ! * @param boolean $axis2 Is this using the y coordinates of axis2 instead? ! */ ! function IsDrawable($coord, $axis2 = false) { if ($axis2) { $axis_min = "axis2_min"; *************** *** 708,712 **** ! function GetGraphicalCoords($start_point, $end_point, $axis2 = false) { if ($this->IsDrawable($start_point, $axis2) && $this->IsDrawable($end_point, $axis2)) { return array($start_point, $end_point); --- 893,907 ---- ! /** ! * GetGraphicalCoords gets two coordinates as the should be drawn *in* the graph. If the ! * line represented by the two points only intersects the graph but is not completely contained within, ! * the line is interpolated and end points that are graphable are returned. ! * ! * @author Ariel Garza (ag...@va...) ! * @param array $start_point The coordinate to check. Contains x and y keys that are in the data space ! * @param array $end_point The coordinate to check. Contains x and y keys that are in the data space ! * @param boolean $axis2 Is this using the y coordinates of axis2 instead? ! */ ! function GetGraphicalCoords($start_point, $end_point, $axis2 = false) { if ($this->IsDrawable($start_point, $axis2) && $this->IsDrawable($end_point, $axis2)) { return array($start_point, $end_point); *************** *** 801,805 **** **************************************************************/ ! function DrawTitle() { if ($this->GetValue('title')) { $title_size = $this->GetValue('title_size'); --- 996,1005 ---- **************************************************************/ ! /** ! * DrawTitle draws the title of the graph ! * ! * @author Ariel Garza (ag...@va...) ! */ ! function DrawTitle() { if ($this->GetValue('title')) { $title_size = $this->GetValue('title_size'); *************** *** 813,817 **** ! function DrawSubtitle() { if ($this->GetValue('subtitle')) { $title_size = $this->GetValue('title_size'); --- 1013,1022 ---- ! /** ! * DrawSubtitle draws the subtitle for the graph ! * ! * @author Ariel Garza (ag...@va...) ! */ ! function DrawSubtitle() { if ($this->GetValue('subtitle')) { $title_size = $this->GetValue('title_size'); *************** *** 826,830 **** ! function DrawXTitle() { if ($this->GetValue('x_title')) { $title_size = $this->GetValue('x_title_size'); --- 1031,1040 ---- ! /** ! * DrawXTitle draws the title of the x axis ! * ! * @author Ariel Garza (ag...@va...) ! */ ! function DrawXTitle() { if ($this->GetValue('x_title')) { $title_size = $this->GetValue('x_title_size'); *************** *** 838,842 **** ! function DrawYTitle() { if ($this->GetValue('y_title')) { $title_size = $this->GetValue('y_title_size'); --- 1048,1057 ---- ! /** ! * DrawYTitle draws the title of the y axis ! * ! * @author Ariel Garza (ag...@va...) ! */ ! function DrawYTitle() { if ($this->GetValue('y_title')) { $title_size = $this->GetValue('y_title_size'); *************** *** 850,854 **** ! function DrawAxis2Title() { if ($this->GetValue('axis2_title')) { $title_size = $this->GetValue('axis2_title_size'); --- 1065,1074 ---- ! /** ! * DrawAxis2Title draws the title for axis2 ! * ! * @author Ariel Garza (ag...@va...) ! */ ! function DrawAxis2Title() { if ($this->GetValue('axis2_title')) { $title_size = $this->GetValue('axis2_title_size'); |
From: Ariel G. <ag...@us...> - 2001-11-28 19:28:43
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv17249 Modified Files: Graph.class Log Message: fix set min/max in drawgrid if user changed max/min Index: Graph.class =================================================================== RCS file: /cvsroot/vagrant/vagrant-2.5/Graph.class,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** Graph.class 2001/11/28 18:40:00 1.1.1.1 --- Graph.class 2001/11/28 19:28:38 1.2 *************** *** 117,124 **** // Now just make sure that the min's and max's line up // ! $this->SetXMin($x_start); ! $this->SetXMax($x_start + $this->GetValue('x_tick') * $this->GetValue('num_x_grid')); ! $this->SetYMin($y_start); ! $this->SetYMax($y_start + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); // In order to draw everything right, we need to get the sizes of the tick marks before we display them --- 117,135 ---- // Now just make sure that the min's and max's line up // ! if (!$this->IsUserValue('x_min')) { ! $this->SetXMin($x_start); ! } // if this is not a user value ! ! if (!$this->IsUserValue('x_max')) { ! $this->SetXMax($x_start + $this->GetValue('x_tick') * $this->GetValue('num_x_grid')); ! } // if this is not a user value ! ! if (!$this->IsUserValue('y_min')) { ! $this->SetYMin($y_start); ! } // if this is not a user value ! ! if (!$this->IsUserValue('y_max')) { ! $this->SetYMax($y_start + $this->GetValue('y_tick') * $this->GetValue('num_y_grid')); ! } // if this is not a user value // In order to draw everything right, we need to get the sizes of the tick marks before we display them |
From: Ariel G. <ag...@us...> - 2001-11-28 18:40:03
|
Update of /cvsroot/vagrant/vagrant-2.5 In directory usw-pr-cvs1:/tmp/cvs-serv31604 Log Message: This is vagrant 2.5. all files except for image library files have been completely rewritten Status: Vendor Tag: vendor Release Tags: start N vagrant-2.5/test.php N vagrant-2.5/VAGRANT.class N vagrant-2.5/VAGRANT.gd2.class N vagrant-2.5/VAGRANT.imlib.class N vagrant-2.5/Chart.class N vagrant-2.5/ARIAL.TTF N vagrant-2.5/Graph.class N vagrant-2.5/ImagePrimitives.class N vagrant-2.5/Classes.txt N vagrant-2.5/ImageText.class N vagrant-2.5/README No conflicts created by this import ***** Bogus filespec: - Imported sources |
From: Ariel G. <ag...@us...> - 2001-11-21 20:11:12
|
Update of /cvsroot/vagrant/vagrant In directory usw-pr-cvs1:/tmp/cvs-serv28431 Modified Files: VAGRANT.class Log Message: label height fixes, no data is customizable string Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant/VAGRANT.class,v retrieving revision 1.33 retrieving revision 1.34 diff -C2 -d -r1.33 -r1.34 *** VAGRANT.class 2001/11/21 19:43:11 1.33 --- VAGRANT.class 2001/11/21 20:11:08 1.34 *************** *** 259,262 **** --- 259,264 ---- function InitGraph($width,$height) { //$height = max(450,$height); + $this->no_data = 0; + $this->no_data_string = "No Data"; $this->perLegendHeight = 20; *************** *** 504,508 **** } // if we are drawing text horizontally else { ! $line_width = $text_size['width']; $line_list = array(); $word_line = ''; --- 506,510 ---- } // if we are drawing text horizontally else { ! $line_width = floor($text_size['width'] / 2); $line_list = array(); $word_line = ''; *************** *** 533,537 **** $num_lines = sizeof($line_list); $left_pos = $x - ($height_mod * $num_lines) + ($text_space * ($num_lines - 1)); ! $height_base = $y + $line_width / 2; while (list(, $word_line) = @each($line_list)) { --- 535,539 ---- $num_lines = sizeof($line_list); $left_pos = $x - ($height_mod * $num_lines) + ($text_space * ($num_lines - 1)); ! $height_base = $y + $height_mod + $text_space + $line_width / 2; while (list(, $word_line) = @each($line_list)) { *************** *** 721,732 **** */ function DrawGrid($color) { - $numGrid = 10; - // For labelling grids, we need to shrink the graph to fit the labels // ! $max_label_width = $this->GetMaxLabelSize("x"); $xNum = $this->graph_width / $this->xAxisSpacing; $numxGrid = round(min($numGrid, $xNum)); if ($this->xLabel) { --- 723,738 ---- */ function DrawGrid($color) { // For labelling grids, we need to shrink the graph to fit the labels // ! $max_label_width = $this->GetMaxLabelSize("x") / 2; ! $this->graph_height -= $max_label_width; + $numGrid = 10; + $xNum = $this->graph_width / $this->xAxisSpacing; + $yNum = $this->graph_height / $this->yAxisSpacing; + $numxGrid = round(min($numGrid, $xNum)); + $numyGrid = round(min($numGrid, $yNum)); if ($this->xLabel) { *************** *** 736,756 **** } - if (!$this->xTick) { - $xTick = $this->adjustNum(($this->xdata_diff / $numxGrid), $this->xdata_diff, $numxGrid, $xIntOnly); - } // if someone has set a x tick size - else { - $xTick = $this->xTick; - } // else set the tick - - if ($max_label_width > $xTick * 2) { - $this->graph_height -= $max_label_width; - } // if - else { - $this->graph_height -= $max_label_width / 2; - } // else - - $yNum = $this->graph_height / $this->yAxisSpacing; - $numyGrid = round(min($numGrid, $yNum)); - if (!$this->yTick) { $yTick = $this->adjustNum(($this->ydata_diff / $numyGrid), $this->ydata_diff, $numyGrid); --- 742,745 ---- *************** *** 760,763 **** --- 749,759 ---- } // else set the tick + if (!$this->xTick) { + $xTick = $this->adjustNum(($this->xdata_diff / $numxGrid), $this->xdata_diff, $numxGrid,$xIntOnly); + } // if someone has set a x tick size + else { + $xTick = $this->xTick; + } // else set the tick + $xLabelYMod = $this->x_label_y_mod; *************** *** 782,787 **** if ($this->show_axis2) { ! if (!$this->axis2_ytick) { ! $axis2_ytick = $this->adjustNum(($this->axis2['ydata_diff']/ ($numyGrid - 1)), $this->axis2['ydata_diff'], $numyGrid - 1); } else { $axis2_ytick = $this->axis2_ytick; --- 778,783 ---- if ($this->show_axis2) { ! if (!$this->axis2_ytick || ($this->axis2_ytick * ($numyGrid - 1) < $this->axis2['ymax'])) { ! $axis2_ytick = $this->adjustNum(($this->axis2['ydata_diff'] / ($numyGrid - 1)), $this->axis2['ydata_diff'], $numyGrid - 1); } else { $axis2_ytick = $this->axis2_ytick; *************** *** 851,859 **** $strSize = $this->GetTextSize($gridy,0); $this->axis1Padding = max($this->axis1Padding,$strSize['width']); - - $label_top = $y0 - ($strSize['height'] / 2); - $label_left = $x0 - $strSize['width'] - $this->xTickPadding; ! $this->DrawText($this->font,$label_left,$label_top,$gridy,"black",0); if ($axis2_ytick) { --- 847,852 ---- $strSize = $this->GetTextSize($gridy,0); $this->axis1Padding = max($this->axis1Padding,$strSize['width']); ! $this->DrawText($this->font,$x0 - $strSize['width'] - $this->xTickPadding,$y0 - ($strSize['height'] / 2),$gridy,"black",0); if ($axis2_ytick) { *************** *** 906,915 **** $legend_text_size = $this->GetTextSize($legend_title,0); ! $legend_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $legend_text_size['height']; $this->DrawText($this->font,10,$legend_top,"Legend:","black",0); $this->DrawLine(10,$legend_top + $legend_text_size['height'],47,$legend_top + $legend_text_size['height'],"black"); ! $current_top = $legend_top + $legend_text_size['height']; while (list($dataset,$legendInfo) = @each($this->legend)) { --- 899,908 ---- $legend_text_size = $this->GetTextSize($legend_title,0); ! $legend_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $this->x_label_y_mod * 2 + $this->xTickPadding + $legend_text_size['height']; $this->DrawText($this->font,10,$legend_top,"Legend:","black",0); $this->DrawLine(10,$legend_top + $legend_text_size['height'],47,$legend_top + $legend_text_size['height'],"black"); ! $current_top = $legend_top + $legend_text_size['height'] + 2; while (list($dataset,$legendInfo) = @each($this->legend)) { *************** *** 1703,1707 **** $text_left = ($this->image_width / 2) - ($titleSize['width'] / 2); ! $text_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $titleSize['height']; $this->DrawText($this->font,$text_left,$text_top,$this->xTitle,"black",0); --- 1696,1700 ---- $text_left = ($this->image_width / 2) - ($titleSize['width'] / 2); ! $text_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $this->x_label_y_mod * 2 + $this->xTickPadding + $titleSize['height']; $this->DrawText($this->font,$text_left,$text_top,$this->xTitle,"black",0); *************** *** 1830,1836 **** ! function NoData() { ! $this->InitGraph(80,20); ! $this->DrawText($this->font,20,0, "No Data","black",0); } // function --- 1823,1835 ---- ! function NoData($message = "No Data") { ! $text_size = $this->GetTextSize($message,0); ! $xpad = 20; ! ! $this->InitGraph($text_size['width'] + 2*$xpad,20); ! $this->no_data_string = $message; ! $this->DrawText($this->font,20,0, $this->no_data_string,"black",0); ! ! $this->no_data = 1; } // function *************** *** 1846,1852 **** header ("Pragma: no-cache"); // HTTP/1.0 ! if ($this->max_num_points == 0) { ! $this->NoData(); } // if $this->DrawImage(); } // function ShowGraph --- 1845,1852 ---- header ("Pragma: no-cache"); // HTTP/1.0 ! if (($this->max_num_points == 0) && !$this->no_data) { ! $this->NoData('No Data'); } // if + $this->DrawImage(); } // function ShowGraph |
From: Ariel G. <ag...@us...> - 2001-11-21 19:43:14
|
Update of /cvsroot/vagrant/vagrant In directory usw-pr-cvs1:/tmp/cvs-serv17980 Modified Files: VAGRANT.class Log Message: fixed axis2 grid labelling Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant/VAGRANT.class,v retrieving revision 1.32 retrieving revision 1.33 diff -C2 -d -r1.32 -r1.33 *** VAGRANT.class 2001/10/25 19:32:26 1.32 --- VAGRANT.class 2001/11/21 19:43:11 1.33 *************** *** 420,440 **** $divisor = 1; } - $num = round($num / $divisor) * $divisor; - - $newnum = $num; - - if ($num >= .2) { - $newnum = .25; - } // if - - if ($num >= .5) { - $newnum = .5; - } // if ! if ($num >= .7) { ! $newnum = 1; ! } // if ! ! $num = $newnum; } // if --- 420,425 ---- $divisor = 1; } ! $num = ceil($num / $divisor) * $divisor; } // if *************** *** 752,756 **** if (!$this->xTick) { ! $xTick = $this->adjustNum(($this->xdata_diff / $numxGrid), $this->xdata_diff, $numxGrid,$xIntOnly); } // if someone has set a x tick size else { --- 737,741 ---- if (!$this->xTick) { ! $xTick = $this->adjustNum(($this->xdata_diff / $numxGrid), $this->xdata_diff, $numxGrid, $xIntOnly); } // if someone has set a x tick size else { *************** *** 798,802 **** if ($this->show_axis2) { if (!$this->axis2_ytick) { ! $axis2_ytick = $this->adjustNum(($this->axis2['ydata_diff'] / $numyGrid), $this->axis2['ydata_diff'], $numyGrid); } else { $axis2_ytick = $this->axis2_ytick; --- 783,787 ---- if ($this->show_axis2) { if (!$this->axis2_ytick) { ! $axis2_ytick = $this->adjustNum(($this->axis2['ydata_diff']/ ($numyGrid - 1)), $this->axis2['ydata_diff'], $numyGrid - 1); } else { $axis2_ytick = $this->axis2_ytick; |
From: Ariel G. <ag...@us...> - 2001-10-25 19:32:29
|
Update of /cvsroot/vagrant/vagrant In directory usw-pr-cvs1:/tmp/cvs-serv28920 Modified Files: VAGRANT.class Log Message: There are problems getting the graph size to adjust according to xlabels. I hacked it quickly so that it works most of the time but I think I have to wrap all of the labels and then figure out the max height, then change the graph size, and then draw them to get it to look correct. Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant/VAGRANT.class,v retrieving revision 1.31 retrieving revision 1.32 diff -C2 -d -r1.31 -r1.32 *** VAGRANT.class 2001/10/25 19:03:03 1.31 --- VAGRANT.class 2001/10/25 19:32:26 1.32 *************** *** 519,523 **** } // if we are drawing text horizontally else { ! $line_width = floor($text_size['width'] / 2); $line_list = array(); $word_line = ''; --- 519,523 ---- } // if we are drawing text horizontally else { ! $line_width = $text_size['width']; $line_list = array(); $word_line = ''; *************** *** 548,552 **** $num_lines = sizeof($line_list); $left_pos = $x - ($height_mod * $num_lines) + ($text_space * ($num_lines - 1)); ! $height_base = $y + $height_mod + $text_space + $line_width / 2; while (list(, $word_line) = @each($line_list)) { --- 548,552 ---- $num_lines = sizeof($line_list); $left_pos = $x - ($height_mod * $num_lines) + ($text_space * ($num_lines - 1)); ! $height_base = $y + $line_width / 2; while (list(, $word_line) = @each($line_list)) { *************** *** 736,751 **** */ function DrawGrid($color) { // For labelling grids, we need to shrink the graph to fit the labels // ! $max_label_width = $this->GetMaxLabelSize("x") / 2; ! $this->graph_height -= $max_label_width; ! ! $numGrid = 10; $xNum = $this->graph_width / $this->xAxisSpacing; - $yNum = $this->graph_height / $this->yAxisSpacing; - $numxGrid = round(min($numGrid, $xNum)); - $numyGrid = round(min($numGrid, $yNum)); if ($this->xLabel) { --- 736,747 ---- */ function DrawGrid($color) { + $numGrid = 10; + // For labelling grids, we need to shrink the graph to fit the labels // ! $max_label_width = $this->GetMaxLabelSize("x"); $xNum = $this->graph_width / $this->xAxisSpacing; $numxGrid = round(min($numGrid, $xNum)); if ($this->xLabel) { *************** *** 755,765 **** } - if (!$this->yTick) { - $yTick = $this->adjustNum(($this->ydata_diff / $numyGrid), $this->ydata_diff, $numyGrid); - } // if no body has set a y tick size - else { - $yTick = $this->yTick; - } // else set the tick - if (!$this->xTick) { $xTick = $this->adjustNum(($this->xdata_diff / $numxGrid), $this->xdata_diff, $numxGrid,$xIntOnly); --- 751,754 ---- *************** *** 769,772 **** --- 758,778 ---- } // else set the tick + if ($max_label_width > $xTick * 2) { + $this->graph_height -= $max_label_width; + } // if + else { + $this->graph_height -= $max_label_width / 2; + } // else + + $yNum = $this->graph_height / $this->yAxisSpacing; + $numyGrid = round(min($numGrid, $yNum)); + + if (!$this->yTick) { + $yTick = $this->adjustNum(($this->ydata_diff / $numyGrid), $this->ydata_diff, $numyGrid); + } // if no body has set a y tick size + else { + $yTick = $this->yTick; + } // else set the tick + $xLabelYMod = $this->x_label_y_mod; *************** *** 861,866 **** $this->axis1Padding = max($this->axis1Padding,$strSize['width']); ! $this->DrawText($this->font,$x0 - $strSize['width'] - $this->xTickPadding,$y0 - ($strSize['height'] / 2),$gridy,"black",0); if ($axis2_ytick) { $axis2_gridy = ($gridCount - $yStart) * $axis2_ytick + $this->axis2['ymin']; --- 867,875 ---- $this->axis1Padding = max($this->axis1Padding,$strSize['width']); ! $label_top = $y0 - ($strSize['height'] / 2); ! $label_left = $x0 - $strSize['width'] - $this->xTickPadding; + $this->DrawText($this->font,$label_left,$label_top,$gridy,"black",0); + if ($axis2_ytick) { $axis2_gridy = ($gridCount - $yStart) * $axis2_ytick + $this->axis2['ymin']; *************** *** 912,916 **** $legend_text_size = $this->GetTextSize($legend_title,0); ! $legend_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $this->x_label_y_mod * 2 + $this->xTickPadding + $legend_text_size['height']; $this->DrawText($this->font,10,$legend_top,"Legend:","black",0); --- 921,925 ---- $legend_text_size = $this->GetTextSize($legend_title,0); ! $legend_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $legend_text_size['height']; $this->DrawText($this->font,10,$legend_top,"Legend:","black",0); *************** *** 1709,1713 **** $text_left = ($this->image_width / 2) - ($titleSize['width'] / 2); ! $text_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $this->x_label_y_mod * 2 + $this->xTickPadding + $titleSize['height']; $this->DrawText($this->font,$text_left,$text_top,$this->xTitle,"black",0); --- 1718,1722 ---- $text_left = ($this->image_width / 2) - ($titleSize['width'] / 2); ! $text_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $titleSize['height']; $this->DrawText($this->font,$text_left,$text_top,$this->xTitle,"black",0); |
From: Ariel G. <ag...@us...> - 2001-10-25 19:03:06
|
Update of /cvsroot/vagrant/vagrant In directory usw-pr-cvs1:/tmp/cvs-serv22317 Modified Files: VAGRANT.class Log Message: Legend was not correct when x axis text was made vertical Index: VAGRANT.class =================================================================== RCS file: /cvsroot/vagrant/vagrant/VAGRANT.class,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** VAGRANT.class 2001/10/25 18:47:13 1.30 --- VAGRANT.class 2001/10/25 19:03:03 1.31 *************** *** 843,847 **** } // for draw the vertical grid lines ! $this->max_x_label_height += $max_label_height; // Draw the horizontal grid lines --- 843,847 ---- } // for draw the vertical grid lines ! $this->max_x_label_height = $max_label_height; // Draw the horizontal grid lines *************** *** 909,917 **** function DrawLegend() { if (@sizeof($this->legend)) { - $legend_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $this->x_label_y_mod * 2; - $legend_title = "Legend:"; $legend_text_size = $this->GetTextSize($legend_title,0); $this->DrawText($this->font,10,$legend_top,"Legend:","black",0); $this->DrawLine(10,$legend_top + $legend_text_size['height'],47,$legend_top + $legend_text_size['height'],"black"); --- 909,917 ---- function DrawLegend() { if (@sizeof($this->legend)) { $legend_title = "Legend:"; $legend_text_size = $this->GetTextSize($legend_title,0); + $legend_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $this->x_label_y_mod * 2 + $this->xTickPadding + $legend_text_size['height']; + $this->DrawText($this->font,10,$legend_top,"Legend:","black",0); $this->DrawLine(10,$legend_top + $legend_text_size['height'],47,$legend_top + $legend_text_size['height'],"black"); *************** *** 1707,1713 **** function DrawxTitle() { $titleSize = $this->GetTextSize($this->xTitle,0); $text_left = ($this->image_width / 2) - ($titleSize['width'] / 2); ! $this->DrawText($this->font,$text_left,($this->graph_height + $this->ypad + $this->max_x_label_height + $this->x_label_y_mod * 2),$this->xTitle,"black",0); } // function DrawxTitle --- 1707,1715 ---- function DrawxTitle() { $titleSize = $this->GetTextSize($this->xTitle,0); + $text_left = ($this->image_width / 2) - ($titleSize['width'] / 2); + $text_top = $this->graph_height + $this->ypad + $this->max_x_label_height + $this->x_label_y_mod * 2 + $this->xTickPadding + $titleSize['height']; ! $this->DrawText($this->font,$text_left,$text_top,$this->xTitle,"black",0); } // function DrawxTitle |