derailed-ziya 2.0.6 → 2.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/Manifest.txt +59 -2
  2. data/README.txt +63 -54
  3. data/Rakefile +2 -2
  4. data/charts/charts.swf +0 -0
  5. data/charts/charts_library/ar3d.swf +0 -0
  6. data/charts/charts_library/arno.swf +0 -0
  7. data/charts/charts_library/ars3.swf +0 -0
  8. data/charts/charts_library/arst.swf +0 -0
  9. data/charts/charts_library/brfl.swf +0 -0
  10. data/charts/charts_library/brno.swf +0 -0
  11. data/charts/charts_library/brst.swf +0 -0
  12. data/charts/charts_library/buno.swf +0 -0
  13. data/charts/charts_library/cl3d.swf +0 -0
  14. data/charts/charts_library/clfl.swf +0 -0
  15. data/charts/charts_library/clim.swf +0 -0
  16. data/charts/charts_library/clno.swf +0 -0
  17. data/charts/charts_library/clp3.swf +0 -0
  18. data/charts/charts_library/cls3.swf +0 -0
  19. data/charts/charts_library/clst.swf +0 -0
  20. data/charts/charts_library/cnno.swf +0 -0
  21. data/charts/charts_library/dono.swf +0 -0
  22. data/charts/charts_library/lnno.swf +0 -0
  23. data/charts/charts_library/mxno.swf +0 -0
  24. data/charts/charts_library/pi3d.swf +0 -0
  25. data/charts/charts_library/piim.swf +0 -0
  26. data/charts/charts_library/pino.swf +0 -0
  27. data/charts/charts_library/pono.swf +0 -0
  28. data/charts/charts_library/scno.swf +0 -0
  29. data/charts/themes/readme.txt +13 -0
  30. data/lib/ziya/charts/base.rb +124 -182
  31. data/lib/ziya/charts/custom.rb +18 -0
  32. data/lib/ziya/charts/image_column.rb +18 -0
  33. data/lib/ziya/charts/image_pie.rb +18 -0
  34. data/lib/ziya/components/area.rb +2 -3
  35. data/lib/ziya/components/button.rb +18 -0
  36. data/lib/ziya/components/chart_guide.rb +4 -2
  37. data/lib/ziya/components/chart_note.rb +18 -0
  38. data/lib/ziya/components/draw.rb +4 -6
  39. data/lib/ziya/components/flash_to_javascript.rb +25 -0
  40. data/lib/ziya/components/tooltip.rb +20 -0
  41. data/lib/ziya/helpers/base_helper.rb +4 -4
  42. data/lib/ziya/version.rb +1 -1
  43. data/lib/ziya/ziya_helper.rb +32 -19
  44. data/release_notes.txt +10 -0
  45. data/spec/charts/base_spec.rb +7 -6
  46. data/spec/charts/chart_type_spec.rb +8 -0
  47. data/spec/components/draw_spec.rb +9 -4
  48. data/spec/ziya_helper_spec.rb +1 -1
  49. data/tasks/doc.rake +12 -7
  50. metadata +132 -3
@@ -5,6 +5,8 @@
5
5
  #
6
6
  # TODO !! Match helpers with chart class name
7
7
  # TODO !! Add accessor for specifying refresh look and data links on comps
8
+ # TODO Figure out the equiv require_dep for merb if any ??
9
+ # TODO Refact and clean up.
8
10
  #
9
11
  # Author:: Fernand Galiana
10
12
  # Date:: Dec 15th, 2006
@@ -12,29 +14,47 @@
12
14
  require 'ziya/helpers/base_helper'
13
15
  require 'yaml'
14
16
 
15
- # TODO Figure out the equiv require_dep for merb if any ??
16
- # TODO Refact and clean up.
17
17
  module Ziya::Charts
18
- # The mother ship of all charts. This class figures out how to generate the
19
- # correct xml to render the chart on the client side. This class handles loading
20
- # style sheets and chart helper for the helper directory specified during
21
- # initialization.
18
+ # The mother ship of all charts. This abstract class figures out how to generate the
19
+ # correct xml to render the chart on the client side. It handles loading the look
20
+ # and feel via associated stylesheets. In order to customize the chart look and feel,
21
+ # you must create a theme directory in your application public/charts/themes dir. And
22
+ # reference it via the #add method using the :theme directive.
22
23
  class Base
