public function __construct(&$result_object = null, &$result_file = null, $extra_attributes = null)
 {
     // Initalize Colors
     $this->i['identifier_size'] = self::$c['size']['identifiers'];
     // Copy this since it's commonly overwritten
     $this->i['graph_orientation'] = 'VERTICAL';
     $this->i['graph_value_type'] = 'NUMERICAL';
     $this->i['hide_graph_identifiers'] = false;
     $this->i['show_graph_key'] = false;
     $this->i['show_background_lines'] = false;
     $this->i['iveland_view'] = false;
     $this->i['graph_max_value_multiplier'] = 1.285;
     $this->i['graph_max_value'] = 0;
     $this->i['bottom_offset'] = 0;
     $this->i['hide_y_title'] = false;
     $this->i['compact_result_view'] = false;
     $this->i['key_line_height'] = 0;
     $this->i['graph_height'] = 0;
     $this->i['graph_width'] = 0;
     $this->i['left_start'] = 10;
     $this->i['left_end_right'] = 10;
     $this->i['top_start'] = 62;
     $this->i['top_end_bottom'] = 22;
     $this->i['mark_count'] = 6;
     // Number of marks to make on vertical axis
     $this->i['notes'] = array();
     // Reset of setup besides config
     if ($result_object != null) {
         $test_version = $result_object->test_profile->get_app_version();
         if (isset($test_version[2]) && is_numeric($test_version[0])) {
             $test_version = 'v' . $test_version;
         }
         $this->graph_title = trim($result_object->test_profile->get_title() . ' ' . $test_version);
         $this->graph_y_title = $result_object->test_profile->get_result_scale_formatted();
         $this->test_identifier = $result_object->test_profile->get_identifier();
         $this->i['graph_proportion'] = $result_object->test_profile->get_result_proportion();
         $this->addSubTitle($result_object->get_arguments_description());
     }
     $this->update_graph_dimensions(self::$c['graph']['width'], self::$c['graph']['height'], true);
     if (isset($extra_attributes['force_tracking_line_graph'])) {
         // Phoromatic result tracker
         $this->is_multi_way_comparison = true;
     } else {
         $this->is_multi_way_comparison = phx_graph_render::multi_way_identifier_check($result_object->test_result_buffer->get_identifiers());
     }
     $this->i['graph_version'] = 'Phoronix Test Suite ' . PTS_VERSION;
     if (isset($extra_attributes['regression_marker_threshold'])) {
         $this->d['regression_marker_threshold'] = $extra_attributes['regression_marker_threshold'];
     }
     if (isset($extra_attributes['set_alternate_view'])) {
         $this->d['link_alternate_view'] = $extra_attributes['set_alternate_view'];
     }
     if (isset($extra_attributes['highlight_graph_values'])) {
         $this->value_highlights = $extra_attributes['highlight_graph_values'];
     } else {
         if (PTS_IS_CLIENT && pts_client::read_env('GRAPH_HIGHLIGHT') != false) {
             $this->value_highlights = pts_strings::comma_explode(pts_client::read_env('GRAPH_HIGHLIGHT'));
         }
     }
     if (isset($extra_attributes['force_simple_keys'])) {
         $this->override_i_value('force_simple_keys', true);
     }
     $this->test_result =& $result_object;
     $this->generate_results_var();
 }
 public static function render_graph_process(&$result_object, &$result_file = null, $save_as = false, $extra_attributes = null)
 {
     if (isset($extra_attributes['sort_result_buffer'])) {
         $result_object->test_result_buffer->sort_buffer_items();
     }
     if (isset($extra_attributes['reverse_result_buffer'])) {
         $result_object->test_result_buffer->buffer_values_reverse();
     }
     if (isset($extra_attributes['normalize_result_buffer'])) {
         if (isset($extra_attributes['highlight_graph_values']) && is_array($extra_attributes['highlight_graph_values']) && count($extra_attributes['highlight_graph_values']) == 1) {
             $normalize_against = $extra_attributes['highlight_graph_values'][0];
         } else {
             $normalize_against = false;
         }
         $result_object->normalize_buffer_values($normalize_against);
     }
     if (isset($extra_attributes['sort_result_buffer_values'])) {
         $result_object->test_result_buffer->buffer_values_sort();
         if ($result_object->test_profile->get_result_proportion() == 'HIB') {
             $result_object->test_result_buffer->buffer_values_reverse();
         }
     }
     if ($result_file != null) {
         // Cache the redundant words on identifiers so it's not re-computed on every graph
         static $redundant_word_cache;
         if (!isset($redundant_word_cache[$result_file->get_title()])) {
             $redundant_word_cache[$result_file->get_title()] = pts_render::evaluate_redundant_identifier_words($result_file->get_system_identifiers());
         }
         if ($redundant_word_cache[$result_file->get_title()]) {
             $result_object->test_result_buffer->auto_shorten_buffer_identifiers($redundant_word_cache[$result_file->get_title()]);
         }
         // COMPACT PROCESS
         if (!isset($extra_attributes['compact_to_scalar']) && $result_object->test_profile->get_display_format() == 'LINE_GRAPH' && $result_file->get_system_count() > 10) {
             // If there's too many lines being plotted on line graph, likely to look messy, so convert to scalar automatically
             $extra_attributes['compact_to_scalar'] = true;
         }
         // XXX: removed || $result_file->is_results_tracker() from below and should be added
         // Removing the command fixes cases like: 1210053-BY-MYRESULTS43
         $result_identifiers = $result_object->test_result_buffer->get_identifiers();
         if ($result_file->is_multi_way_comparison($result_identifiers, $extra_attributes) || isset($extra_attributes['compact_to_scalar']) || isset($extra_attributes['compact_scatter'])) {
             if ((isset($extra_attributes['compact_to_scalar']) || false && $result_file->is_multi_way_comparison($result_identifiers, $extra_attributes)) && in_array($result_object->test_profile->get_display_format(), array('LINE_GRAPH', 'FILLED_LINE_GRAPH'))) {
                 // Convert multi-way line graph into horizontal box plot
                 if (true) {
                     $result_object->test_profile->set_display_format('HORIZONTAL_BOX_PLOT');
                 }
                 /*	else // XXX commented out during PTS 6.0 development, TODO decide if to delete
                 					{
                 						// Turn a multi-way line graph into an averaged bar graph
                 						$buffer_items = $result_object->test_result_buffer->get_buffer_items();
                 						$result_object->test_result_buffer = new pts_test_result_buffer();
                 
                 						foreach($buffer_items as $buffer_item)
                 						{
                 							$values = pts_strings::comma_explode($buffer_item->get_result_value());
                 							$avg_value = pts_math::set_precision(array_sum($values) / count($values), 2);
                 							$j = null;
                 							if(count($values) > 2)
                 							{
                 								$j['min-result'] = min($values);
                 								$j['max-result'] = max($values);
                 
                 								if($j['min-result'] == $j['max-result'])
                 								{
                 									$json = null;
                 								}
                 							}
                 
                 							$result_object->test_result_buffer->add_test_result($buffer_item->get_result_identifier(), $avg_value, null, $j, $j['min-result'], $j['max-result']);
                 						}
                 
                 						$result_object->test_profile->set_display_format('BAR_GRAPH');
                 					} */
             }
             if ($result_object->test_profile->get_display_format() != 'PIE_CHART' && (phx_graph_render::multi_way_identifier_check($result_object->test_result_buffer->get_identifiers()) || isset($extra_attributes['force_tracking_line_graph']) && $extra_attributes['force_tracking_line_graph'])) {
                 //$result_table = false;
                 //pts_render::compact_result_file_test_object($result_object, $result_table, $result_file, $extra_attributes);
                 if ($result_object->test_profile->get_display_format() == 'LINE_GRAPH' || isset($extra_attributes['force_tracking_line_graph']) && $extra_attributes['force_tracking_line_graph']) {
                     $result_object->test_profile->set_display_format('LINE_GRAPH');
                 }
             }
         } else {
             if (in_array($result_object->test_profile->get_display_format(), array('LINE_GRAPH'))) {
                 // Check to see for line graphs if every result is an array of the same result (i.e. a flat line for every result).
                 // If all the results are just flat lines, you might as well convert it to a bar graph
                 $buffer_items = $result_object->test_result_buffer->get_buffer_items();
                 $all_values_are_flat = false;
                 $flat_values = array();
                 foreach ($buffer_items as $i => $buffer_item) {
                     $unique_in_buffer = array_unique(explode(',', $buffer_item->get_result_value()));
                     $all_values_are_flat = count($unique_in_buffer) == 1;
                     if ($all_values_are_flat == false) {
                         break;
                     }
                     $flat_values[$i] = array_pop($unique_in_buffer);
                 }
                 if ($all_values_are_flat) {
                     $result_object->test_result_buffer = new pts_test_result_buffer();
                     foreach ($buffer_items as $i => $buffer_item) {
                         $result_object->test_result_buffer->add_test_result($buffer_item->get_result_identifier(), $flat_values[$i]);
                     }
                     $result_object->test_profile->set_display_format('BAR_GRAPH');
                 }
             }
         }
     }
     if (isset($extra_attributes['graph_render_type'])) {
         $result_object->test_profile->set_display_format($extra_attributes['graph_render_type']);
     }
     $display_format = $result_object->test_profile->get_display_format();
     switch ($display_format) {
         case 'LINE_GRAPH':
             $graph = new phx_graph_lines($result_object, $result_file, $extra_attributes);
             break;
         case 'HORIZONTAL_BOX_PLOT':
             $graph = new phx_graph_box_plot($result_object, $result_file, $extra_attributes);
             break;
         case 'BAR_ANALYZE_GRAPH':
         case 'BAR_GRAPH':
             $graph = new phx_graph_horizontal_bars($result_object, $result_file);
             break;
         case 'PASS_FAIL':
             $graph = new pts_PassFailGraph($result_object, $result_file);
             break;
         case 'MULTI_PASS_FAIL':
             $graph = new pts_MultiPassFailGraph($result_object, $result_file);
             break;
         case 'TEST_COUNT_PASS':
             $graph = new pts_TestCountPassGraph($result_object, $result_file);
             break;
         case 'PIE_CHART':
             $graph = new pts_PieChart($result_object, $result_file);
             break;
         case 'IMAGE_COMPARISON':
             $graph = new pts_ImageComparisonGraph($result_object, $result_file);
             break;
         case 'SCATTER_PLOT':
             $graph = new pts_ScatterPlot($result_object, $result_file);
             break;
         default:
             switch ($requested_graph_type) {
                 case 'LINE_GRAPH':
                     $graph = new phx_graph_lines($result_object, $result_file, $extra_attributes);
                     break;
                 case 'HORIZONTAL_BOX_PLOT':
                     $graph = new phx_graph_box_plot($result_object, $result_file, $extra_attributes);
                     break;
                 default:
                     $graph = new phx_graph_horizontal_bars($result_object, $result_file, $extra_attributes);
                     break;
             }
             break;
     }
     self::report_test_notes_to_graph($graph, $result_object);
     return $graph;
 }