How to use shift_color method of pts_graph_core class

Best Phoronix-test-suite code snippet using pts_graph_core.shift_color

pts_graph_core.php

Source:pts_graph_core.php Github

copy

Full Screen

...261 /* foreach(array(0.8, 0.4) as $p)262 {263 foreach(array(0, 220) as $o)264 {265 self::$c['color']['seeded_paint'][] = self::shift_color($color, $p, $o);266 }267 } */268 }269 //shuffle(self::$c['color']['seeded_paint']);270 }271 public static function set_default_graph_values(&$config)272 {273 // Setup config values274 $config['graph']['width'] = 600;275 $config['graph']['height'] = 310;276 $config['graph']['border'] = false;277 // Colors278 $config['color']['notches'] = '#757575';279 $config['color']['text'] = '#065695';280 $config['color']['border'] = '#757575';281 $config['color']['main_headers'] = '#231f20';282 $config['color']['headers'] = '#231f20';283 $config['color']['background'] = '#FEFEFE';284 $config['color']['body'] = '#BABABA';285 $config['color']['body_text'] = '#FFFFFF';286 $config['color']['body_light'] = '#949494';287 $config['color']['highlight'] = '#005a00';288 $config['color']['alert'] = '#C80000';289 $config['color']['paint'] = array('#2196f3', '#f44336', '#673ab7', '#009688', '#4caf50', '#e91e63', '#795548', '#9e9e9e', '#607d8b', '#FFB300', '#803E75', '#FF6800', '#A6BDD7', '#C10020', '#CEA262', '#817066', '#007D34', '#01579b', '#F6768E', '#ff5722', '#00538A', '#FF7A5C', '#53377A', '#FF8E00', '#B32851', '#F4C800', '#7F180D', '#93AA00', '#593315', '#F13A13', '#232C16');290 // Text291 $config['size']['tick_mark'] = 10;292 $config['size']['key'] = 9;293 if(defined('OPENBENCHMARKING_BUILD'))294 {295 $config['text']['watermark'] = 'OpenBenchmarking.org';296 if(defined('OPENBENCHMARKING_WATERMARK_URL'))297 {298 $config['text']['watermark_url'] = OPENBENCHMARKING_WATERMARK_URL;299 }300 else301 {302 $config['text']['watermark_url'] = 'https://www.openbenchmarking.org/';303 }304 }305 else306 {307 $config['text']['watermark'] = 'Phoronix Test Suite ' . PTS_VERSION;308 $config['text']['watermark_url'] = 'https://www.phoronix-test-suite.com/';309 }310 $config['size']['headers'] = 17;311 $config['size']['bars'] = 11;312 $config['size']['identifiers'] = 10;313 $config['size']['sub_headers'] = 11;314 $config['size']['axis_headers'] = 10;315 $config['style']['allow_box_plots'] = true;316 $config['style']['bar_graphs_horizontal'] = true;317 }318 //319 // Load Functions320 //321 public function addGraphIdentifierNote($identifier, $note)322 {323 if(!isset($this->d['identifier_notes'][$identifier]) || empty($this->d['identifier_notes'][$identifier]))324 {325 $this->d['identifier_notes'][$identifier] = $note;326 }327 else328 {329 $this->d['identifier_notes'][$identifier] .= ' - ' . $note;330 }331 }332 public function addSubTitle($sub_title)333 {334 $sub_titles = array_map('trim', explode('|', $sub_title));335 foreach($sub_titles as $sub_title)336 {337 if(!empty($sub_title))338 {339 $this->graph_sub_titles[] = $sub_title;340 }341 }342 }343 public function addTestNote($note, $hover_title = null, $section = null)344 {345 $this->i['notes'][] = array('note' => $note, 'hover-title' => $hover_title, 'section' => $section);346 }347 //348 // Misc Functions349 //350 protected function get_paint_color($identifier, $check_branding = false)351 {352 // 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 exhausted353 if(!isset(self::$color_cache[$check_branding][$identifier]))354 {355 if(!empty(self::$c['color']['seeded_paint']))356 {357 self::$color_cache[$check_branding][$identifier] = array_shift(self::$c['color']['seeded_paint']);358 }359 else360 {361 self::$color_cache[$check_branding][$identifier] = sprintf('#%06X', mt_rand(0, 0xFFFFFF));362 }363 if($check_branding)364 {365 self::$color_cache[$check_branding][$identifier] = self::identifier_to_branded_color($identifier, self::$color_cache[$check_branding][$identifier]);366 }367 }368 return self::$color_cache[$check_branding][$identifier];369 }370 protected function maximum_graph_value($v = -1)371 {372 $real_maximum = 0;373 $data_max = $v == -1 ? $this->test_result->test_result_buffer->get_max_value() : $v;374 $max_precision = pts_math::get_precision($data_max);375 if(!is_numeric($data_max))376 {377 if(is_array($data_max))378 {379 $data_max = max($data_max);380 }381 if(is_array($data_max))382 {383 $data_max = max($data_max);384 }385 if(!is_numeric($data_max))386 {387 $data_max = str_repeat(9, strlen($data_max));388 }389 }390 if($data_max > $real_maximum)391 {392 $real_maximum = $data_max;393 }394 if(is_numeric($real_maximum))395 {396 if($real_maximum < $this->i['mark_count'])397 {398 $maximum = (($real_maximum * 1.35 / $this->i['mark_count']) * $this->i['mark_count']);399 if($maximum > 1)400 {401 pts_math::set_precision($maximum, $max_precision);402 }403 }404 else405 {406 $maximum = (floor(round($real_maximum * $this->i['graph_max_value_multiplier']) / $this->i['mark_count']) + 1) * $this->i['mark_count'];407 $maximum = round(ceil($maximum / $this->i['mark_count']), (0 - strlen($maximum) + 2)) * $this->i['mark_count'];408 $maximum = pts_math::set_precision($maximum, $max_precision);409 }410 }411 else412 {413 $maximum = 0;414 }415 return $maximum;416 }417 protected function text_size_bounds($string, $font_size, $minimum_font_size, $bound_width, $bound_height = -1)418 {419 list($string_width, $string_height) = pts_svg_dom::estimate_text_dimensions($string, $font_size);420 while($font_size > $minimum_font_size && $string_width > $bound_width || ($bound_height > 0 && $string_height > $bound_height))421 {422 $font_size -= 0.3;423 list($string_width, $string_height) = pts_svg_dom::estimate_text_dimensions($string, $font_size);424 }425 return $font_size;426 }427 protected function update_graph_dimensions($width = -1, $height = -1, $recalculate_offsets = false)428 {429 // Allow render area to be increased, but not decreased430 $this->i['graph_width'] = max($this->i['graph_width'], $width);431 $this->i['graph_height'] = max($this->i['graph_height'], $height);432 if($recalculate_offsets)433 {434 $this->i['graph_top_end'] = $this->i['graph_height'] - $this->i['top_end_bottom'];435 $this->i['graph_left_end'] = $this->i['graph_width'] - $this->i['left_end_right'];436 }437 }438 protected function identifier_to_branded_color($identifier, $fallback_color = null)439 {440 if($this->i['support_color_branding'] == false || !isset($identifier[5]))441 {442 return $fallback_color;443 }444 $paint_color = pts_render::identifier_to_brand_color($identifier, $fallback_color);445 if($paint_color != $fallback_color && strpos($identifier, ' - '))446 {447 // If there is " - " in string, darken the color... based upon idea when doing AMDGPU vs. Mesa vs. stock NVIDIA comparison for RX 480448 $paint_color = self::shift_color($paint_color);449 }450 return $paint_color;451 }452 //453 // Render Functions454 //455 public static function shift_color($paint_color, $percent = 0.7, $mask = 0)456 {457 $new_color = null;458 foreach(str_split(str_replace('#', null, $paint_color), 2) as $color)459 {460 $dec = hexdec($color);461 $dec = min(max(0, round($dec * $percent) + round($mask * (1 - $percent))), 255);462 $new_color .= str_pad(dechex($dec), 2, 0, STR_PAD_LEFT);463 }464 return '#' . substr($new_color, 0, 6);465 }466 public function renderGraph()467 {468 $this->render_graph_start();469 $this->render_graph_finish();470 }471 public function render_graph_start()472 {473 $this->render_graph_dimensions();474 $this->render_graph_pre_init();475 $this->render_graph_init();476 }477 public function render_graph_dimensions()478 {479 $this->i['graph_max_value'] = $this->maximum_graph_value();480 $longest_identifier = $this->test_result->test_result_buffer->get_longest_identifier();481 $se_width = self::text_string_width('SE +/- 0.04, N = 3', $this->i['identifier_size'] - 1);482 // Make room for tick markings, left hand side483 if($this->i['iveland_view'] == false)484 {485 if($this->i['graph_value_type'] == 'NUMERICAL')486 {487 $this->i['left_start'] += self::text_string_width($this->i['graph_max_value'], self::$c['size']['tick_mark']) + 2;488 }489 if($this->i['hide_graph_identifiers'])490 {491 $this->i['graph_top_end'] += $this->i['top_end_bottom'] / 2;492 }493 $this->i['top_start'] += $this->graph_key_height();494 }495 else496 {497 if($this->i['graph_orientation'] == 'HORIZONTAL')498 {499 if($this->i['is_multi_way_comparison'] && count($this->results) > 1)500 {501 $longest_r = $longest_identifier;502 $longest_r = explode(' - ', $longest_r);503 $plus_extra = 0;504 if(count($longest_r) > 1)505 {506 $plus_extra += floor(count($longest_r) * $this->i['identifier_size'] * 1.2);507 }508 $longest_identifier_width = self::text_string_width($this->i['graph_max_value'], $this->i['identifier_size']) + 64 + $plus_extra;509 }510 else511 {512 $longest_identifier_width = max($se_width, ceil(self::text_string_width($longest_identifier, $this->i['identifier_size']) * 1.09) + 24);513 }514 $longest_identifier_max = ceil(($this->i['graph_width'] * 0.55) + 0.01);515 $this->i['left_start'] = min($longest_identifier_max, max($longest_identifier_width, 70));516 $this->i['left_end_right'] = 15;517 $this->i['graph_left_end'] = $this->i['graph_width'] - $this->i['left_end_right'];518 }519 else if($this->i['graph_value_type'] == 'NUMERICAL')520 {521 $this->i['left_start'] += max(20, self::text_string_width($this->i['graph_max_value'], self::$c['size']['tick_mark']) + 3);522 }523 // Pad 8px on top and bottom + title bar + sub-headings524 $this->i['top_heading_height'] = 16 + self::$c['size']['headers'] + (count($this->graph_sub_titles) * (self::$c['size']['sub_headers'] + 4));525 if($this->i['iveland_view'])526 {527 // Ensure there is enough room to print PTS logo528 $this->i['top_heading_height'] = max($this->i['top_heading_height'], 46);529 }530 $key_height = $this->graph_key_height();531 if($key_height > $this->i['key_line_height'])532 {533 // Increase height so key doesn't take up too much room534 $this->i['graph_height'] += $key_height;535 $this->i['graph_top_end'] += $key_height;536 }537 $this->i['top_start'] = $this->i['top_heading_height'] + $key_height + 16; // + spacing before graph starts538 if($this->i['skip_headers'])539 {540 $this->i['top_heading_height'] = 0;541 $this->i['top_start'] = 5;542 }543 $bottom_heading = $this->i['skip_headers'] ? 0 : 14;544 if($this->i['graph_orientation'] == 'HORIZONTAL')545 {546 if($this->i['is_multi_way_comparison'] && count($this->results) > 1)547 {548 $longest_string = explode(' - ', $longest_identifier);549 $longest_string = pts_strings::find_longest_string($longest_string);550 $per_identifier_height = 22; // default551 if($this->test_result->test_result_buffer->get_count() > 9)552 {553 $per_identifier_height = 20; // default554 $this->i['identifier_size'] = floor($this->i['identifier_size'] * 0.88);555 }556 $rotated_text = round(self::text_string_width($longest_string, $this->i['identifier_size']) * 1.02);557 if(ceil($rotated_text * 1.2) >= floor($per_identifier_height * count($this->results)))558 {559 // this is to avoid having a rotated text bar overrun other results560 $per_identifier_height = max(($per_identifier_height + 2), ceil($rotated_text / count($this->results)));561 }562 }563 else if(count($this->results) > 3)564 {565 $per_identifier_height = count($this->results) * 18;566 }567 else568 {569 // If there's too much to plot, reduce the size so each graph doesn't take too much room570 $id_count = count(pts_arrays::first_element($this->results));571 if($id_count < 10)572 {573 $per_identifier_height = 46;574 }575 else if($id_count < 20)576 {577 $per_identifier_height = 36;578 }579 else580 {581 $this->i['compact_result_view'] = true;582 $per_identifier_height = 28;583 }584 }585 $num_identifiers = $this->test_result->test_result_buffer->get_count() + ($this->i['is_multi_way_comparison'] ? 2 : 0);586 $this->i['graph_top_end'] = $this->i['top_start'] + ($num_identifiers * $per_identifier_height);587 // $this->i['top_end_bottom']588 $this->i['graph_height'] = $this->i['graph_top_end'] + ($this->i['skip_headers'] ? 0 : 25) + $bottom_heading;589 }590 else591 {592 $this->i['graph_height'] += $bottom_heading + 4;593 }594 if(!empty($this->i['notes']))595 {596 $this->i['graph_height'] += $this->note_display_height();597 }598 }599 }600 public function render_graph_finish()601 {602 $this->render_graph_key();603 $this->render_graph_base($this->i['left_start'], $this->i['top_start'], $this->i['graph_left_end'], $this->i['graph_top_end']);604 $this->render_graph_heading();605 if($this->i['hide_graph_identifiers'] == false)606 {607 $this->render_graph_identifiers();608 }609 if($this->i['graph_value_type'] == 'NUMERICAL')610 {611 $this->render_graph_value_ticks($this->i['left_start'], $this->i['top_start'], $this->i['graph_left_end'], $this->i['graph_top_end']);612 }613 $this->render_graph_result();614 $this->render_graph_post();615 }616 protected function render_graph_pre_init()617 {618 return;619 }620 protected function render_graph_init()621 {622 $this->update_graph_dimensions();623 $this->svg_dom = new pts_svg_dom(ceil($this->i['graph_width']), ceil($this->i['graph_height']));624 // Background Color625 if(self::$c['graph']['border'])626 {627 $this->svg_dom->add_element('rect', array('x' => 0, 'y' => 0, 'width' => $this->i['graph_width'], 'height' => $this->i['graph_height'], 'fill' => self::$c['color']['background'], 'stroke' => self::$c['color']['border'], 'stroke-width' => 2));628 }629 else630 {631 $this->svg_dom->add_element('rect', array('x' => 0, 'y' => 0, 'width' => $this->i['graph_width'], 'height' => $this->i['graph_height'], 'fill' => self::$c['color']['background']));632 }633 if($this->i['iveland_view'] == false && ($sub_title_count = count($this->graph_sub_titles)) > 1)634 {635 $this->i['top_start'] += (($sub_title_count - 1) * (self::$c['size']['sub_headers'] + 4));636 }637 }638 protected function render_graph_heading($with_version = true)639 {640 if($this->i['skip_headers'])641 {642 return;643 }644 // Default to NORMAL645 if($this->i['iveland_view'])646 {647 //$this->svg_dom->add_element('rect', array('x' => 0, 'y' => 0, 'width' => $this->i['graph_width'], 'height' => $this->i['top_heading_height'], 'fill' => self::$c['color']['main_headers']));648 if(isset($this->i['graph_title'][36]))649 {650 // If it's a long string make sure it won't run over the side...651 while(self::text_string_width($this->i['graph_title'], self::$c['size']['headers']) > ($this->i['graph_left_end'] - 20))652 {653 self::$c['size']['headers'] -= 0.5;654 }655 }656 $this->svg_dom->add_text_element($this->i['graph_title'], array('x' => 6, 'y' => (self::$c['size']['headers'] + 2), 'font-size' => self::$c['size']['headers'], 'fill' => self::$c['color']['main_headers'], 'text-anchor' => 'start', 'xlink:href' => $this->i['header_link'], 'font-weight' => 'bold'));657 foreach($this->graph_sub_titles as $i => $sub_title)658 {659 $vertical_offset = 12 + self::$c['size']['headers'] + (($i + 1) * (self::$c['size']['sub_headers'] - 4));660 $sub_title_size = self::$c['size']['sub_headers'];661 if(isset($sub_title[69]))662 {663 while(self::text_string_width($sub_title, $sub_title_size) > ($this->i['graph_left_end'] - 20))664 $sub_title_size -= 0.5;665 }666 $this->svg_dom->add_text_element($sub_title, array('x' => 6, 'y' => $vertical_offset, 'font-size' => $sub_title_size, 'font-weight' => 'bold', 'fill' => self::$c['color']['main_headers'], 'text-anchor' => 'start'));667 }668 // SVG version of PTS thanks to https://gist.github.com/xorgy/65c6d0e87757dbb56a75669 if($this->i['graph_version'])670 {671 $this->svg_dom->add_element('path', array('d' => 'm74 22v9m-5-16v16m-5-28v28m-23-2h12.5c2.485281 0 4.5-2.014719 4.5-4.5s-2.014719-4.5-4.5-4.5h-8c-2.485281 0-4.5-2.014719-4.5-4.5s2.014719-4.5 4.5-4.5h12.5m-21 5h-11m11 13h-2c-4.970563 0-9-4.029437-9-9v-20m-24 40v-20c0-4.970563 4.0294373-9 9-9 4.970563 0 9 4.029437 9 9s-4.029437 9-9 9h-9', 'stroke' => self::$c['color']['main_headers'], 'stroke-width' => 4, 'fill' => 'none', 'xlink:href' => 'https://www.phoronix-test-suite.com/', 'transform' => 'translate(' . ceil($this->i['graph_left_end'] - 77) . ',' . (ceil($this->i['top_heading_height'] / 40 + 2)) . ')'));672 }673 }674 else675 {676 $this->svg_dom->add_text_element($this->i['graph_title'], array('x' => round($this->i['graph_left_end'] / 2), 'y' => (self::$c['size']['headers'] + 2), 'font-size' => self::$c['size']['headers'], 'fill' => self::$c['color']['main_headers'], 'text-anchor' => 'middle', 'xlink:href' => $this->i['header_link']));677 foreach($this->graph_sub_titles as $i => $sub_title)678 {679 $this->svg_dom->add_text_element($sub_title, array('x' => round($this->i['graph_left_end'] / 2), 'y' => (31 + (($i + 1) * 18)), 'font-size' => self::$c['size']['sub_headers'], 'fill' => self::$c['color']['main_headers'], 'text-anchor' => 'middle'));680 }681 if($with_version && !empty($this->i['graph_version']))682 {683 $this->svg_dom->add_text_element($this->i['graph_version'], array('x' => $this->i['graph_left_end'] , 'y' => ($this->i['top_start'] - 3), 'font-size' => 7, 'fill' => self::$c['color']['body_light'], 'text-anchor' => 'end', 'xlink:href' => 'https://www.phoronix-test-suite.com/'));684 }685 }686 }687 protected function render_graph_post()688 {689 if($this->i['skip_headers'])690 {691 return;692 }693 if($this->i['iveland_view'])694 {695 $bottom_heading_start = $this->i['graph_top_end'] + $this->i['bottom_offset'] + 22;696 //$this->svg_dom->add_element('rect', array('x' => 0, 'y' => $bottom_heading_start, 'width' => $this->i['graph_width'], 'height' => ($this->i['graph_height'] - $bottom_heading_start), 'fill' => self::$c['color']['main_headers']));697 //$this->svg_dom->add_text_element($this->i['graph_version'], array('x' => $this->i['graph_left_end'], 'y' => ($bottom_heading_start + self::$c['size']['key'] + 3), 'font-size' => self::$c['size']['key'], 'fill' => self::$c['color']['main_headers'], 'text-anchor' => 'end', 'font-weight' => 'bold', 'xlink:href' => 'https://www.phoronix-test-suite.com/'));698 if(!empty($this->i['notes']))699 {700 $estimated_height = 0;701 foreach($this->i['notes'] as $i => $note_r)702 {703 $this->svg_dom->add_textarea_element(($i + 1) . '. ' . $note_r['note'], array('x' => 5, 'y' => ($bottom_heading_start + (self::$c['size']['key'] * 2) + $estimated_height), 'font-size' => (self::$c['size']['key'] - 1), 'fill' => self::$c['color']['main_headers'], 'text-anchor' => 'start'), $estimated_height);704 }705 }706 }707 }708 protected function render_graph_base($left_start, $top_start, $left_end, $top_end)709 {710 if($this->i['graph_orientation'] == 'HORIZONTAL' || $this->i['iveland_view'])711 {712 $g = $this->svg_dom->make_g(array('stroke' => self::$c['color']['notches'], 'stroke-width' => 1));713 $this->svg_dom->add_element('line', array('x1' => $left_start, 'y1' => $top_start, 'x2' => $left_start, 'y2' => ($top_end + 1)), $g);714 $this->svg_dom->add_element('line', array('x1' => $left_start, 'y1' => $top_end, 'x2' => ($left_end + 1), 'y2' => $top_end), $g);715 if($this->i['watermark'] && isset($this->d['link_alternate_view']) && $this->d['link_alternate_view'])716 {717 // add SVG version: https://gist.github.com/xorgy/169a65e29a3c2cc41e7f718 $a = $this->svg_dom->make_a($this->d['link_alternate_view']);719 $g = $this->svg_dom->make_g(array('transform' => 'translate(' . ($left_end - 10) . ',' . ($top_start - 5 - 10) . ')', 'width' => 10, 'height' => 16), $a);720 $this->svg_dom->add_element('path', array('d' => 'M5 0v6.5L0 11l3-3-3-3.5L5 0', 'fill' => '#038bb8'), $g);721 $this->svg_dom->add_element('path', array('d' => 'M5 0v6.5l5 4.5-3-3 3-3.5L5 0', 'fill' => '#25b3e8'), $g);722 $this->svg_dom->add_element('path', array('d' => 'M5 16V9l5-4.5V11l-5 5', 'fill' => '#e4f4fd'), $g);723 $this->svg_dom->add_element('path', array('d' => 'M5 16V9L0 4.5V11l5 5', 'fill' => '#65cbf4'), $g);724 $this->svg_dom->add_text_element($this->i['watermark'], array('x' => $left_end - 12, 'y' => ($top_start - 5), 'font-size' => 8, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end', 'font-weight' => 'bold', 'xlink:href' => self::$c['text']['watermark_url']));725 }726 else if(!empty($this->i['watermark']))727 {728 $this->svg_dom->add_text_element($this->i['watermark'], array('x' => $left_end, 'y' => ($top_start - 5), 'font-size' => 8, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end', 'font-weight' => 'bold', 'xlink:href' => self::$c['text']['watermark_url']));729 }730 }731 else732 {733 $this->svg_dom->add_element('rect', array('x' => $left_start, 'y' => $top_start, 'width' => ($left_end - $left_start), 'height' => ($top_end - $top_start), 'fill' => self::$c['color']['body'], 'stroke' => self::$c['color']['notches'], 'stroke-width' => 1));734 if($this->i['watermark'] != null)735 {736 $this->svg_dom->add_text_element($this->i['watermark'], array('x' => ($left_end - 2), 'y' => ($top_start + 12), 'font-size' => 10, 'fill' => self::$c['color']['text'], 'text-anchor' => 'end', 'font-weight' => 'bold', 'xlink:href' => self::$c['text']['watermark_url']));737 }738 }739 if(!empty($this->i['graph_y_title']) && $this->i['hide_y_title'] == false)740 {741 $str = $this->i['graph_y_title'];742 $offset = 0;743 if($this->i['graph_proportion'] != null)744 {745 $proportion = null;746 switch($this->i['graph_proportion'])747 {748 case 'LIB':749 $proportion = 'Fewer Is Better';750 $offset += 12;751 if($this->i['graph_orientation'] == 'HORIZONTAL')752 {753 $this->draw_arrow($left_start, $top_start - 8, $left_start + 9, $top_start - 8, self::$c['color']['text'], self::$c['color']['body_light'], 1);754 }755 else756 {757 $this->draw_arrow($left_start + 4, $top_start - 4, $left_start + 4, $top_start - 11, self::$c['color']['text'], self::$c['color']['body_light'], 1);758 }759 break;760 case 'HIB':761 $proportion = 'More Is Better';762 $offset += 12;763 if($this->i['graph_orientation'] == 'HORIZONTAL')764 {765 $this->draw_arrow($left_start + 9, $top_start - 8, $left_start, $top_start - 8, self::$c['color']['text'], self::$c['color']['body_light'], 1);766 }767 else768 {769 $this->draw_arrow($left_start + 4, $top_start - 11, $left_start + 4, $top_start - 4, self::$c['color']['text'], self::$c['color']['body_light'], 1);770 }771 break;772 }773 if($proportion)774 {775 if($str)776 {777 $str .= ', ';778 }779 $str .= $proportion;780 }781 }782 $this->svg_dom->add_text_element($str, array('x' => ($left_start + $offset), 'y' => ($top_start - 5), 'font-size' => 8, 'font-weight' => 'bold', 'fill' => self::$c['color']['text'], 'text-anchor' => 'start'));783 }784 }785 protected function render_graph_value_ticks($left_start, $top_start, $left_end, $top_end, $show_numbers = true)786 {787 $increment = round(($this->i['graph_max_value'] - $this->i['graph_min_value']) / $this->i['mark_count'], $this->i['graph_max_value'] < 10 ? 4 : 2);788 $dv_divide = 1;789 $dv_postfix = null;790 if($increment > 1000000 && ($increment % 1000) == 0)791 {792 $dv_divide = 1000000;793 $dv_postfix = 'M';794 }795 else if($increment > 1000 && ($increment % 1000) == 0)796 {797 $dv_divide = 1000;798 $dv_postfix = 'K';799 }800 if($this->i['graph_orientation'] == 'HORIZONTAL')801 {802 $tick_width = round(($left_end - $left_start) / $this->i['mark_count']);803 $display_value = $this->i['graph_min_value'];804 $tick_font_size = self::$c['size']['tick_mark'];805 while($this->i['graph_max_value'] > 100000 && self::text_string_width($this->i['graph_max_value'], $tick_font_size) + 4 > $tick_width)806 {807 $tick_font_size--;808 }809 $g = $this->svg_dom->make_g(array('font-size' => $tick_font_size, 'fill' => self::$c['color']['text'], 'text-anchor' => 'middle'));810 $g_lines = $this->svg_dom->make_g(array('stroke' => self::$c['color']['body'], 'stroke-width' => 1));811 for($i = 0; $i < $this->i['mark_count']; $i++)812 {813 $px_from_left = $left_start + ($tick_width * $i);814 if($i != 0 && $display_value != 0)815 {816 if(!$this->i['no_graph_value_ticks'] && $show_numbers)817 {818 $dv = $display_value;819 if($dv_divide > 1)820 {821 $dv = round($dv / $dv_divide, 2) . $dv_postfix;822 }823 $this->svg_dom->add_text_element($dv, array('x' => $px_from_left + 2, 'y' => ($top_end + 5 + self::$c['size']['tick_mark'])), $g);824 }825 $this->svg_dom->add_element('line', array('x1' => ($px_from_left + 2), 'y1' => ($top_start), 'x2' => ($px_from_left + 2), 'y2' => ($top_end - 5), 'stroke-dasharray' => '5,5'), $g_lines);826 $this->svg_dom->add_element('line', array('x1' => ($px_from_left + 2), 'y1' => ($top_end - 4), 'x2' => ($px_from_left + 2), 'y2' => ($top_end + 5)), $g_lines);827 }828 $display_value += $increment;829 }830 }831 else832 {833 $tick_width = round(($top_end - $top_start) / $this->i['mark_count']);834 $px_from_left_start = $left_start - 5;835 $px_from_left_end = $left_start + 5;836 $display_value = $this->i['graph_min_value'];837 $g_lines = $this->svg_dom->make_g(array('stroke' => self::$c['color']['notches'], 'stroke-width' => 1, 'stroke-dasharray' => '5,5'));838 $g_lines_2 = $this->svg_dom->make_g(array('stroke' => self::$c['color']['notches'], 'stroke-width' => 1));839 $g_background_lines = $this->svg_dom->make_g(array('stroke' => self::$c['color']['body_light'], 'stroke-width' => 1, 'stroke-dasharray' => '5,5'));840 $g_text = $this->svg_dom->make_g(array('font-size' => self::$c['size']['tick_mark'], 'fill' => self::$c['color']['text'], 'text-anchor' => 'end'));841 for($i = 0; $i < $this->i['mark_count']; $i++)842 {843 $px_from_top = round($top_end - ($tick_width * $i));844 if($display_value != 0)845 {846 if(!$this->i['no_graph_value_ticks'] && $show_numbers)847 {848 $dv = $display_value;849 if($dv_divide > 1)850 {851 $dv = round($dv / $dv_divide, 2) . $dv_postfix;852 }853 $this->svg_dom->add_text_element($dv, array('x' => ($px_from_left_start - 4), 'y' => round($px_from_top + (self::$c['size']['tick_mark'] / 2))), $g_text);854 }855 if($i != 0 && $this->i['show_background_lines'])856 {857 // $this->svg_dom->add_element('line', array('x1' => ($px_from_left_end + 6), 'y1' => ($px_from_top + 1), 'x2' => ($this->i['graph_left_end']), 'y2' => ($px_from_top + 1)), $g_background_lines);858 }859 if($i != 0)860 {861 $this->svg_dom->add_element('line', array('x1' => ($left_start), 'y1' => ($px_from_top + 1), 'x2' => ($left_end), 'y2' => ($px_from_top + 1)), $g_lines);862 $this->svg_dom->add_element('line', array('x1' => ($left_start - 4), 'y1' => ($px_from_top + 1), 'x2' => ($left_start + 4), 'y2' => ($px_from_top + 1)), $g_lines_2);863 }864 }865 $display_value += $increment;866 }867 }868 }869 protected function render_graph_identifiers()870 {871 return;872 }873 protected function render_graph_result()874 {875 return;876 }877 protected function graph_key_height()878 {879 if((count($this->results) < 2 || $this->i['show_graph_key'] == false) && !$this->i['is_multi_way_comparison'] && !$this->i['force_graph_key'])880 {881 return 0;882 }883 $this->i['key_line_height'] = 16;884 $ak = array_keys($this->results);885 $this->i['key_item_width'] = 8 + ceil(self::text_string_width(pts_strings::find_longest_string($ak), self::$c['size']['key']) * 1.4);886 $this->i['keys_per_line'] = max(1, floor(($this->i['graph_left_end'] - $this->i['left_start']) / $this->i['key_item_width']));887 return ceil(count($this->results) / $this->i['keys_per_line']) * $this->i['key_line_height'];888 }889 protected function render_graph_key()890 {891 if($this->i['key_line_height'] == 0)892 {893 return;894 }895 $y = $this->i['top_start'] - $this->graph_key_height() - 7;896 $i = 0;897 $g_rect = $this->svg_dom->make_g(array('stroke' => self::$c['color']['notches'], 'stroke-width' => 1));898 $g_text = $this->svg_dom->make_g(array('font-size' => self::$c['size']['key'], 'text-anchor' => 'start', 'font-weight' => 'bold'));899 if(!is_array($this->results))900 {901 return false;902 }903 foreach(array_keys($this->results) as $title)904 {905 if(!empty($title))906 {907 $this_color = $this->get_paint_color($title);908 if($i != 0 && $i % $this->i['keys_per_line'] == 0)909 {910 $y += $this->i['key_line_height'];911 }912 $x = $this->i['left_start'] + 13 + ($this->i['key_item_width'] * ($i % $this->i['keys_per_line']));913 $this->svg_dom->add_element('rect', array('x' => ($x - 13), 'y' => ($y - 5), 'width' => 10, 'height' => 10, 'fill' => $this_color), $g_rect);914 $this->svg_dom->add_text_element($title, array('x' => $x, 'y' => ($y + 4), 'fill' => $this_color), $g_text);915 $i++;916 }917 }918 }919 protected function draw_arrow($tip_x1, $tip_y1, $tail_x1, $tail_y1, $background_color, $border_color = null, $border_width = 0)920 {921 $is_vertical = ($tip_x1 == $tail_x1);922 if($is_vertical)923 {924 // Vertical arrow925 $arrow_length = sqrt(pow(($tail_x1 - $tip_x1), 2) + pow(($tail_y1 - $tip_y1), 2));926 $arrow_length_half = $arrow_length / 2;927 $arrow_points = array(928 $tip_x1 . ',' . $tip_y1,929 ($tail_x1 + $arrow_length_half) . ',' . $tail_y1,930 ($tail_x1 - $arrow_length_half) . ',' . $tail_y1931 );932 }933 else934 {935 // Horizontal arrow936 $arrow_length = sqrt(pow(($tail_x1 - $tip_x1), 2) + pow(($tail_y1 - $tip_y1), 2));937 $arrow_length_half = $arrow_length / 2;938 $arrow_points = array(939 $tip_x1 . ',' . $tip_y1,940 $tail_x1 . ',' . ($tail_y1 + $arrow_length_half),941 $tail_x1 . ',' . ($tail_y1 - $arrow_length_half)942 );943 }944 $this->svg_dom->add_element('polygon', array('points' => implode(' ', $arrow_points), 'fill' => $background_color, 'stroke' => $border_color, 'stroke-width' => $border_width));945 }946 protected function adjust_color($identifier, $paint_color)947 {948 // Adjust the color based on the identifier and the content of value_highlights949 if($this->i['highlight_values'] && (array_key_exists($identifier, $this->i['highlight_values']) || in_array($identifier, $this->i['highlight_values'])))950 {951 $color = isset($this->i['highlight_values'][$identifier]) ? $this->i['highlight_values'][$identifier] : null;952 $paint_color = empty($color) ? self::shift_color($paint_color) : $color;953 }954 return $paint_color;955 }956 protected static function text_string_width($string, $size)957 {958 $dimensions = pts_svg_dom::estimate_text_dimensions($string, $size);959 return $dimensions[0];960 }961 protected static function text_string_height($string, $size)962 {963 $dimensions = pts_svg_dom::estimate_text_dimensions($string, $size);964 return $dimensions[1];965 }966 protected function note_display_height()...