23
- # blee blee
24
24
  include Ziya::Helpers::BaseHelper
25
25
 
26
26
  # =========================================================================
27
27
  protected
28
28
  # defines the various chart components
29
29
  def self.declare_components # :nodoc:
30
- @components = [
31
- :axis_category, :axis_ticks, :axis_value,
32
- :chart_rect, :chart_border, :chart_grid_h, :chart_grid_v,
33
- :chart_transition, :chart_label, :chart_guide, :legend,
34
- :filter, :draw,
35
- :series_color, :series, :series_explode,
36
- :chart_pref, :scroll,
37
- :update, :link_data, :link, :context_menu]
30
+ @components =
31
+ [
32
+ :axis_category,
33
+ :axis_ticks,
34
+ :axis_value,
35
+ :chart_rect,
36
+ :chart_border,
37
+ :chart_grid_h,
38
+ :chart_grid_v,
39
+ :chart_note,
40
+ :tooltip,
41
+ :chart_transition,
42
+ :chart_label,
43
+ :chart_guide,
44
+ :legend,
45
+ :filter,
46
+ :flash_to_javascript,
47
+ :draw,
48
+ :series_color,
49
+ :series,
50
+ :series_explode,
51
+ :chart_pref,
52
+ :scroll,
53
+ :update,
54
+ :link_data,
55
+ :link,
56
+ :context_menu
57
+ ]
38
58
  @components.each { |a| attr_accessor a }
39
59
  end
40
60
  declare_components
@@ -46,15 +66,16 @@ module Ziya::Charts
46
66
  attr_reader :type # :nodoc:
47
67
 
48
68
  # create a new chart.
49
- # <tt>:license</tt>:: the XML/SWF charts license
50
- # <tt>:chart_id</tt>:: the name of the chart style sheet.
69
+ # <tt>license</tt> -- the XML/SWF charts license
70
+ # <tt>chart_id</tt> -- the name of the chart style sheet.
51
71
  # NOTE: If chart_id is specified the framework will attempt to load the chart styles
52
72
  # from public/themes/theme_name/chart_id.yml
53
- def initialize( license=nil, chart_id=nil )
73
+ def initialize( license=nil, chart_id=nil ) # :nodoc:
54
74
  @id = chart_id
55
75
  @license = license
56
76
  @options = {}
57
77
  @series_desc = []
78
+ @annotations = []
58
79
  @theme = default_theme
59
80
  @render_mode = Base.mode_reset
60
81
  initialize_components
@@ -66,20 +87,22 @@ module Ziya::Charts
66
87
  @components
67
88
  end
68
89
 
69
- # don't render stylesheets just gen code for chart stylesheet and data
70
- def self.mode_data() 1; end
90
+ # don't load stylesheets just gen code for chart..
91
+ def self.mode_data() #:nodoc:
92
+ 1
93
+ end
71
94
 
72
95
  # renders everything
73
- def self.mode_reset() 0; end
96
+ def self.mode_reset #:nodoc:
97
+ 0
98
+ end
74
99
 
75
- # -------------------------------------------------------------------------
76
- # Default ZiYa theme
100
+ # default ZiYa theme
77
101
  def default_theme # :nodoc:
78
102
  File.join( Ziya.themes_dir, %w[default] )
79
103
  end
80
104
 
81
- # -------------------------------------------------------------------------
82
- # Load up ERB style helpers
105
+ # load up ERB style helpers
83
106
  def load_helpers( helper_dir ) # :nodoc:
84
107
  Dir.foreach(helper_dir) do |helper_file|
85
108
  next unless helper_file =~ /^([a-z][a-z_]*_helper).rb$/
@@ -99,48 +122,46 @@ module Ziya::Charts
99
122
  end
100
123
  end
101
124
 
102
- # Add chart components such as x and y axis labels, data points and chart
103
- # labels.
125
+ # Add chart components to a given chart.
104
126
  #
105
- # Example:
106
- # my_chart = Ziya::Charts::Bar.new
107
- # my_chart.add( :axis_category_text, ['2004', '2005', '2006'] )
108
- # my_chart.add( :axis_category_label, [ '10 dogs', '20 cats', '30 rats'] )
109
- # my_chart.add( :series, 'series A', [ 10, 20, 30] )
110
- # my_chart.add( :axis_value_label, [ 'my dogs', 'my cats', 'my rats'] )
111
- # my_chart.add( :user_data, :mykey, "Fred" )
112
- #
113
- # This will display a bar chart with x axis ticks my dogs, my cats, my fox and
114
- # y axis values 2004, 2005, 2006. The labels on the bars will read 10 dogs,
115
- # 20 cats, 30 rats
116
- #
117
127
  # The <tt>args</tt> must contain certain keys for the chart
