ofc_bar_base.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. /* this is a base class */
  3. class bar_base
  4. {
  5. function bar_base(){}
  6. /**
  7. * @param $text as string the key text
  8. * @param $size as integer, size in pixels
  9. */
  10. function set_key( $text, $size )
  11. {
  12. $this->text = $text;
  13. $tmp = 'font-size';
  14. $this->$tmp = $size;
  15. }
  16. /**
  17. * syntatical sugar.
  18. */
  19. function key( $text, $size )
  20. {
  21. $this->set_key( $text, $size );
  22. }
  23. /**
  24. * @param $v as an array, a mix of:
  25. * - a bar_value class. You can use this to customise the paramters of each bar.
  26. * - integer. This is the Y position of the top of the bar.
  27. */
  28. function set_values( $v )
  29. {
  30. $this->values = $v;
  31. }
  32. /**
  33. * see set_values
  34. */
  35. function append_value( $v )
  36. {
  37. $this->values[] = $v;
  38. }
  39. /**
  40. * @param $colour as string, a HEX colour, e.g. '#ff0000' red
  41. */
  42. function set_colour( $colour )
  43. {
  44. $this->colour = $colour;
  45. }
  46. /**
  47. *syntatical sugar
  48. */
  49. function colour( $colour )
  50. {
  51. $this->set_colour( $colour );
  52. }
  53. /**
  54. * @param $alpha as real number (range 0 to 1), e.g. 0.5 is half transparent
  55. */
  56. function set_alpha( $alpha )
  57. {
  58. $this->alpha = $alpha;
  59. }
  60. /**
  61. * @param $tip as string, the tip to show. May contain various magic variables.
  62. */
  63. function set_tooltip( $tip )
  64. {
  65. $this->tip = $tip;
  66. }
  67. /**
  68. *@param $on_show as line_on_show object
  69. */
  70. function set_on_show($on_show)
  71. {
  72. $this->{'on-show'} = $on_show;
  73. }
  74. function set_on_click( $text )
  75. {
  76. $tmp = 'on-click';
  77. $this->$tmp = $text;
  78. }
  79. function attach_to_right_y_axis()
  80. {
  81. $this->axis = 'right';
  82. }
  83. }