Full Screen

Full Screen

shift_color

Using AI Code Generation

copy

Full Screen

1$graph = new pts_graph_core();2$graph->shift_color('FF0000');3$graph->shift_color('00FF00');4$graph->shift_color('0000FF');5$graph->shift_color('FF00FF');6$graph->shift_color('00FFFF');7$graph->shift_color('FFFF00');8$graph->shift_color('000000');9$graph->shift_color('FFFFFF');10echo $graph->shift_color('FF0000');11echo $graph->shift_color('00FF00');12echo $graph->shift_color('0000FF');13echo $graph->shift_color('FF00FF');14echo $graph->shift_color('00FFFF');15echo $graph->shift_color('FFFF00');16echo $graph->shift_color('000000');17echo $graph->shift_color('FFFFFF');18echo $graph->shift_color('FF0000');19echo $graph->shift_color('00FF00');20echo $graph->shift_color('0000FF');21echo $graph->shift_color('FF00FF');22echo $graph->shift_color('00FFFF');23echo $graph->shift_color('FFFF00');24echo $graph->shift_color('000000');25echo $graph->shift_color('FFFFFF');26echo $graph->shift_color('FF0000');27echo $graph->shift_color('00FF00');28echo $graph->shift_color('0000FF');29echo $graph->shift_color('FF00FF');30echo $graph->shift_color('00FFFF');31echo $graph->shift_color('FFFF00');32echo $graph->shift_color('000000');33echo $graph->shift_color('FFFFFF');34echo $graph->shift_color('FF0000');35echo $graph->shift_color('00FF00');36echo $graph->shift_color('0000FF');37echo $graph->shift_color('FF00FF');38echo $graph->shift_color('00FFFF');39echo $graph->shift_color('FFFF00');40echo $graph->shift_color('000000');41echo $graph->shift_color('FFFFFF');42echo $graph->shift_color('FF0000');43echo $graph->shift_color('00FF00');44echo $graph->shift_color('0000FF');45echo $graph->shift_color('FF00FF');46echo $graph->shift_color('00FFFF');47echo $graph->shift_color('FFFF00');48echo $graph->shift_color('000000');49echo $graph->shift_color('FFFFFF');

