open-flash-chart.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. // var_dump(debug_backtrace());
  3. //
  4. // Omar Kilani's php C extension for encoding JSON has been incorporated in stock PHP since 5.2.0
  5. // http://www.aurore.net/projects/php-json/
  6. //
  7. // -- Marcus Engene
  8. //
  9. if (! function_exists('json_encode'))
  10. {
  11. include_once 'JSON.php';
  12. }
  13. include_once 'json_format.php';
  14. // ofc classes
  15. include_once 'ofc_title.php';
  16. include_once 'ofc_y_axis_base.php';
  17. include_once 'ofc_y_axis.php';
  18. include_once 'ofc_y_axis_right.php';
  19. include_once 'ofc_y_axis_labels.php';
  20. include_once 'ofc_y_axis_label.php';
  21. include_once 'ofc_x_axis.php';
  22. include_once 'ofc_pie.php';
  23. //include_once 'ofc_bar.php';
  24. include_once 'ofc_bar_glass.php';
  25. include_once 'ofc_bar_filled.php';
  26. include_once 'ofc_bar_stack.php';
  27. //include_once 'ofc_bar_3d.php';
  28. include_once 'ofc_hbar.php';
  29. include_once 'ofc_line_base.php';
  30. include_once 'ofc_line.php';
  31. //include_once 'ofc_line_dot.php';
  32. //include_once 'ofc_line_hollow.php';
  33. include_once 'ofc_candle.php';
  34. include_once 'ofc_area_base.php';
  35. include_once 'ofc_tags.php';
  36. include_once 'ofc_arrow.php';
  37. //include_once 'ofc_area_hollow.php';
  38. //include_once 'ofc_area_line.php';
  39. include_once 'ofc_x_legend.php';
  40. include_once 'ofc_y_legend.php';
  41. include_once 'ofc_bar_sketch.php';
  42. include_once 'ofc_scatter.php';
  43. include_once 'ofc_scatter_line.php';
  44. include_once 'ofc_x_axis_labels.php';
  45. include_once 'ofc_x_axis_label.php';
  46. include_once 'ofc_tooltip.php';
  47. include_once 'ofc_shape.php';
  48. include_once 'ofc_radar_axis.php';
  49. include_once 'ofc_radar_axis_labels.php';
  50. include_once 'ofc_radar_spoke_labels.php';
  51. include_once 'ofc_line_style.php';
  52. include_once 'dot_base.php';
  53. include_once 'ofc_menu.php';
  54. class open_flash_chart
  55. {
  56. function open_flash_chart()
  57. {
  58. //$this->title = new title( "Many data lines" );
  59. $this->elements = array();
  60. }
  61. function set_title( $t )
  62. {
  63. $this->title = $t;
  64. }
  65. function set_x_axis( $x )
  66. {
  67. $this->x_axis = $x;
  68. }
  69. function set_y_axis( $y )
  70. {
  71. $this->y_axis = $y;
  72. }
  73. function add_y_axis( $y )
  74. {
  75. $this->y_axis = $y;
  76. }
  77. function set_y_axis_right( $y )
  78. {
  79. $this->y_axis_right = $y;
  80. }
  81. function add_element( $e )
  82. {
  83. $this->elements[] = $e;
  84. }
  85. function set_x_legend( $x )
  86. {
  87. $this->x_legend = $x;
  88. }
  89. function set_y_legend( $y )
  90. {
  91. $this->y_legend = $y;
  92. }
  93. function set_bg_colour( $colour )
  94. {
  95. $this->bg_colour = $colour;
  96. }
  97. function set_radar_axis( $radar )
  98. {
  99. $this->radar_axis = $radar;
  100. }
  101. function set_tooltip( $tooltip )
  102. {
  103. $this->tooltip = $tooltip;
  104. }
  105. /**
  106. * This is a bit funky :(
  107. *
  108. * @param $num_decimals as integer. Truncate the decimals to $num_decimals, e.g. set it
  109. * to 5 and 3.333333333 will display as 3.33333. 2.0 will display as 2 (or 2.00000 - see below)
  110. * @param $is_fixed_num_decimals_forced as boolean. If true it will pad the decimals.
  111. * @param $is_decimal_separator_comma as boolean
  112. * @param $is_thousand_separator_disabled as boolean
  113. *
  114. * This needs a bit of love and attention
  115. */
  116. function set_number_format($num_decimals, $is_fixed_num_decimals_forced, $is_decimal_separator_comma, $is_thousand_separator_disabled )
  117. {
  118. $this->num_decimals = $num_decimals;
  119. $this->is_fixed_num_decimals_forced = $is_fixed_num_decimals_forced;
  120. $this->is_decimal_separator_comma = $is_decimal_separator_comma;
  121. $this->is_thousand_separator_disabled = $is_thousand_separator_disabled;
  122. }
  123. /**
  124. * This is experimental and will change as we make it work
  125. *
  126. * @param $m as ofc_menu
  127. */
  128. function set_menu($m)
  129. {
  130. $this->menu = $m;
  131. }
  132. function toString()
  133. {
  134. if (function_exists('json_encode'))
  135. {
  136. return json_encode($this);
  137. }
  138. else
  139. {
  140. $json = new Services_JSON();
  141. return $json->encode( $this );
  142. }
  143. }
  144. function toPrettyString()
  145. {
  146. return json_format( $this->toString() );
  147. }
  148. }
  149. //
  150. // there is no PHP end tag so we don't mess the headers up!
  151. //