derailed-ziya 2.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (177) hide show
  1. data/History.txt +0 -0
  2. data/Manifest.txt +405 -0
  3. data/README.txt +232 -0
  4. data/Rakefile +44 -0
  5. data/bin/ziyafy +53 -0
  6. data/charts/AC_RunActiveContent.js +292 -0
  7. data/charts/charts.swf +0 -0
  8. data/charts/charts_library/ar3d.swf +0 -0
  9. data/charts/charts_library/arno.swf +0 -0
  10. data/charts/charts_library/ars3.swf +0 -0
  11. data/charts/charts_library/arst.swf +0 -0
  12. data/charts/charts_library/brfl.swf +0 -0
  13. data/charts/charts_library/brno.swf +0 -0
  14. data/charts/charts_library/brst.swf +0 -0
  15. data/charts/charts_library/buno.swf +0 -0
  16. data/charts/charts_library/cl3d.swf +0 -0
  17. data/charts/charts_library/clfl.swf +0 -0
  18. data/charts/charts_library/clno.swf +0 -0
  19. data/charts/charts_library/clp3.swf +0 -0
  20. data/charts/charts_library/cls3.swf +0 -0
  21. data/charts/charts_library/clst.swf +0 -0
  22. data/charts/charts_library/cnno.swf +0 -0
  23. data/charts/charts_library/dono.swf +0 -0
  24. data/charts/charts_library/lnno.swf +0 -0
  25. data/charts/charts_library/mxno.swf +0 -0
  26. data/charts/charts_library/pi3d.swf +0 -0
  27. data/charts/charts_library/pino.swf +0 -0
  28. data/charts/charts_library/pono.swf +0 -0
  29. data/charts/charts_library/scno.swf +0 -0
  30. data/charts/full_screen.swf +0 -0
  31. data/charts/scripts/output_jpg.php +23 -0
  32. data/charts/sliders/black.swf +0 -0
  33. data/charts/sliders/preview_handle_1.swf +0 -0
  34. data/charts/sliders/preview_handle_2.swf +0 -0
  35. data/gauges/designs/circle.yml +18 -0
  36. data/gauges/designs/signal.yml +14 -0
  37. data/gauges/designs/thermo.yml +119 -0
  38. data/gauges/designs/title.yml +11 -0
  39. data/gauges/gauge.swf +0 -0
  40. data/lib/ziya/charts/area.rb +18 -0
  41. data/lib/ziya/charts/area_threed.rb +16 -0
  42. data/lib/ziya/charts/bar.rb +16 -0
  43. data/lib/ziya/charts/base.rb +510 -0
  44. data/lib/ziya/charts/bubble.rb +18 -0
  45. data/lib/ziya/charts/candle_stick.rb +16 -0
  46. data/lib/ziya/charts/column.rb +16 -0
  47. data/lib/ziya/charts/column_threed.rb +16 -0
  48. data/lib/ziya/charts/donut.rb +18 -0
  49. data/lib/ziya/charts/floating_bar.rb +16 -0
  50. data/lib/ziya/charts/floating_column.rb +16 -0
  51. data/lib/ziya/charts/line.rb +16 -0
  52. data/lib/ziya/charts/mixed.rb +16 -0
  53. data/lib/ziya/charts/parallel_threed_column.rb +16 -0
  54. data/lib/ziya/charts/pie.rb +16 -0
  55. data/lib/ziya/charts/pie_threed.rb +16 -0
  56. data/lib/ziya/charts/polar.rb +16 -0
  57. data/lib/ziya/charts/scatter.rb +16 -0
  58. data/lib/ziya/charts/stacked_area.rb +16 -0
  59. data/lib/ziya/charts/stacked_bar.rb +16 -0
  60. data/lib/ziya/charts/stacked_column.rb +16 -0
  61. data/lib/ziya/charts/stacked_threed_area.rb +16 -0
  62. data/lib/ziya/charts/stacked_threed_column.rb +16 -0
  63. data/lib/ziya/components/area.rb +17 -0
  64. data/lib/ziya/components/axis_category.rb +17 -0
  65. data/lib/ziya/components/axis_ticks.rb +35 -0
  66. data/lib/ziya/components/axis_value.rb +16 -0
  67. data/lib/ziya/components/base.rb +142 -0
  68. data/lib/ziya/components/bevel.rb +15 -0
  69. data/lib/ziya/components/blur.rb +13 -0
  70. data/lib/ziya/components/chart_border.rb +14 -0
  71. data/lib/ziya/components/chart_grid_h.rb +26 -0
  72. data/lib/ziya/components/chart_grid_v.rb +27 -0
  73. data/lib/ziya/components/chart_guide.rb +16 -0
  74. data/lib/ziya/components/chart_label.rb +16 -0
  75. data/lib/ziya/components/chart_pref.rb +22 -0
  76. data/lib/ziya/components/chart_rect.rb +37 -0
  77. data/lib/ziya/components/chart_transition.rb +25 -0
  78. data/lib/ziya/components/circle.rb +16 -0
  79. data/lib/ziya/components/context_menu.rb +15 -0
  80. data/lib/ziya/components/draw.rb +47 -0
  81. data/lib/ziya/components/draw_base.rb +10 -0
  82. data/lib/ziya/components/filter.rb +26 -0
  83. data/lib/ziya/components/glow.rb +14 -0
  84. data/lib/ziya/components/image.rb +17 -0
  85. data/lib/ziya/components/legend.rb +18 -0
  86. data/lib/ziya/components/line.rb +16 -0
  87. data/lib/ziya/components/link.rb +29 -0
  88. data/lib/ziya/components/link_data.rb +18 -0
  89. data/lib/ziya/components/rect.rb +18 -0
  90. data/lib/ziya/components/scroll.rb +26 -0
  91. data/lib/ziya/components/series.rb +16 -0
  92. data/lib/ziya/components/series_color.rb +35 -0
  93. data/lib/ziya/components/series_explode.rb +38 -0
  94. data/lib/ziya/components/shadow.rb +14 -0
  95. data/lib/ziya/components/text.rb +17 -0
  96. data/lib/ziya/components/update.rb +19 -0
  97. data/lib/ziya/gauges/base.rb +172 -0
  98. data/lib/ziya/gauges/radial.rb +18 -0
  99. data/lib/ziya/gauges/signal.rb +138 -0
  100. data/lib/ziya/gauges/support/area.rb +13 -0
  101. data/lib/ziya/gauges/support/base.rb +33 -0
  102. data/lib/ziya/gauges/support/circle.rb +14 -0
  103. data/lib/ziya/gauges/support/design.rb +5 -0
  104. data/lib/ziya/gauges/support/image.rb +12 -0
  105. data/lib/ziya/gauges/support/line.rb +12 -0
  106. data/lib/ziya/gauges/support/link.rb +24 -0
  107. data/lib/ziya/gauges/support/move.rb +15 -0
  108. data/lib/ziya/gauges/support/point.rb +12 -0
  109. data/lib/ziya/gauges/support/polygon.rb +13 -0
  110. data/lib/ziya/gauges/support/radial_base.rb +21 -0
  111. data/lib/ziya/gauges/support/radial_numbers.rb +41 -0
  112. data/lib/ziya/gauges/support/radial_ticks.rb +29 -0
  113. data/lib/ziya/gauges/support/rect.rb +14 -0
  114. data/lib/ziya/gauges/support/rotate.rb +15 -0
  115. data/lib/ziya/gauges/support/scale.rb +15 -0
  116. data/lib/ziya/gauges/support/text.rb +21 -0
  117. data/lib/ziya/gauges/support/update.rb +12 -0
  118. data/lib/ziya/gauges/thermo.rb +121 -0
  119. data/lib/ziya/helpers/base_helper.rb +70 -0
  120. data/lib/ziya/utils/logger.rb +125 -0
  121. data/lib/ziya/utils/text.rb +39 -0
  122. data/lib/ziya/version.rb +15 -0
  123. data/lib/ziya/ziya_helper.rb +374 -0
  124. data/lib/ziya.rb +112 -0
  125. data/spec/charts/base_spec.rb +134 -0
  126. data/spec/charts/chart_type_spec.rb +63 -0
  127. data/spec/components/area_spec.rb +67 -0
  128. data/spec/components/draw_spec.rb +32 -0
  129. data/spec/components/filter_spec.rb +27 -0
  130. data/spec/components/link_spec.rb +22 -0
  131. data/spec/components/series.rb +18 -0
  132. data/spec/components/series_color_spec.rb +39 -0
  133. data/spec/components/series_explode.rb +39 -0
  134. data/spec/components/series_explode_spec.rb +39 -0
  135. data/spec/designs/circle.yml +7 -0
  136. data/spec/designs/crapping_out.yml +8 -0
  137. data/spec/designs/gauge_1.yml +43 -0
  138. data/spec/designs/gauge_2.yml +11 -0
  139. data/spec/designs/gauge_no_name.yml +43 -0
  140. data/spec/designs/gauge_raw.yml +5 -0
  141. data/spec/designs/thermo.yml +13 -0
  142. data/spec/gauges/base_spec.rb +90 -0
  143. data/spec/gauges/signal_spec.rb +36 -0
  144. data/spec/gauges/support/area_spec.rb +40 -0
  145. data/spec/gauges/support/circle_spec.rb +78 -0
  146. data/spec/gauges/support/image_spec.rb +35 -0
  147. data/spec/gauges/support/line_spec.rb +34 -0
  148. data/spec/gauges/support/link_spec.rb +35 -0
  149. data/spec/gauges/support/move_spec.rb +45 -0
  150. data/spec/gauges/support/polygon_spec.rb +36 -0
  151. data/spec/gauges/support/radial_numbers_spec.rb +35 -0
  152. data/spec/gauges/support/radial_ticks_spec.rb +30 -0
  153. data/spec/gauges/support/rotate_spec.rb +45 -0
  154. data/spec/gauges/support/scale_spec.rb +46 -0
  155. data/spec/gauges/support/text_spec.rb +40 -0
  156. data/spec/gauges/thermo_spec.rb +49 -0
  157. data/spec/helpers/base_helper_spec.rb +36 -0
  158. data/spec/spec_helper.rb +10 -0
  159. data/spec/test_helpers/gauge_2_helper.rb +17 -0
  160. data/spec/themes/default/fred.yml +6 -0
  161. data/spec/themes/default/line_chart.yml +6 -0
  162. data/spec/utils/logger_spec.rb +55 -0
  163. data/spec/utils/text_spec.rb +33 -0
  164. data/spec/ziya_helper_spec.rb +117 -0
  165. data/spec/ziya_spec.rb +19 -0
  166. data/tasks/ann.rake +76 -0
  167. data/tasks/annotations.rake +22 -0
  168. data/tasks/doc.rake +48 -0
  169. data/tasks/gem.rake +110 -0
  170. data/tasks/manifest.rake +49 -0
  171. data/tasks/post_load.rake +26 -0
  172. data/tasks/rubyforge.rake +57 -0
  173. data/tasks/setup.rb +227 -0
  174. data/tasks/spec.rake +61 -0
  175. data/tasks/svn.rake +44 -0
  176. data/tasks/test.rake +38 -0
  177. metadata +468 -0