118
- # to be display correctly. The keys are defined as follows:
119
- # <tt>:axis_category_text</tt>:: Array of strings representing the x/y axis
120
- # ticks dependending on the chart type. This
121
- # value is required.
122
- # <tt>:axis_category_label</tt>:: Array of strings representing the x axis
123
- # labels. This is supported only for Scatter and Bubble charts.
124
- # This value is optional. Specify nil for no label change.
125
- # <tt>:series</tt>:: Specifies the series name and chart data points.
126
- # The series name will be used to display chart legends.
127
- # You must have at least one of these tag defined.
128
- # You may also specify an array of strings to identifies the
129
- # custom labels that will be used on top of the chart
130
- # elements
131
- # <tt>:axis_value_label</tt>:: Array of strings representing the ticks on the x/y
132
- # axis depending on the chart type. This is symmetrical
133
- # to the <tt>axis_category_label</tt> tag for the opposite
134
- # chart axis. Specify nil for no label change.
135
- # <tt>:user_data</tt>:: Used to make user data available to the ERB templates in
136
- # the chart stylesheet yaml file. You must specify a key symbol
137
- # and an ad-hoc value. The key will be used with the @options
138
- # hash to access the user data.
139
- # <tt>:composites</tt>:: Embeds multiple charts within the given chart via the draw image component.
140
- # <tt>:chart_types</tt>:: Specify the chart types per series. This option should
141
- # only be used with Mixed Charts !!
142
- # <tt>:theme</tt>:: Specify the use of a given theme
128
+ # to be displayed correctly.
129
+ #
130
+ # === Directives
131
+ # * <tt>:axis_category_text</tt> -- Array of strings representing the x/y
132
+ # axis ticks dependending on the chart type. This value is required.
133
+ # In an x/y axis chart setup the category is the x axis unless the chart is
134
+ # a bar chart.
135
+ # * <tt>:axis_category_label</tt> -- Array of strings representing the x axis
136
+ # labels. This is supported only for Scatter and Bubble charts.
137
+ # This value is optional. Specify nil for no label change.
138
+ # * <tt>:series</tt> -- Specifies the series name and chart data points as an array.
139
+ # The series name will be used to display chart legends. You must have at least one
140
+ # of these tag defined. The data values may be specified as a straight up array of
141
+ # strings or numbers but also as an array of hash representing the data points and
142
+ # their attributes such as note, label, tooltip, effect, etc..
143
+ # * <tt>:axis_value_label</tt> -- Array of strings representing the ticks on the x/y
144
+ # axis depending on the chart type. This is symmetrical to the <tt>axis_category_label</tt>
145
+ # tag for the opposite chart axis. Specify nil for no label change.
146
+ # * <tt>:user_data</tt>:: -- Used to make user data available to the ERB templates in
147
+ # the chart stylesheet yaml file. You must specify a key symbol and an ad-hoc value.
148
+ # The key will be used with the @options hash to access the user data.
149
+ # * <tt>:composites</tt> -- Embeds multiple charts within the given chart via the
150
+ # draw image component. You must specify a hash of chart_id/url pairs.
151
+ # * <tt>:chart_types</tt> -- Specify the chart types per series. This option should
152
+ # only be used with Mixed Charts !!
153
+ # * <tt>:theme</tt> -- Specify the use of a given named theme. The named theme must
154
+ # reside in a directory named equaly under your application public/charts/themes.
143
155
  #
156
+ # === Examples
157
+ # Setup the category axis to with 3 ticks namely 2004, 2005, 2006
158
+ # my_chart.add( :axis_category_text, ['2004', '2005', '2006'] )
159
+ #
160
+ # Plain old series with integer data points
161
+ # my_chart.add( :series, "series A", [ 10, 20, 30] )
162
+ # Specifying custom series labels. You may specify the following attributes in the data point
163
+ # hash : :note, :label, :tooltip and effects such as :shadow, :glow, etc...
164
+ # my_chart.add( :series, "series A", [ { :value => 10, :label => 'l1' }, { :value => 20, :label => 'l2' } ] )
144
165
  def add( *args )
