open_flash_chart.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271
  1. function ofc_chart() {
  2. this.elements = [];
  3. this.set_title = function(title) {
  4. this.title = title;
  5. };
  6. this.add_element = function(new_element) {
  7. this.elements.push(new_element);
  8. };
  9. this.set_x_axis = function(axis) {
  10. this.x_axis = axis;
  11. };
  12. this.set_y_axis = function(axis) {
  13. this.y_axis = axis;
  14. };
  15. }
  16. function ofc_element(type) {
  17. this.type = type;
  18. this.values = [];
  19. this.set_values = function(values) {
  20. this.values = values;
  21. };
  22. this.set_key = function(text, size) {
  23. this.text = text;
  24. this['font-size'] = size;
  25. };
  26. this.set_colour = function(colour) {
  27. this.colour = colour;
  28. };
  29. }
  30. function ofc_line() {
  31. ofc_element.apply(this, ['line']);
  32. }
  33. ofc_line.prototype = new ofc_element();
  34. function ofc_bar() {
  35. ofc_element.apply(this, ['bar']);
  36. }
  37. ofc_bar.prototype = new ofc_element();
  38. function ofc_scatter(colour) {
  39. ofc_element.apply(this, ['scatter']);
  40. this.set_colour(colour);
  41. this.set_default_dot_style = function(dot_style) {
  42. this['dot-style'] = dot_style;
  43. };
  44. }
  45. ofc_scatter.prototype = new ofc_element();
  46. function ofc_scatter_line(colour) {
  47. ofc_element.apply(this, ['scatter_line']);
  48. this.set_colour(colour);
  49. this.set_default_dot_style = function(dot_style) {
  50. this['dot-style'] = dot_style;
  51. };
  52. this.set_step_horizontal = function() {
  53. this.stepgraph = 'horizontal';
  54. };
  55. this.set_step_vertical = function() {
  56. this.stepgraph = 'vertical';
  57. };
  58. }
  59. ofc_scatter_line.prototype = new ofc_element();
  60. function ofc_title(text, style) {
  61. this.text = text;
  62. this.style = style;
  63. }
  64. function ofc_axis() {
  65. this.set_range = function(min, max) {
  66. this.min = min;
  67. this.max = max;
  68. };
  69. this.set_steps = function(steps) {
  70. this.steps = steps;
  71. };
  72. this.set_stroke = function(stroke) {
  73. this.stroke = stroke;
  74. };
  75. this.set_colour = function(colour) {
  76. this.colour = colour;
  77. };
  78. this.set_grid_colour = function(grid_colour) {
  79. this['grid-colour'] = grid_colour;
  80. };
  81. this.set_offset = function(offset) {
  82. this.offset = offset;
  83. };
  84. }
  85. function ofc_x_axis() {
  86. this.set_tick_height = function(tick_height) {
  87. this['tick-height'] = tick_height;
  88. };
  89. this.set_3d = function(threeD) {
  90. this['3d'] = threeD;
  91. };
  92. }
  93. ofc_x_axis.prototype = new ofc_axis();
  94. function ofc_y_axis() {
  95. this.set_tick_length = function(tick_length) {
  96. this['tick-length'] = tick_length;
  97. };
  98. this.set_grid_visible = function(grid_visible) {
  99. this['grid-visible'] = grid_visible;
  100. };
  101. this.set_visible = function(visible) {
  102. this.visible = visible;
  103. };
  104. }
  105. ofc_y_axis.prototype = new ofc_axis();
  106. function ofc_scatter_value(xVal, yVal, dot_size) {
  107. this.x = xVal || 0;
  108. this.y = yVal || 0;
  109. this['dot-size'] = dot_size;
  110. }
  111. function ofc_dot_base(type, value) {
  112. this.type = type;
  113. this.value = value;
  114. this.position = function position(xVal, yVal) {
  115. this.x = xVal;
  116. this.y = yVal;
  117. };
  118. }
  119. function ofc_dot(value) {
  120. ofc_dot_base.apply(this, ['dot', value]);
  121. }
  122. ofc_dot.prototype = new ofc_dot();
  123. function ofc_hollow_dot(value) {
  124. ofc_dot_base.apply(this, ['hollow-dot', value]);
  125. }
  126. ofc_hollow_dot.prototype = new ofc_dot_base();
  127. function ofc_solid_dot(value) {
  128. ofc_dot_base.apply(this, ['solid-dot', value]);
  129. }
  130. ofc_solid_dot.prototype = new ofc_dot();
  131. function ofc_star(value) {
  132. ofc_dot_base.apply(this, ['star', value]);
  133. }
  134. ofc_star.prototype = new ofc_dot_base();
  135. function ofc_bow(value) {
  136. ofc_dot_base.apply(this, ['bow', value]);
  137. }
  138. ofc_bow.prototype = new ofc_dot_base();
  139. function ofc_anchor(value) {
  140. ofc_dot_base.apply(this, ['anchor', value]);
  141. }
  142. ofc_anchor.prototype = new ofc_dot_base();
  143. function ofc_pie() {
  144. ofc_element.apply(this, ['pie']);
  145. this.add_animation = function(animation) {
  146. if (!this.animate) {
  147. this.animate = [];
  148. }
  149. this.animate.push(animation);
  150. };
  151. this.set_alpha = function(alpha) {
  152. this.alpha = alpha;
  153. };
  154. this.set_colours = function(colours) {
  155. this.colours = colours;
  156. };
  157. this.set_start_angle = function(start_angle) {
  158. this['start-angle'] = start_angle;
  159. };
  160. this.set_tooltip = function(tip) {
  161. this.tip = tip;
  162. };
  163. this.set_gradient_fill = function() {
  164. this['gradient-fill'] = true;
  165. };
  166. this.set_label_colour = function (label_colour) {
  167. this['label-colour'] = label_colour;
  168. };
  169. this.set_no_labels = function() {
  170. this['no-labels'] = true;
  171. };
  172. this.on_click = function(event) {
  173. this['on-click'] = event;
  174. };
  175. this.radius = function(radius) {
  176. this.radius = radius;
  177. };
  178. }
  179. ofc_pie.prototype = new ofc_element();
  180. function ofc_pie_value(value, label) {
  181. this.value = value;
  182. this.label = label;
  183. this.set_colour = function(colour) {
  184. this.colour = colour;
  185. };
  186. this.set_label = function(label, label_colour, font_size) {
  187. this.label = label;
  188. this['label-colour'] = label_colour;
  189. this['font-size'] = font_size;
  190. };
  191. this.set_tooltip = function(tip) {
  192. this.tip = tip;
  193. };
  194. this.on_click = function(event) {
  195. this['on-click'] = event;
  196. };
  197. this.add_animation = function(animation) {
  198. if (!this.animate) {
  199. this.animate = [];
  200. }
  201. this.animate.push(animation);
  202. };
  203. }
  204. function ofc_base_pie_animation(type) {
  205. this.type = type;
  206. }
  207. function ofc_pie_fade() {
  208. ofc_base_pie_animation.apply(this, ['fade']);
  209. }
  210. ofc_pie_fade.prototype = new ofc_base_pie_animation();
  211. function ofc_pie_bounce(distance) {
  212. ofc_base_pie_animation.apply(this, ['bounce']);
  213. this.distance = distance;
  214. }
  215. ofc_pie_bounce.prototype = new ofc_base_pie_animation();