@@ -0,0 +1,47 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Sets up a drawing area on the chart to draw text, rect, circles...
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/ziya_helper'
7
+
8
+ module Ziya::Components
9
+ # Sets up a drawing area on the chart to draw text, rect, circles...
10
+ #
11
+ # Holds any number of elements to draw. A draw element can be a circle, image (JPEG or SWF),
12
+ # line, rectangle, or text. Use draw "image" to include SWF flash file with animation,
13
+ # roll-over buttons, sounds, scripts, etc.
14
+ #
15
+ # <tt></tt>:
16
+ #
17
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=draw
18
+ # for additional documentation, examples and futher detail.
19
+ #
20
+ class Draw < Base
21
+ include Ziya::Helper
22
+
23
+ has_attribute :components
24
+
25
+
26
+ # -------------------------------------------------------------------------
27
+ # Dump has_attribute into xml element
28
+ def flatten( xml, composite_urls=nil )
29
+ if components
30
+ xml.draw do
31
+ components.each { |comp| comp.flatten( xml ) }
32
+ gen_composites( xml, composite_urls ) if composite_urls
33
+ end
34
+ end
35
+ end
36
+
37
+ # -------------------------------------------------------------------------
38
+ # Generates Draw component for composite charts
39
+ def gen_composites( xml, composite_urls )
40
+ # chart_path = chart_path
41
+ for url in composite_urls do
42
+ # xml.image( :url => composite_url % [ chart_path, chart_path, url] )
43
+ xml.image( :url => gen_composite_path( chart_path, url ) )
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,10 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draw base class for all draw components
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ class DrawBase < Base # :nodoc:
8
+ has_attribute :shadow, :bevel, :glow, :blur
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Sets various filters for enhancing charts look and feel
3
+ #
4
+ # Holds any number of filters. such as bevel, shadow etc. You must specify
5
+ # and id so that other drawable component can use the filters
6
+ #
7
+ # Author:: Fernand
8
+ # -----------------------------------------------------------------------------
9
+ module Ziya::Components
10
+ # Specifies the various filters that can be reused across components ie blur, bevel, glow, etc...
11
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=filter
12
+ # for additional documentation, examples and futher detail.
13
+ class Filter < Base
14
+ has_attribute :filters
15
+
16
+ # -------------------------------------------------------------------------
17
+ # Dump has_attribute into xml element
18
+ def flatten( xml )
19
+ if filters
20
+ xml.filter do
21
+ filters.each { |comp| comp.flatten( xml ) }
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,14 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Create a glow filter
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ # Specifies the glow filter to be applied to some component ie chart_rect, axis_value, etc...
8
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=filter
9
+ # for additional documentation, examples and futher detail.
10
+ class Glow < Base
11
+ has_attribute :id, :color, :alpha, :blurX, :blurY, :strength, :quality,
12
+ :inner, :knockout
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draw an image on a chart. Can also be used to reference another chart and
3
+ # embed it in the current chart. (See XML/SWF docs for composite charts )
4
+ #
5
+ # Author:: Fernand Galiana
6
+ # Date:: Dec 15th, 2006
7
+ # -----------------------------------------------------------------------------
8
+ module Ziya::Components
9
+ # Renders the specified image (jpg/gif) on the chart. Must be set up within the draw
10
+ # component.
11
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=draw
12
+ # for additional documentation, examples and futher detail.
13
+ class Image < Base
14
+ has_attribute :layer, :transition, :delay, :duration, :url, :x, :y, :width,
15
+ :height, :rotation, :alpha, :bevel, :glow, :blur, :timeout, :retry
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Sets up chart legend location
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ # Renders a legend on the chart
8
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=legend
9
+ # for additional documentation, examples and futher detail.
10
+
11
+ class Legend < Base
12
+ has_attribute :transition, :delay, :duration,
13
+ :x, :y, :width, :height,
14
+ :toggle, :layout, :margin, :bullet, :font, :bold, :size, :color, :alpha,
15
+ :fill_color, :fill_alpha, :line_color, :line_alpha, :line_thickness,
16
+ :shadow, :bevel, :glow, :blur
17
+ end
18
+ end
@@ -0,0 +1,16 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draw a line on a chart
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ # Line component to draw a line on the chart. Must be set up within the draw
8
+ # component.
9
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=draw
10
+ # for additional documentation, examples and futher detail.
11
+ class Line < Base
12
+ has_attribute :layer, :transition, :delay, :duration, :x1, :y1, :x2, :y2,
13
+ :line_color,:line_alpha, :line_thickness,
14
+ :bevel, :glow, :blur, :shadow
15
+ end
16
+ end
@@ -0,0 +1,29 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Sets up clickable areas on the chart.
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ # Sets up clickable areas on the chart.
8
+ #
9
+ # Holds any number of areas, each defining a rectangle and a URL to go to when the user
10
+ # clicks inside the rectangle. This can also be used to make refresh or print buttons.
11
+ #
12
+ # <tt></tt>:
13
+ #
14
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=link
15
+ # for additional documentation, examples and futher detail.
16
+ class Link < Base
17
+ has_attribute :areas
18
+
19
+ # -------------------------------------------------------------------------
20
+ # Dump has_attribute into xml element
21
+ def flatten( xml )
22
+ if areas
23
+ xml.link do
24
+ areas.each { |area| area.flatten( xml ) }
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Sets up a handler for clickable chart elements
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ # Sets the URL of a script responsible for processing clicks on chart elements.
8
+ # This enables drilling down into charts.
9
+ #
10
+ # <tt></tt>:
11
+ #
12
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=link_data
13
+ # for additional documentation, examples and futher detail.
14
+ #
15
+ class LinkData < Base
16
+ has_attribute :url, :target, :timeout, :retry, :spinning_wheel
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draw a rectangle on a chart
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ # Rect component to draw a rectangle on the chart. Must be set up within the draw
8
+ # component.
9
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=draw
10
+ # for additional documentation, examples and futher detail.
11
+ class Rect < Base
12
+ has_attribute :layer, :transition, :delay, :duration, :x, :y, :width,
13
+ :height, :fill_color, :fill_alpha, :line_color, :line_alpha,
14
+ :line_thickness,
15
+ :corner_tl, :corner_tr, :corner_bl, :corner_br,
16
+ :shadow, :bevel, :blur, :bevel
17
+ end
18
+ end
@@ -0,0 +1,26 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Embeds a scroller in a given chart
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # Date:: Dec 15th, 2006
6
+ # -----------------------------------------------------------------------------
7
+ require 'ziya/components/base'
8
+
9
+ module Ziya::Components
10
+ # Specifies the ability to scroll a chart by setting single or double sliders
11
+ # on the chart.
12
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=scroll
13
+ # for additional documentation, examples and futher detail.
14
+ #
15
+ class Scroll < Base
16
+ has_attribute :x, :y, :width, :height, :alpha,
17
+ :transition, :delay, :duration,
18
+ :url_button_1_idle, :url_button_1_over, :url_button_1_press,
19
+ :url_button_2_idle, :url_button_2_over, :url_button_2_press,
20
+ :url_slider_body, :url_slider_handle_1, :url_slider_handle_2,
21
+ :button_length, :slider_handle_length, :gap, :button_speed,
22
+ :buttons_together, :start, :span, :drag, :reverse_handle,
23
+ :scroll_detail, :stop_detail,
24
+ :timeout, :retry
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Refines series attributes on a chart
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/components/base'
7
+
8
+ module Ziya::Components
9
+ # Specifies the gap betwen cols/bars and gap between series for column and bar
10
+ # charts only.
11
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=series
12
+ # for additional documentation, examples and futher detail.
13
+ class Series < Base
14
+ has_attribute :bar_gap, :set_gap, :transfer
15
+ end
16
+ end
@@ -0,0 +1,35 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Sets up chart elements color
3
+ #
4
+ # Sets the colors to use for the chart series.
5
+ #
6
+ # <tt></tt>:
7
+ #
8
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=series_color
9
+ # for additional documentation, examples and futher detail.
10
+ #
11
+ # Author:: Fernand Galiana
12
+ # Date:: Dec 15th, 2006
13
+ # -----------------------------------------------------------------------------
14
+ module Ziya::Components
15
+ class SeriesColor < Base
16
+ has_attribute :colors
17
+
18
+ # -------------------------------------------------------------------------
19
+ # Dump has_attribute into xml element
20
+ def flatten( xml )
21
+ unless colors.nil?
22
+ xml.series_color do
23
+ if colors.is_a? String
24
+ cols = colors.split( "," )
25
+ cols.each { |c| xml.color( c.strip ) }
26
+ elsif colors.respond_to? :each
27
+ colors.each { |c| xml.color( c ) }
28
+ else
29
+ xml.color( colors )
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,38 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Sets up the 'exploding' factor on a particular chart. Only applies to pie,
3
+ # scattered and line charts.
4
+ #
5
+ # Applies to pie, line, and scatter charts only. In pie charts, it sets which pie wedge
6
+ # separates from the pie for emphasis. In line and scatter charts, it sets which line or
7
+ # point is increased in thickness or size for emphasis.
8
+ #
9
+ # <tt></tt>:
10
+ #
11
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=series_explode
12
+ # for additional documentation, examples and futher detail.
13
+ #
14
+ # Author:: Fernand Galiana
15
+ # Date:: Dec 15th, 2006
16
+ # -----------------------------------------------------------------------------
17
+ module Ziya::Components
18
+ class SeriesExplode < Base
19
+ has_attribute :numbers
20
+
21
+ # -------------------------------------------------------------------------
22
+ # Dump has_attribute into xml element
23
+ def flatten( xml )
24
+ if numbers
25
+ xml.series_explode do
26
+ if numbers.is_a? String
27
+ nums = numbers.split( "," )
28
+ nums.each { |n| xml.number( n.strip ) }
29
+ elsif numbers.respond_to? :each
30
+ numbers.each { |n| xml.number( n ) }
31
+ else
32
+ xml.number( numbers )
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,14 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Create a shadow filter
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ # Specifies the shadow filter to be applied to some component ie chart_rect, axis_value, etc...
8
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=filter
9
+ # for additional documentation, examples and futher detail.
10
+ class Shadow < Base
11
+ has_attribute :id, :distance, :angle, :color, :alpha,
12
+ :blurX, :blurY, :strength, :quality, :inner, :knockout, :hideObject
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws some text on a chart
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # Date:: Dec 15th, 2006
6
+ # -----------------------------------------------------------------------------
7
+ module Ziya::Components
8
+ # Text component to draw text on the chart. Must be set up within the draw
9
+ # component.
10
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=draw
11
+ # for additional documentation, examples and futher detail.
12
+ class Text < Base
13
+ has_attribute :layer, :transition, :delay, :duration, :x, :y, :width,
14
+ :height, :h_align, :v_align, :rotation, :font, :bold, :size,
15
+ :color, :alpha, :shadow, :bevel, :glow, :blur, :text
16
+ end
17
+ end
@@ -0,0 +1,19 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Sets up handler for refresh the chart content. The refresh xml can only refresh
3
+ # parts of the chart that have changed.
4
+ #
5
+ # Author:: Fernand Galiana
6
+ # -----------------------------------------------------------------------------
7
+ module Ziya::Components
8
+ # Updates the chart at intervals, without reloading the web page. This makes it possible
9
+ # to display charts with live data, change the chart's look over time for emphasis, or
10
+ # create a slideshow from different charts.
11
+ #
12
+ # <tt></tt>:
13
+ #
14
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=live_update
15
+ # for additional documentation, examples and futher detail.
16
+ class Update < Base
17
+ has_attribute :url, :delay, :timeout, :retry, :mode, :span
18
+ end
19
+ end
@@ -0,0 +1,172 @@
1
+ module Ziya::Gauges
2
+ class Base
3
+ include Ziya::Helpers::BaseHelper
4
+
5
+ attr_accessor :license, :design_id
6
+ attr_reader :type, :components
7
+ attr_reader :options
8
+
9
+ def initialize( license, design_id )
10
+ @license = license
11
+ @design_id = design_id
12
+
13
+ # load up associated helper
14
+ loaded = load_helper( Ziya.helpers_dir ) if Ziya.helpers_dir
15
+ Ziya.logger.warn( ">>> ZiYa -- no helper for gauge `#{design_id}" ) unless loaded
16
+
17
+ # init defaults
18
+ @options = default_options
19
+ end
20
+
21
+ # -------------------------------------------------------------------------
22
+ # provides for overiding basic functionality
23
+ #
24
+ # <tt>gauge_color</tt>:: Legend color
25
+ # <tt>legend_color</tt>:: Gauge color
26
+ def set_preferences( opts={} )
27
+ options.merge!( opts )
28
+ end
29
+
30
+ # -------------------------------------------------------------------------
31
+ # render gauge to xml
32
+ def to_xml
33
+ render_xml
34
+ end
35
+
36
+ # =========================================================================
37
+ protected
38
+
39
+ # inject update behavior
40
+ def render_extra_components
41
+ if options[:url]
42
+ Ziya::Gauges::Support::Update.new(
43
+ :url => options[:url],
44
+ :retry => options[:retry] || 0,
45
+ :timeout => options[:timeout] || 30,
46
+ :delay_type => options[:delay_type] || 1,
47
+ :delay => options[:delay] || 30 ).flatten( @xml )
48
+ end
49
+ end
50
+
51
+ # -------------------------------------------------------------------------
52
+ # setup thermometer default options
53
+ def default_options
54
+ {
55
+ :x => 20,
56
+ :y => 20,
57
+ :gauge_color => "ff0000",
58
+ :legend_color => "cc0000",
59
+ }
60
+ end
61
+
62
+ # =========================================================================
63
+ private
64
+
65
+ # retrieve bundled design directory
66
+ def bundled_designs_dir
67
+ Ziya.path( %w[gauges designs] )
68
+ end
69
+
70
+ # -----------------------------------------------------------------------
71
+ # Load up ERB style helpers
72
+ def load_helper( helper_dir )
73
+ Dir.foreach(helper_dir) do |helper_file|
74
+ unless helper_file =~ /^(#{design_id}_helper).rb$/ or helper_file =~ /^(base_helper).rb$/
75
+ next
76
+ end
77
+ Ziya.logger.info( ">>> ZiYa loading custom helper `#{$1}" )
78
+ # BOZO !! This will only work in rails ??
79
+ if defined? RAILS_ROOT
80
+ require_dependency File.join(helper_dir, $1)
81
+ else
82
+ require File.join(helper_dir, $1)
83
+ end
84
+ helper_module_name = "Ziya::" + $1.gsub(/(^|_)(.)/) { $2.upcase }
85
+ # helper_module_name = $1.to_s.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
86
+ Ziya.logger.debug( "Include module #{helper_module_name}")
87
+ Ziya::Gauges::Base.class_eval("include #{helper_module_name}")
88
+ true
89
+ end
90
+ false
91
+ end
92
+
93
+ # -----------------------------------------------------------------------
94
+ # merge components with user overrides
95
+ def merge_comps( original, override )
96
+ override.each do |k,v|
97
+ if original.has_key? k
98
+ original[k] = v
99
+ else
100
+ original << [k,v]
101
+ end
102
+ end
103
+ end
104
+
105
+ # -----------------------------------------------------------------------
106
+ # renders design components
107
+ def render_components
108
+ # First check bundled design dir for std design
109
+ std_design = inflate( self, bundled_designs_dir, design_id )
110
+ # Now check for user overrides
111
+ usr_design = inflate( self, Ziya.designs_dir, design_id )
112
+
113
+ design = usr_design
114
+ if std_design and usr_design
115
+ design = std_design
116
+ merge_comps( design.components, usr_design.components )
117
+ # design.components.merge!( usr_design.components )
118
+ elsif std_design
119
+ design = std_design
120
+ end
121
+ # Ziya.logger.debug "!!!! Design\n#{design.to_yaml}"
122
+ # flatten components to xml
123
+ design.components.each do |name, value|
124
+ # Ziya.logger.debug "Processing #{name}"
125
+ value.flatten( @xml )
126
+ end
127
+ end
128
+
129
+ # -----------------------------------------------------------------------
130
+ # renders chart to xml
131
+ def render_xml
132
+ @xml = Builder::XmlMarkup.new
133
+ @xml.gauge do
134
+ @xml.license( @license ) unless @license.nil?
135
+ render_extra_components
136
+ render_components
137
+ end
138
+ @xml.to_s.gsub( /<to_s\/>/, '' )
139
+ end
140
+
141
+ # -----------------------------------------------------------------------
142
+ # Parse erb template if any
143
+ def erb_render( yml )
144
+ # b = binding
145
+ ERB.new( yml ).result binding
146
+ end
147
+
148
+ # -----------------------------------------------------------------------
149
+ # Load yaml file associated with class if any
150
+ def inflate( clazz, designs_dir, design )
151
+ class_name = underscore( demodulize( clazz.to_s ) )
152
+ begin
153
+ file_name = "#{designs_dir}/#{design}.yml"
154
+ Ziya.logger.debug ">>> ZiYa attempt to load design file '#{file_name}"
155
+ return nil unless File.exists?( file_name )
156
+ yml = IO.read( file_name )
157
+ # Ziya.logger.debug ">>> Unprocessed yaml...\n#{yml}\n"
158
+ processed = erb_render( yml )
159
+ # Ziya.logger.debug ">>> Processed yaml...\n#{processed}"
160
+ load = YAML::load( processed )
161
+ Ziya.logger.info ">>> ZiYa successfully loaded design file `#{file_name}"
162
+ return load
163
+ rescue SystemCallError => boom
164
+ Ziya.logger.error boom
165
+ rescue => bang
166
+ Ziya.logger.error ">>> ZiYa -- Error encountered loading design file `#{file_name} -- #{bang}"
167
+ bang.backtrace.each { |l| Ziya.logger.error( l ) }
168
+ end
169
+ nil
170
+ end
171
+ end
172
+ end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Abstract class representing a radial based gauge
3
+ #
4
+ # Author: Fernand
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Gauges
7
+ class Radial < Base
8
+
9
+ # =========================================================================
10
+ protected
11
+
12
+ # converts degrees to radiants
13
+ def deg2rad( degrees )
14
+ degrees * Math::PI / 180
15
+ end
16
+
17
+ end
18
+ end