diff --git a/pages/php-ofc-library/dot_base.php b/pages/php-ofc-library/dot_base.php new file mode 100644 index 0000000000..843db7dc80 --- /dev/null +++ b/pages/php-ofc-library/dot_base.php @@ -0,0 +1,231 @@ +type = $type; + if( isset( $value ) ) + $this->value( $value ); + } + + /** + * For line charts that only require a Y position + * for each point. + * @param $value as integer, the Y position + */ + function value( $value ) + { + $this->value = $value; + } + + /** + * For scatter charts that require an X and Y position for + * each point. + * + * @param $x as integer + * @param $y as integer + */ + function position( $x, $y ) + { + $this->x = $x; + $this->y = $y; + } + + /** + * @param $colour is a string, HEX colour, e.g. '#FF0000' red + */ + function colour($colour) + { + $this->colour = $colour; + return $this; + } + + /** + * The tooltip for this dot. + */ + function tooltip( $tip ) + { + $this->tip = $tip; + return $this; + } + + /** + * @param $size is an integer. Size of the dot. + */ + function size($size) + { + $tmp = 'dot-size'; + $this->$tmp = $size; + return $this; + } + + /** + * a private method + */ + function type( $type ) + { + $this->type = $type; + return $this; + } + + /** + * @param $size is an integer. The size of the hollow 'halo' around the dot that masks the line. + */ + function halo_size( $size ) + { + $tmp = 'halo-size'; + $this->$tmp = $size; + return $this; + } + + /** + * @param $do as string. One of three options (examples): + * - "http://example.com" - browse to this URL + * - "https://example.com" - browse to this URL + * - "trace:message" - print this message in the FlashDevelop debug pane + * - all other strings will be called as Javascript functions, so a string "hello_world" + * will call the JS function "hello_world(index)". It passes in the index of the + * point. + */ + function on_click( $do ) + { + $tmp = 'on-click'; + $this->$tmp = $do; + } +} + +/** + * Draw a hollow dot + */ +class hollow_dot extends dot_base +{ + function hollow_dot($value=null) + { + parent::dot_base( 'hollow-dot', $value ); + } +} + +/** + * Draw a star + */ +class star extends dot_base +{ + /** + * The constructor, takes an optional $value + */ + function star($value=null) + { + parent::dot_base( 'star', $value ); + } + + /** + * @param $angle is an integer. + */ + function rotation($angle) + { + $this->rotation = $angle; + return $this; + } + + /** + * @param $is_hollow is a boolean. + */ + function hollow($is_hollow) + { + $this->hollow = $is_hollow; + } +} + +/** + * Draw a 'bow tie' shape. + */ +class bow extends dot_base +{ + /** + * The constructor, takes an optional $value + */ + function bow($value=null) + { + parent::dot_base( 'bow', $value ); + } + + /** + * Rotate the anchor object. + * @param $angle is an integer. + */ + function rotation($angle) + { + $this->rotation = $angle; + return $this; + } +} + +/** + * An n sided shape. + */ +class anchor extends dot_base +{ + /** + * The constructor, takes an optional $value + */ + function anchor($value=null) + { + parent::dot_base( 'anchor', $value ); + } + + /** + * Rotate the anchor object. + * @param $angle is an integer. + */ + function rotation($angle) + { + $this->rotation = $angle; + return $this; + } + + /** + * @param $sides is an integer. Number of sides this shape has. + */ + function sides($sides) + { + $this->sides = $sides; + return $this; + } +} + +/** + * A simple dot + */ +class dot extends dot_base +{ + /** + * The constructor, takes an optional $value + */ + function dot($value=null) + { + parent::dot_base( 'dot', $value ); + } +} + +/** + * A simple dot + */ +class solid_dot extends dot_base +{ + /** + * The constructor, takes an optional $value + */ + function solid_dot($value=null) + { + parent::dot_base( 'solid-dot', $value ); + } +} \ No newline at end of file diff --git a/pages/php-ofc-library/ofc_arrow.php b/pages/php-ofc-library/ofc_arrow.php new file mode 100644 index 0000000000..77671c87f4 --- /dev/null +++ b/pages/php-ofc-library/ofc_arrow.php @@ -0,0 +1,27 @@ +type = "arrow"; + $this->start = array("x"=>$x, "y"=>$y); + $this->end = array("x"=>$a, "y"=>$b); + $this->colour($colour); + $this->{"barb-length"} = $barb_length; + } + + function colour( $colour ) + { + $this->colour = $colour; + return $this; + } +} diff --git a/pages/php-ofc-library/ofc_candle.php b/pages/php-ofc-library/ofc_candle.php new file mode 100644 index 0000000000..5507efa9ef --- /dev/null +++ b/pages/php-ofc-library/ofc_candle.php @@ -0,0 +1,41 @@ +high = $high; + $this->top = $open; + $this->bottom = $close; + $this->low = $low; + } + + function set_colour( $colour ) + { + $this->colour = $colour; + } + + function set_tooltip( $tip ) + { + $this->tip = $tip; + } +} + +class candle extends bar_base +{ + function candle($colour, $negative_colour=null) + { + $this->type = "candle"; + parent::bar_base(); + + $this->set_colour( $colour ); + if(!is_null($negative_colour)) + $this->{'negative-colour'} = $negative_colour; + } +} + diff --git a/pages/php-ofc-library/ofc_menu.php b/pages/php-ofc-library/ofc_menu.php new file mode 100644 index 0000000000..c44dd177a3 --- /dev/null +++ b/pages/php-ofc-library/ofc_menu.php @@ -0,0 +1,56 @@ +type = "text"; + $this->text = $text; + $tmp = 'javascript-function'; + $this->$tmp = $javascript_function_name; + } +} + +class ofc_menu_item_camera +{ + /** + * @param $text as string. The menu item text. + * @param $javascript_function_name as string. The javascript function name, the + * js function takes one parameter, the chart ID. So for example, our js function + * could look like this: + * + * function save_image( chart_id ) + * { + * alert( chart_id ); + * } + * + * to make a menu item call this: ofc_menu_item_camera('Save chart', 'save_image'); + */ + function ofc_menu_item_camera($text, $javascript_function_name) + { + $this->type = "camera-icon"; + $this->text = $text; + $tmp = 'javascript-function'; + $this->$tmp = $javascript_function_name; + } +} + +class ofc_menu +{ + function ofc_menu($colour, $outline_colour) + { + $this->colour = $colour; + $this->outline_colour = $outline_colour; + } + + function values($values) + { + $this->values = $values; + } +} \ No newline at end of file diff --git a/pages/php-ofc-library/ofc_sugar.php b/pages/php-ofc-library/ofc_sugar.php new file mode 100644 index 0000000000..242182a4c2 --- /dev/null +++ b/pages/php-ofc-library/ofc_sugar.php @@ -0,0 +1,43 @@ +colour($colour)->size($size); + } +} + +class s_box extends anchor +{ + /** + * 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); + } +} + +class s_hollow_dot extends hollow_dot +{ + /** + * I use this wrapper for default dot types, + * it just makes the code easier to read. + */ + function s_hollow_dot($colour, $size) + { + parent::hollow_dot(); + $this->colour($colour)->size($size); + } +} \ No newline at end of file diff --git a/pages/php-ofc-library/ofc_tags.php b/pages/php-ofc-library/ofc_tags.php new file mode 100644 index 0000000000..e31f7d65c1 --- /dev/null +++ b/pages/php-ofc-library/ofc_tags.php @@ -0,0 +1,133 @@ +type = "tags"; + $this->values = array(); + } + + function colour( $colour ) + { + $this->colour = $colour; + return $this; + } + + /** + *@param $font as string. e.g. "Verdana" + *@param $size as integer. Size in px + */ + function font($font, $size) + { + $this->font = $font; + $this->{'font-size'} = $size; + return $this; + } + + /** + *@param $x as integer. Size of x padding in px + *@param $y as integer. Size of y padding in px + */ + function padding($x, $y) + { + $this->{"pad-x"} = $x; + $this->{"pad-y"} = $y; + return $this; + } + + function rotate($angle) + { + $this->rotate($angle); + return $this; + } + + function align_x_center() + { + $this->{"align-x"} = "center"; + return $this; + } + + function align_x_left() + { + $this->{"align-x"} = "left"; + return $this; + } + + function align_x_right() + { + $this->{"align-x"} = "right"; + return $this; + } + + function align_y_above() + { + $this->{"align-y"} = "above"; + return $this; + } + + function align_y_below() + { + $this->{"align-y"} = "below"; + return $this; + } + + function align_y_center() + { + $this->{"align-y"} = "center"; + return $this; + } + + /** + * This can contain some HTML, e.g: + * - "More info" + * - "ofc" + */ + function text($text) + { + $this->text = $text; + return $this; + } + + /** + * This works, but to get the mouse pointer to change + * to a little hand you need to use "stuff"-- see text() + */ + function on_click($on_click) + { + $this->{'on-click'} = $on_click; + return $this; + } + + /** + *@param $bold boolean. + *@param $underline boolean. + *@param $border boolean. + *@prarm $alpha real (0 to 1.0) + */ + function style($bold, $underline, $border, $alpha ) + { + $this->bold = $bold; + $this->border = $underline; + $this->underline = $border; + $this->alpha = $alpha; + return $this; + } + + /** + *@param $tag as ofc_tag + */ + function append_tag($tag) + { + $this->values[] = $tag; + } +} + +class ofc_tag extends ofc_tags +{ + function ofc_tag($x, $y) + { + $this->x = $x; + $this->y = $y; + } +} \ No newline at end of file diff --git a/pages/php-ofc-library/ofc_y_axis_label.php b/pages/php-ofc-library/ofc_y_axis_label.php new file mode 100644 index 0000000000..bded9b84e5 --- /dev/null +++ b/pages/php-ofc-library/ofc_y_axis_label.php @@ -0,0 +1,38 @@ +y = $y; + $this->set_text( $text ); + } + + function set_text( $text ) + { + $this->text = $text; + } + + function set_colour( $colour ) + { + $this->colour = $colour; + } + + function set_size( $size ) + { + $this->size = $size; + } + + function set_rotate( $rotate ) + { + $this->rotate = $rotate; + } + + function set_vertical() + { + $this->rotate = "vertical"; + } +} \ No newline at end of file diff --git a/pages/php-ofc-library/ofc_y_axis_labels.php b/pages/php-ofc-library/ofc_y_axis_labels.php new file mode 100644 index 0000000000..75f777e532 --- /dev/null +++ b/pages/php-ofc-library/ofc_y_axis_labels.php @@ -0,0 +1,57 @@ +steps = $steps; + } + + /** + * + * @param $labels as an array of [y_axis_label or string] + */ + function set_labels( $labels ) + { + $this->labels = $labels; + } + + function set_colour( $colour ) + { + $this->colour = $colour; + } + + /** + * font size in pixels + */ + function set_size( $size ) + { + $this->size = $size; + } + + /** + * rotate labels + */ + function set_vertical() + { + $this->rotate = 270; + } + + function rotate( $angle ) + { + $this->rotate = $angle; + } + + /** + * @param $text default text that all labels inherit + */ + function set_text( $text ) + { + $this->text = $text; + } +} \ No newline at end of file