145
166
  # TODO Validation categories = series, series = labels, etc...
146
167
  directive = args.shift
@@ -148,15 +169,17 @@ module Ziya::Charts
148
169
  when :axis_category_text
149
170
  categories = args.first.is_a?(Array) ? args.shift : []
150
171
  raise ArgumentError, "Must specify an array of categories" if categories.empty?
151
- categories.insert( 0, nil )
152
- @options[directive] = categories
172
+ # don't side effect the passed in categs
173
+ categs = categories.clone
174
+ categs.insert( 0, nil )
175
+ @options[directive] = categs
153
176
  when :axis_category_label
154
177
  labels = args.first.is_a?(Array) ? args.shift : []
155
178
  raise ArgumentError, "Must specify an array of category labels" if labels.empty?
156
179
  @options[directive] = labels
157
180
  when :composites
158
- composites = args.first.is_a?(Array) ? args.shift: []
159
- raise ArgumentError, "Must specify an array of urls for the composite chart(s)" if composites.empty?
181
+ composites = args.first.is_a?(Hash) ? args.shift: []
182
+ raise ArgumentError, "Must specify a hash of id => url pairs for the composite chart(s)" if composites.empty?
160
183
  @options[directive] = composites
161
184
  when :axis_value_label
162
185
  values = args.first.is_a?(Array) ? args.shift : []
@@ -168,8 +191,10 @@ module Ziya::Charts
168
191
  if args.first.is_a?( Array )
169
192
  points = args.shift || []
170
193
  raise ArgumentError, "Must specify an array of data points" if points.empty?
171
- points.insert( 0, legend )
172
- series[:points] = points
194
+ # don't side effect the passed in series
195
+ pts = points.clone
196
+ pts.insert( 0, legend )
197
+ series[:points] = pts
173
198
  else
174
199
  raise ArgumentError, "Must specify an array of data points"
175
200
  end
@@ -233,8 +258,7 @@ module Ziya::Charts
233
258
  # =========================================================================
234
259
  private
235
260
 
236
- # -------------------------------------------------------------------------
237
- # Inflate object state based on object hierarchy
261
+ # inflate object state based on object hierarchy
238
262
  def setup_state( state )
239
263
  override = self.class.name == state.class.name
240
264
  Base.components.each do |comp|
@@ -242,8 +266,7 @@ module Ziya::Charts
242
266
  end
243
267
  end
244
268
 
245
- # -------------------------------------------------------------------------
246
- # Load yaml file associated with class if any
269
+ # load yaml file associated with class if any
247
270
  def inflate( clazz, theme, instance=nil )
