Originally posted by Michael
View Post
Code:
diff -Naur phoronix-test-suite.orig/pts-core/objects/pts_Graph/pts_Graph.php phoronix-test-suite/pts-core/objects/pts_Graph/pts_Graph.php --- phoronix-test-suite.orig/pts-core/objects/pts_Graph/pts_Graph.php 2013-08-01 21:58:25.000000000 -0500 +++ phoronix-test-suite/pts-core/objects/pts_Graph/pts_Graph.php 2013-08-01 22:19:53.771812762 -0500 @@ -463,6 +463,27 @@ $this->render_graph_result(); $this->render_graph_post(); } + protected function get_special_paint_color($identifier) + { + // For now to try to improve the color handling of line graphs, first try to use a pre-defined pool of colors until falling back to the old color code once exhausted + // Thanks to ua=42 in the Phoronix Forums for the latest attempt at improving the automated color handling + static $line_color_cache = null; + static $predef_line_colors = array('#000000', '#FFB300', '#803E75', '#FF6800', '#A6BDD7', '#C10020', '#CEA262', '#817066', '#007D34', '#F6768E', '#00538A', '#FF7A5C', '#53377A', '#FF8E00', '#B32851', '#F4C800', '#7F180D', '#93AA00', '#593315', '#F13A13', '#232C16'); + + if(!isset($line_color_cache[$identifier])) + { + if(!empty($predef_line_colors)) + { + $line_color_cache[$identifier] = array_pop($predef_line_colors); + } + else + { + $line_color_cache[$identifier] = $this->get_paint_color($identifier); + } + } + + return $line_color_cache[$identifier]; + } protected function render_graph_pre_init() { return; @@ -719,7 +740,7 @@ { if(!empty($this->graph_data_title[$i])) { - $this_color = $this->get_paint_color($this->graph_data_title[$i]); + $this_color = $this->get_special_paint_color($this->graph_data_title[$i]); if($i != 0 && $i % $this->i['keys_per_line'] == 0) { diff -Naur phoronix-test-suite.orig/pts-core/objects/pts_Graph/pts_LineGraph.php phoronix-test-suite/pts-core/objects/pts_Graph/pts_LineGraph.php --- phoronix-test-suite.orig/pts-core/objects/pts_Graph/pts_LineGraph.php 2013-08-01 21:58:25.000000000 -0500 +++ phoronix-test-suite/pts-core/objects/pts_Graph/pts_LineGraph.php 2013-08-01 22:16:54.451820757 -0500 @@ -3,8 +3,8 @@ /* Phoronix Test Suite URLs: http://www.phoronix.com, http://www.phoronix-test-suite.com/ - Copyright (C) 2008 - 2012, Phoronix Media - Copyright (C) 2008 - 2012, Michael Larabel + Copyright (C) 2008 - 2013, Phoronix Media + Copyright (C) 2008 - 2013, Michael Larabel pts_LineGraph.php: The line graph object that extends pts_Graph.php. This program is free software; you can redistribute it and/or modify @@ -115,6 +115,27 @@ } } } + protected function get_special_paint_color($identifier) + { + // For now to try to improve the color handling of line graphs, first try to use a pre-defined pool of colors until falling back to the old color code once exhausted + // Thanks to ua=42 in the Phoronix Forums for the latest attempt at improving the automated color handling + static $line_color_cache = null; + static $predef_line_colors = array('#000000', '#FFB300', '#803E75', '#FF6800', '#A6BDD7', '#C10020', '#CEA262', '#817066', '#007D34', '#F6768E', '#00538A', '#FF7A5C', '#53377A', '#FF8E00', '#B32851', '#F4C800', '#7F180D', '#93AA00', '#593315', '#F13A13', '#232C16'); + + if(!isset($line_color_cache[$identifier])) + { + if(!empty($predef_line_colors)) + { + $line_color_cache[$identifier] = array_shift($predef_line_colors); + } + else + { + $line_color_cache[$identifier] = $this->get_paint_color($identifier); + } + } + + return $line_color_cache[$identifier]; + } protected function renderGraphLines() { $calculations_r = array(); @@ -124,7 +145,7 @@ foreach(array_keys($this->graph_data) as $i_o) { - $paint_color = $this->get_paint_color((isset($this->graph_data_title[$i_o]) ? $this->graph_data_title[$i_o] : null)); + $paint_color = $this->get_special_paint_color((isset($this->graph_data_title[$i_o]) ? $this->graph_data_title[$i_o] : null)); $calculations_r[$paint_color] = array(); $point_counter = count($this->graph_data[$i_o]);
Comment