/** * I use this wrapper for default dot types, * it just makes the code easier to read. */ function s_box($colour, $size) { parent::anchor(); $this->colour($colour)->size($size)->rotation(45)->sides(4); }
/** * I use this wrapper for default dot types, * it just makes the code easier to read. */ public function __construct($colour, $size) { parent::anchor(); $this->colour($colour)->size($size)->rotation(45)->sides(4); }
function get_linear_graph($dates, $vals, $keys = array()) { include 'php-ofc-library/open-flash-chart.php'; $max_y = 0; $arr_filled = array(); for ($i = 0; $i < count($dates); $i++) { $year[] = $dates[$i]; for ($m = 0; $m < count($vals); $m++) { $price[$m][] = (int) $vals[$m][$i]; if ($max_y < (int) $vals[$m][$i]) { $max_y = (int) $vals[$m][$i]; } if (@$arr_filled[$m] != $vals[$m][$i] and @$arr_filled[$m] == 0) { @($arr_filled[$m] = (int) $vals[$m][$i]); } } } while ($max_y % 10 != 0) { $max_y++; } $chart = new open_flash_chart(); //$title = new title( 'UK Petrol price (pence) per Litre' ); $d = new anchor(); if (count($dates) > 60) { $d->size(2); } else { $d->size(3); } $d->halo_size(1); $d->colour('#3D5C56'); $d->rotation(0); $d->sides(4); for ($i = 0; $i < count($price); $i++) { if ($arr_filled[$i] == 0) { continue; } if ($i == 0) { $color = '#5E0722'; } elseif ($i == 1) { $color = '#00FF00'; } else { $color = '#FF0000'; } $area = new area(); $area->set_colour($color); $area->set_default_dot_style($d); $area->set_values($price[$i]); if (isset($keys[$i])) { $area->set_key($keys[$i], 12); } // mb_convert_encoding($keys[$i], "UTF-8", "Windows-1251") $area->set_width(2); $chart->add_element($area); } $x_labels = new x_axis_labels(); if (count($dates) > 40) { $x_labels->set_steps(7); } else { $x_labels->set_steps(1); } $x_labels->set_vertical(); $x_labels->set_colour('#000000'); $x_labels->set_labels($year); $x_labels->rotate(-55); $x_labels->set_size(12); $x = new x_axis(); $x->set_colour('#000000'); $x->set_grid_colour('#DDDDDD'); //$x->set_offset( false ); $x->set_steps(1); // Add the X Axis Labels to the X Axis $x->set_labels($x_labels); $chart->set_x_axis($x); $y = new y_axis(); $y->set_range(0, $max_y); $y->set_colour('#000000'); $y->set_grid_colour('#DDDDDD'); $chart->add_y_axis($y); $chart->set_bg_colour("#FFFFFF"); ?> <script type="text/javascript" src="script/json/json2.js"></script> <script type="text/javascript" src="script/swfobject.js"></script> <script type="text/javascript"> swfobject.embedSWF("open-flash-chart.swf", "my_chart", "600", "350", "9.0.0"); </script> <script type="text/javascript"> function ofc_ready() { } function open_flash_chart_data() { return JSON.stringify(data); } function findSWF(movieName) { if (navigator.appName.indexOf("Microsoft")!= -1) { return window[movieName]; } else { return document[movieName]; } } var data = <?php echo $chart->toPrettyString(); ?> ; </script> <?php }