Full Screen

Full Screen

shift_color

Using AI Code Generation

copy

Full Screen

1require_once('pts_graph_core.php');2$graph = new pts_graph_core();3$graph->shift_color('blue');4echo $graph->shift_color('blue');5require_once('pts_graph_core.php');6$graph = new pts_graph_core();7$graph->shift_color('blue');8$graph->shift_color('blue');9echo $graph->shift_color('blue');10require_once('pts_graph_core.php');11$graph = new pts_graph_core();12$graph->shift_color('blue');13$graph->shift_color('blue');14$graph->shift_color('blue');15echo $graph->shift_color('blue');16require_once('pts_graph_core.php');17$graph = new pts_graph_core();18$graph->shift_color('blue');19$graph->shift_color('blue');20$graph->shift_color('blue');21$graph->shift_color('blue');22echo $graph->shift_color('blue');23require_once('pts_graph_core.php');24$graph = new pts_graph_core();25$graph->shift_color('blue');26$graph->shift_color('blue');27$graph->shift_color('blue');28$graph->shift_color('blue');29$graph->shift_color('blue');30echo $graph->shift_color('blue');31require_once('pts_graph_core.php');32$graph = new pts_graph_core();

Full Screen

Full Screen

shift_color

Using AI Code Generation

copy

Full Screen