248
271
  class_name = underscore(clazz.to_s.gsub( /Ziya::Charts/, '' )).gsub( /\//, '' )
249
272
  class_name += '_chart' unless class_name.match( /.?_chart$/ )
@@ -265,104 +288,28 @@ module Ziya::Charts
265
288
  nil
266
289
  end
267
290
 
268
- # -------------------------------------------------------------------------
269
- # Parse erb template if any
291
+ # parse erb template if any
270
292
  def erb_render(fixture_content)
271
293
  b = binding
272
294
  ERB.new(fixture_content).result b
273
295
  end
274
296
 
275
- # -------------------------------------------------------------------------
276
- # Generates xml element for given data set
277
- # TODO Lame ! Refact...
278
- def gen_data_points( series_name, labels=nil )
279
- values = @options[series_name]
280
- labels.insert( 0, nil ) if labels
297
+ # generates category axis data points
298
+ def gen_axis_category
299
+ categories = @options[:axis_category_text]
281
300
  @xml.row do
282
- if values.respond_to? :each
283
- values.each do |c|
284
- if c.nil?
285
- @xml.null
286
- elsif c.instance_of? String
287
- if labels and !labels.empty?
288
- label = labels.shift
289
- if label
290
- @xml.string( :label => label ) { |x| x.text!( c ) }
291
- else
292
- @xml.string( c )
293
- end
294
- else
295
- @xml.string( c )
296
- end
297
- elsif c.respond_to? :zero?
298
- if labels and !labels.empty?
299
- label = labels.shift
300
- if label
301
- @xml.number( :label => label ) { |x| x.text!( c.to_s ) }
302
- else
303
- @xml.number( c )
304
- end
305
- else
306
- @xml.number( c )
307
- end
308
- end
301
+ categories.each do |category|
302
+ case
303
+ when category.nil? : @xml.null
304
+ when category.instance_of?(String) : @xml.string( category )
305
+ when category.respond_to?(:zero?) : @xml.number( category )
306
+ when category.is_a?(Hash) : categ = category.clone;gen_row_data( categ.delete( :value ), categ, @xml )
307
+ else puts "No match"
309
308
  end
310
- else
311
- @xml.string( values )
312
309
  end
313
- end
310
+ end
314
311
  end
315
312
 
316
- # # -------------------------------------------------------------------------
317
- # # Generates custom axis values
318
- # def gen_axis_value_text( values )
319
- # return if values.nil? or values.empty?
320
- # @xml.axis_value_text do
321
- # values.each { |v| @xml.string( v ) }
322
- # end
323
- # end
324
-
325
- # # -------------------------------------------------------------------------
326
- # # Check if the series are named
327
- # def named_series?( names )
328
- # names.each do |name|
329
- # next unless name.to_s.index( 'series_' )
330
- # return @options[name][0].instance_of?(String) if @options[name] and !@options[name].empty?
331
- # end
332
- # false
333
- # end
334
-
335
- # # -------------------------------------------------------------------------
336
- # # Check if the options have custom labels ie :label_xxx tag
337
- # def has_labels( names )
338
- # names.each do |name|
339
- # next unless name.to_s.index( 'labels_' )
340
- # return @options[name].size if @options[name] and !@options[name].empty?
341
- # end
342
- # 0
343
- # end
344
-
345
- # # -------------------------------------------------------------------------
346
- # # Generates custom labels
347
- # def gen_labels( series_name, is_default=false )
348
- # cltn = @options[series_name]
349
- # cltn.insert( 0, nil ) unless is_default
350
- # @xml.row do
351
- # cltn.each { |c| ((c.nil? or c.to_s.empty?) ? @xml.null : @xml.string( c )) }
352
- # end
353
- # end
354
-
355
- # # ------------------------------------------------------------------------
356
- # # Generates default series labels
357
- # def gen_default_labels( size )
358
- # labels = []
359
- # size.times { |i| labels << nil }
360
- # @xml.row do
361
- # labels.each { |c| @xml.null }
362
- # end
363
- # end
364
-
365
- # ------------------------------------------------------------------------
366
313
  # generates chart data row
367
314
  # TODO Validate options !!
368
315
  def gen_row_data( value, opts=nil, xml=@xml )
@@ -373,19 +320,16 @@ module Ziya::Charts
373
320
  end
374
321
  end
375
322
 
376
- # -------------------------------------------------------------------------
377
323
  # generates string chart_value
378
324
  def gen_string_data( value, opts, xml )
379
325
  opts ? xml.string( opts ) { |x| x.text!( value ) } : xml.string( value )
380
326
  end
381
327
 
382
- # -------------------------------------------------------------------------
383
328
  # generates number chart_value
384
329
  def gen_number_data( value, opts, xml )
385
330
  opts ? xml.number( opts ) { |x| x.text!( value.to_s ) } : xml.number( value )
386
331
  end
387
332
 
388
- # -------------------------------------------------------------------------
389
333
  # generates chart data points
390
334
  # BOZO !! Check args on hash
391
335
  def gen_chart_data( series )
@@ -394,8 +338,10 @@ module Ziya::Charts
394
338
  if row.nil?
395
339
  @xml.null
396
340
  elsif row.instance_of? Hash
397
- value = row.delete( :value )
398
- gen_row_data( value, row, @xml )
341
+ # don't side effect the original series
342
+ the_clone = row.clone
343
+ value = the_clone.delete( :value )
344
+ gen_row_data( value, the_clone, @xml )
399
345
  else
400
346
  gen_row_data( row, nil, @xml )
401
347
  end
@@ -409,15 +355,14 @@ module Ziya::Charts
409
355
  end
410
356
  end
411
357
 
412
- # -------------------------------------------------------------------------
413
- # Lay down graph data points and labels if any
358
+ # lay down graph data points and labels if any
414
359
  # TODO Validate series sizes/label sizes
415
360
  def setup_series
416
- raise "You must specify an axis_category_text with your series." if !@series_desc.empty? and ! @options[:axis_category_text]
361
+ # raise "You must specify an axis_category_text with your series." if !@series_desc.empty? and ! @options[:axis_category_text]
417
362
 
418
363
  if @options[:axis_category_text]
419
364
  @xml.chart_data do
420
- gen_data_points( :axis_category_text )
365
+ gen_axis_category
421
366
  # render xml for each series
422
367
  @series_desc.each do |series|
423
368
  gen_chart_data( series )
@@ -445,8 +390,7 @@ module Ziya::Charts
445
390
 
446
391
  end
447
392
 
448
- # -------------------------------------------------------------------------
449
- # Walk up class hierarchy to find chart inheritance classes
393
+ # walk up class hierarchy to find chart inheritance classes
450
394
  def ancestors
451
395
  ancestors = self.class.ancestors.reverse
452
396
  allow = false
@@ -456,14 +400,12 @@ module Ziya::Charts
456
400
  end.compact!
457
401
  end
458
402
 
459
- # -------------------------------------------------------------------------
460
- # Check if we should do the all monty or just render the instance styles
403
+ # check if we should do the all monty or just render the instance styles
461
404
  def render_parents?
462
405
  (@render_mode == Base.mode_reset)
463
406
  end
464
407
 
465
- # -------------------------------------------------------------------------
466
- # Load up look and feel data
408
+ # load up look and feel data
467
409
  def load_lnf
468
410
  unless @partial
469
411
  ancestors.each do |super_class|
@@ -490,13 +432,13 @@ module Ziya::Charts
490
432
  end
491
433
  end
492
434
 
493
- # -------------------------------------------------------------------------
494
- # Generates xml for look and feel data
435
+ # generates xml for look and feel data
495
436
  def setup_lnf
496
437
  load_lnf
497
438
  unless @partial
498
- Base.components.each do |comp|
499
- next unless self.send( comp ).configured? # => Don't include non configured components
439
+ Base.components.each do |comp|
440
+ # Don't include non configured components
441
+ next unless ( comp == :draw and @options[:composites] ) or self.send( comp ).configured?
500
442
  if comp == :draw
501
443
  instance_eval "#{comp}.flatten( @xml, @options[:composites] )"
502
444
  else
@@ -506,7 +448,7 @@ module Ziya::Charts
506
448
  end
507
449
  end
508
450
 
509
- # -------------------------------------------------------------------------
451
+ # load up the allowable chart components
510
452
  def initialize_components
511
453
  # Setup instance vars
512
454
  Base.components.each do |comp|
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Generates necessary xml for an custom chart
3
+ #
4
+ # Author: Fernand
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/charts/base'
7
+
8
+ module Ziya::Charts
9
+ class Custom < Base
10
+ # Creates an area chart
11
+ # <tt>:license</tt>:: the XML/SWF charts license
12
+ # <tt>:chart_id</tt>:: the name of the chart style sheet.
13
+ def initialize( license=nil, chart_id=nil )
14
+ super( license, chart_id )
15
+ @type = ""
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Generates necessary xml for an image column chart
3
+ #
4
+ # Author: Fernand
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/charts/base'
7
+
8
+ module Ziya::Charts
9
+ class ImageColumn < Base
10
+ # Creates an area chart
11
+ # <tt>:license</tt>:: the XML/SWF charts license
12
+ # <tt>:chart_id</tt>:: the name of the chart style sheet.
13
+ def initialize( license=nil, chart_id=nil )
14
+ super( license, chart_id )
15
+ @type = "image column"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Generates necessary xml for an image pie chart
3
+ #
4
+ # Author: Fernand
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/charts/base'
7
+
8
+ module Ziya::Charts
9
+ class ImagePie < Base
10
+ # Creates an area chart
11
+ # <tt>:license</tt>:: the XML/SWF charts license
12
+ # <tt>:chart_id</tt>:: the name of the chart style sheet.
13
+ def initialize( license=nil, chart_id=nil )
14
+ super( license, chart_id )
15
+ @type = "image pie"
16
+ end
17
+ end
18
+ end
@@ -10,8 +10,7 @@ module Ziya::Components
10
10
  # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=link
11
11
  # for additional documentation, examples and futher detail.
12
12
  class Area < Base
13
- has_attribute :x, :y, :width, :height, :url, :priority, :target, :text,
14
- :font, :bold, :size, :color, :background_color, :alpha,
15
- :timeout, :retry, :spinning_wheel
13
+ has_attribute :x, :y, :width, :height, :url, :priority, :target, :tooltip,
14
+ :timeout, :retry, :spinning_wheel
16
15
  end
17
16
  end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Draws a button on a chart
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ module Ziya::Components
7
+ # Button component to draw a a button on the chart.
8
+ # Must be set up within the draw 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 Button < Base
12
+ has_attribute :layer, :transition, :delay, :duration,
13
+ :url_idle, :url_over, :url_press, :x, :y,
14
+ :width, :height, :alpha,
15
+ :bevel, :glow, :blur, :shadow,
16
+ :timeout, :retry
17
+ end
18
+ end
@@ -9,8 +9,10 @@ module Ziya::Components
9
9
  # for additional documentation, examples and futher detail.
10
10
  class ChartGuide < Base
11
11
  has_attribute :horizontal, :vertical, :thickness, :color, :alpha, :type,
12
- :snap_h, :snap_v, :radius, :fill_color, :line_color, :line_alpha, :line_thickness,
12
+ :snap_h, :snap_v, :connect,
13
+ :radius, :fill_color, :line_color, :line_alpha, :line_thickness,
13
14
  :text_h_alpha, :text_v_alpha, :prefix_h, :prefix_v, :suffix_h, :suffix_v,
14
- :decimals, :decimal_char, :separator, :font, :bold, :size, :text_color, :background_color
15
+ :decimals, :decimal_char, :separator, :font, :bold, :size, :text_color,
16
+ :background_color
15
17
  end
16
18
  end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Describes the look and feel for a chart annotation. An annotation must be
3
+ # added using the Chart#add( :series) call using the hash definition ie
4
+ #
5
+ # chart.add( :series, "fred", [ { :value => 10, :note => "Hi there !"} ] )
6
+ #
7
+ # Author:: Fernand Galiana
8
+ # -----------------------------------------------------------------------------
9
+ module Ziya::Components
10
+ # Specifies an annotation look and feel on a chart.
11
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=chart_note
12
+ # for additional documentation, examples and futher detail.
13
+ class ChartNote < Base
14
+ has_attribute :type, :x, :y, :offset_x, :offset_y,
15
+ :font, :bold, :size, :color, :alpha,
16
+ :background_color, :background_alpha, :shadow, :bevel, :glow, :blur
17
+ end
18
+ end
@@ -26,9 +26,9 @@ module Ziya::Components
26
26
  # -------------------------------------------------------------------------
27
27
  # Dump has_attribute into xml element
28
28
  def flatten( xml, composite_urls=nil )
29
- if components
29
+ if components or composite_urls
30
30
  xml.draw do
31
- components.each { |comp| comp.flatten( xml ) }
31
+ components.each { |comp| comp.flatten( xml ) } if components
32
32
  gen_composites( xml, composite_urls ) if composite_urls
33
33
  end
34
34
  end
@@ -37,10 +37,8 @@ module Ziya::Components
37
37
  # -------------------------------------------------------------------------
38
38
  # Generates Draw component for composite charts
39
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 ) )
40
+ composite_urls.each_pair do |id, url|
41
+ xml.image( :url => gen_composite_path( chart_path, url, id ) )
44
42
  end
45
43
  end
46
44
  end
@@ -0,0 +1,25 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Provide for the toggling of js function callback. You can enable or disable
3
+ # some or all the automatic flash to js callbacks using this component
4
+ #
5
+ # Author:: Fernand Galiana
6
+ # -----------------------------------------------------------------------------
7
+ require 'ziya/components/base'
8
+
9
+ module Ziya::Components
10
+ # Toggles flash to js callbacks.
11
+ #
12
+ # === Example
13
+ # Add this component to your yaml stylesheet. Enables Loaded_Chart callback and disable
14
+ # all other callbacks.
15
+ # <%= comp :flash_to_javascript %>
16
+ # Loaded_Chart: true
17
+ # Render_Count: false
18
+ # Scrolled_Chart: false
19
+ #
20
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=Flash_to_Javascript
21
+ # for additional documentation, examples and further detail.
22
+ class FlashToJavascript < Base
23
+ has_attribute :Loaded_Chart, :Render_Count, :Scrolled_Chart, :Stopped_Scrolling
24
+ end
25
+ end