ofc_line.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. <?php
  2. class line_on_show
  3. {
  4. /**
  5. *@param $type as string. Can be any one of:
  6. * - 'pop-up'
  7. * - 'explode'
  8. * - 'mid-slide'
  9. * - 'drop'
  10. * - 'fade-in'
  11. * - 'shrink-in'
  12. *
  13. * @param $cascade as float. Cascade in seconds
  14. * @param $delay as float. Delay before animation starts in seconds.
  15. */
  16. function __construct($type, $cascade, $delay)
  17. {
  18. $this->type = $type;
  19. $this->cascade = (float)$cascade;
  20. $this->delay = (float)$delay;
  21. }
  22. }
  23. class line
  24. {
  25. function line()
  26. {
  27. $this->type = "line";
  28. $this->values = array();
  29. }
  30. /**
  31. * Set the default dot that all the real
  32. * dots inherit their properties from. If you set the
  33. * default dot to be red, all values in your chart that
  34. * do not specify a colour will be red. Same for all the
  35. * other attributes such as tooltip, on-click, size etc...
  36. *
  37. * @param $style as any class that inherits base_dot
  38. */
  39. function set_default_dot_style( $style )
  40. {
  41. $tmp = 'dot-style';
  42. $this->$tmp = $style;
  43. }
  44. /**
  45. * @param $v as array, can contain any combination of:
  46. * - integer, Y position of the point
  47. * - any class that inherits from dot_base
  48. * - <b>null</b>
  49. */
  50. function set_values( $v )
  51. {
  52. $this->values = $v;
  53. }
  54. /**
  55. * Append a value to the line.
  56. *
  57. * @param mixed $v
  58. */
  59. function append_value($v)
  60. {
  61. $this->values[] = $v;
  62. }
  63. function set_width( $width )
  64. {
  65. $this->width = $width;
  66. }
  67. function set_colour( $colour )
  68. {
  69. $this->colour = $colour;
  70. }
  71. /**
  72. * sytnatical sugar for set_colour
  73. */
  74. function colour( $colour )
  75. {
  76. $this->set_colour( $colour );
  77. return $this;
  78. }
  79. function set_halo_size( $size )
  80. {
  81. $tmp = 'halo-size';
  82. $this->$tmp = $size;
  83. }
  84. function set_key( $text, $font_size )
  85. {
  86. $this->text = $text;
  87. $tmp = 'font-size';
  88. $this->$tmp = $font_size;
  89. }
  90. function set_tooltip( $tip )
  91. {
  92. $this->tip = $tip;
  93. }
  94. /**
  95. * @param $text as string. A javascript function name as a string. The chart will
  96. * try to call this function, it will pass the chart id as the only parameter into
  97. * this function. E.g:
  98. *
  99. */
  100. function set_on_click( $text )
  101. {
  102. $tmp = 'on-click';
  103. $this->$tmp = $text;
  104. }
  105. function loop()
  106. {
  107. $this->loop = true;
  108. }
  109. function line_style( $s )
  110. {
  111. $tmp = "line-style";
  112. $this->$tmp = $s;
  113. }
  114. /**
  115. * Sets the text for the line.
  116. *
  117. * @param string $text
  118. */
  119. function set_text($text)
  120. {
  121. $this->text = $text;
  122. }
  123. function attach_to_right_y_axis()
  124. {
  125. $this->axis = 'right';
  126. }
  127. /**
  128. *@param $on_show as line_on_show object
  129. */
  130. function set_on_show($on_show)
  131. {
  132. $this->{'on-show'} = $on_show;
  133. }
  134. function on_show($on_show)
  135. {
  136. $this->set_on_show($on_show);
  137. return $this;
  138. }
  139. }