mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-19 08:38:45 +02:00
231
pages/php-ofc-library/dot_base.php
Normal file
231
pages/php-ofc-library/dot_base.php
Normal file
@@ -0,0 +1,231 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* A private class. All the other line-dots inherit from this.
|
||||
* Gives them all some common methods.
|
||||
*/
|
||||
class dot_base
|
||||
{
|
||||
/**
|
||||
* @param $type string
|
||||
* @param $value integer
|
||||
*/
|
||||
function dot_base($type, $value=null)
|
||||
{
|
||||
$this->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 <i><b>n</b></i> 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 );
|
||||
}
|
||||
}
|
||||
27
pages/php-ofc-library/ofc_arrow.php
Normal file
27
pages/php-ofc-library/ofc_arrow.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
class ofc_arrow
|
||||
{
|
||||
/**
|
||||
*@param $x as number. Start x position
|
||||
*@param $y as number. Start y position
|
||||
*@param $a as number. End x position
|
||||
*@param $b as number. End y position
|
||||
*@param $colour as string.
|
||||
*@param $barb_length as number. Length of the barbs in pixels.
|
||||
*/
|
||||
function ofc_arrow($x, $y, $a, $b, $colour, $barb_length=10)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
41
pages/php-ofc-library/ofc_candle.php
Normal file
41
pages/php-ofc-library/ofc_candle.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
include_once 'ofc_bar_base.php';
|
||||
|
||||
class candle_value
|
||||
{
|
||||
/**
|
||||
*
|
||||
*/
|
||||
function candle_value( $high, $open, $close, $low )
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
|
||||
56
pages/php-ofc-library/ofc_menu.php
Normal file
56
pages/php-ofc-library/ofc_menu.php
Normal file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
|
||||
class ofc_menu_item
|
||||
{
|
||||
/**
|
||||
* @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. See ofc_menu_item_camera for
|
||||
* some example code.
|
||||
*/
|
||||
function ofc_menu_item($text, $javascript_function_name)
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
43
pages/php-ofc-library/ofc_sugar.php
Normal file
43
pages/php-ofc-library/ofc_sugar.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Sugar: to make stars easier sometimes
|
||||
*/
|
||||
class s_star extends star
|
||||
{
|
||||
/**
|
||||
* I use this wrapper for default dot types,
|
||||
* it just makes the code easier to read.
|
||||
*/
|
||||
function s_star($colour, $size)
|
||||
{
|
||||
parent::star();
|
||||
$this->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);
|
||||
}
|
||||
}
|
||||
133
pages/php-ofc-library/ofc_tags.php
Normal file
133
pages/php-ofc-library/ofc_tags.php
Normal file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
|
||||
class ofc_tags
|
||||
{
|
||||
function ofc_tags()
|
||||
{
|
||||
$this->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 <a href="javascript:alert(12);">info</a>"
|
||||
* - "<a href="http://teethgrinder.co.uk">ofc</a>"
|
||||
*/
|
||||
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 "<a href="">stuff</a>"-- 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;
|
||||
}
|
||||
}
|
||||
38
pages/php-ofc-library/ofc_y_axis_label.php
Normal file
38
pages/php-ofc-library/ofc_y_axis_label.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* y_axis_label see y_axis_labels
|
||||
*/
|
||||
class y_axis_label
|
||||
{
|
||||
function y_axis_label( $y, $text)
|
||||
{
|
||||
$this->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";
|
||||
}
|
||||
}
|
||||
57
pages/php-ofc-library/ofc_y_axis_labels.php
Normal file
57
pages/php-ofc-library/ofc_y_axis_labels.php
Normal file
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
class y_axis_labels
|
||||
{
|
||||
function y_axis_labels(){}
|
||||
|
||||
/**
|
||||
* @param $steps which labels are generated
|
||||
*/
|
||||
function set_steps( $steps )
|
||||
{
|
||||
$this->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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user