diff options
author | Michael Larabel <michael@phx-laptop.(none)> | 2008-11-29 14:35:48 -0500 |
---|---|---|
committer | Michael Larabel <michael@phx-laptop.(none)> | 2008-11-29 14:35:48 -0500 |
commit | b87a1c03035e16e2c8477a563da2a743ed12d689 (patch) | |
tree | 3058ddd7ae31966a1bba9c696d16d3c7ba728b55 /pts-core/objects/pts_Graph | |
parent | b3e534b27443892d9f73401003b2f1ea57051a77 (diff) | |
download | phoronix-test-suite-upstream-b87a1c03035e16e2c8477a563da2a743ed12d689.tar.gz phoronix-test-suite-upstream-b87a1c03035e16e2c8477a563da2a743ed12d689.tar.xz phoronix-test-suite-upstream-b87a1c03035e16e2c8477a563da2a743ed12d689.zip |
pts_CandleStickGraph: A new graph type that displays results from all
test runs and is modeled after Japanese Candlestick charting
Diffstat (limited to 'pts-core/objects/pts_Graph')
-rw-r--r-- | pts-core/objects/pts_Graph/pts_CandleStickGraph.php | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/pts-core/objects/pts_Graph/pts_CandleStickGraph.php b/pts-core/objects/pts_Graph/pts_CandleStickGraph.php new file mode 100644 index 0000000..2449f8d --- /dev/null +++ b/pts-core/objects/pts_Graph/pts_CandleStickGraph.php @@ -0,0 +1,93 @@ +<?php + +/* + Phoronix Test Suite + URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/ + Copyright (C) 2008, Phoronix Media + Copyright (C) 2008, Michael Larabel + pts_BarGraph.php: The bar graph object that extends pts_Graph.php. + + 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 3 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, see <http://www.gnu.org/licenses/>. +*/ + +class pts_CandleStickGraph extends pts_BarGraph +{ + public function __construct($title, $sub_title, $y_axis_title) + { + parent::__construct($title, $sub_title, $y_axis_title); + $this->graph_type = "CANDLE_STICK_GRAPH"; + } + protected function render_graph_candle_sticks() + { + $bar_count = count($this->graph_data_raw); + $bar_width = floor($this->identifier_width / $bar_count) - ($bar_count * 16); + + for($i_o = 0; $i_o < $bar_count; $i_o++) + { + $paint_color = $this->next_paint_color(); + + for($i = 0; $i < count($this->graph_data_raw[$i_o]); $i++) + { + $run_values_r = explode(":", $this->graph_data_raw[$i_o][$i]); + + $start_value = $run_values_r[0]; + $end_value = $run_values_r[(count($run_values_r) - 1)]; + $average_value = array_sum($run_values_r) / count($run_values_r); + sort($run_values_r); + $low_value = $run_values_r[0]; + $high_value = $run_values_r[(count($run_values_r) - 1)]; + + $px_bound_left = $this->graph_left_start + ($this->identifier_width * $i) + ($bar_width * $i_o) + 8; + $px_bound_center = $px_bound_left + round($bar_width / 2); + $px_bound_right = $px_bound_left + $bar_width; + + $top_diff = $this->graph_top_end - $this->graph_top_start; + $plot_wick_lowest = $this->graph_top_end + 1 - round(($low_value / $this->graph_maximum_value) * $top_diff); + $plot_wick_highest = $this->graph_top_end + 1 - round(($high_value / $this->graph_maximum_value) * $top_diff); + $plot_body_start = $this->graph_top_end + 1 - round(($start_value / $this->graph_maximum_value) * $top_diff); + $plot_body_end = $this->graph_top_end + 1 - round(($end_value / $this->graph_maximum_value) * $top_diff); + + if($start_value > $end_value) + { + $body_color = $this->graph_color_body; + $plot_body_high = $plot_body_start; + $plot_body_low = $plot_body_end; + } + else + { + $body_color = $paint_color; + $plot_body_low = $plot_body_start; + $plot_body_high = $plot_body_end; + } + + $this->graph_image->draw_line($px_bound_center, $plot_wick_lowest, $px_bound_center, $plot_wick_highest, $this->graph_color_body_light, 1); + $this->graph_image->draw_rectangle_border($px_bound_left, $plot_body_low, $px_bound_right, $plot_body_high, $this->graph_color_body_light); + $this->graph_image->draw_rectangle($px_bound_left + 1, $plot_body_low - 1, $px_bound_right - 1, $plot_body_high + 1, $body_color); + } + } + } + protected function render_graph_result() + { + if(count($this->graph_data_raw) == 0 || empty($this->graph_data_raw[0])) + { + $this->render_graph_bars(); + } + else + { + $this->render_graph_candle_sticks(); + } + } +} + +?> |