1require_once 'pts_graph_core.php';2$pts_graph_core = new pts_graph_core();3$pts_graph_core->shift_color("#000000", 0.5);4require_once 'pts_graph_core.php';5$pts_graph_core = new pts_graph_core();6$pts_graph_core->shift_color("#000000", 1.0);7require_once 'pts_graph_core.php';8$pts_graph_core = new pts_graph_core();9$pts_graph_core->shift_color("#000000", 1.5);10require_once 'pts_graph_core.php';11$pts_graph_core = new pts_graph_core();12$pts_graph_core->shift_color("#000000", 2.0);13require_once 'pts_graph_core.php';14$pts_graph_core = new pts_graph_core();15$pts_graph_core->shift_color("#000000", 2.5);16require_once 'pts_graph_core.php';17$pts_graph_core = new pts_graph_core();18$pts_graph_core->shift_color("#000000", 3.0);19require_once 'pts_graph_core.php';20$pts_graph_core = new pts_graph_core();21$pts_graph_core->shift_color("#000000", 3.5);22require_once 'pts_graph_core.php';23$pts_graph_core = new pts_graph_core();24$pts_graph_core->shift_color("#000000", 4.0);25require_once 'pts_graph_core.php';26$pts_graph_core = new pts_graph_core();27$pts_graph_core->shift_color("#000000", 4.5);28require_once 'pts_graph_core.php';

Full Screen

Full Screen

shift_color

Using AI Code Generation

copy

Full Screen

1require_once('pts_graph_core.php');2$color = new pts_graph_core();3$color->shift_color('#000000', 1.5);4echo $color->get_current_color();5require_once('pts_graph_core.php');6$color = new pts_graph_core();7$color->shift_color('#000000', 2.5);8echo $color->get_current_color();9require_once('pts_graph_core.php');10$color = new pts_graph_core();11$color->shift_color('#000000', 3.5);12echo $color->get_current_color();13require_once('pts_graph_core.php');14$color = new pts_graph_core();15$color->shift_color('#000000', 4.5);16echo $color->get_current_color();17require_once('pts_graph_core.php');18$color = new pts_graph_core();19$color->shift_color('#000000', 5.5);20echo $color->get_current_color();21require_once('pts_graph_core.php');22$color = new pts_graph_core();23$color->shift_color('#000000', 6.5);24echo $color->get_current_color();25require_once('pts_graph_core.php');26$color = new pts_graph_core();27$color->shift_color('#000000', 7.5);28echo $color->get_current_color();29require_once('pts_graph_core.php');30$color = new pts_graph_core();31$color->shift_color('#000000', 8.5);32echo $color->get_current_color();33require_once('pts_graph_core.php');34$color = new pts_graph_core();35$color->shift_color('#000000', 9.5);

Full Screen

Full Screen

shift_color

Using AI Code Generation

copy

Full Screen

1$colors = $graph->shift_color('FF0000', '00FF00', 10);2$graph->color_array = $colors;3$colors = $graph->shift_color('FF0000', '00FF00', 10);4$graph->color_array = $colors;5$colors = $graph->shift_color('FF0000', '00FF00', 10);6$graph->color_array = $colors;7$colors = $graph->shift_color('FF0000', '00FF00', 10);

Full Screen

Full Screen

shift_color

Using AI Code Generation

copy

Full Screen

1require_once('pts_graph_core.php');2$graph = new pts_graph_core();3$graph->shift_color('red', 0.25);4echo $graph->get_color('red');5Related Posts: PHP | array_shift() Function6PHP | array_shift() Function PHP | array_unshift() Function7PHP | array_unshift() Function PHP | array_shift() Function8PHP | array_shift() Function PHP | array_reverse() Function9PHP | array_reverse() Function PHP | array_slice() Function10PHP | array_slice() Function PHP | array_splice() Function11PHP | array_splice() Function PHP | array_push() Function12PHP | array_push() Function PHP | array_pop() Function13PHP | array_pop() Function PHP | array_multisort() Function14PHP | array_multisort() Function PHP | array_merge() Function15PHP | array_merge() Function PHP | array_keys() Function16PHP | array_keys() Function PHP | array_intersect() Function17PHP | array_intersect() Function PHP | array_flip() Function18PHP | array_flip() Function PHP | array_fill() Function19PHP | array_fill() Function PHP | array_diff() Function20PHP | array_diff() Function PHP | array_count_values() Function21PHP | array_count_values() Function PHP | array_combine() Function22PHP | array_combine() Function PHP | array_chunk() Function23PHP | array_chunk() Function PHP | array_change_key_case() Function

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful