ziya 2.0.5 → 2.0.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/Manifest.txt +8 -3
  2. data/README.txt +1 -0
  3. data/Rakefile +1 -1
  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/dollar.jpg +0 -0
  22. data/charts/charts_library/dono.swf +0 -0
  23. data/charts/charts_library/lnno.swf +0 -0
  24. data/charts/charts_library/mxno.swf +0 -0
  25. data/charts/charts_library/pi3d.swf +0 -0
  26. data/charts/charts_library/pie.jpg +0 -0
  27. data/charts/charts_library/piim.swf +0 -0
  28. data/charts/charts_library/pino.swf +0 -0
  29. data/charts/charts_library/pono.swf +0 -0
  30. data/charts/charts_library/scno.swf +0 -0
  31. data/charts/ziya.js +66 -0
  32. data/lib/ziya/charts/base.rb +25 -22
  33. data/lib/ziya/charts/custom.rb +18 -0
  34. data/lib/ziya/charts/image_column.rb +18 -0
  35. data/lib/ziya/charts/image_pie.rb +18 -0
  36. data/lib/ziya/charts/stacked_threed_area.rb +1 -1
  37. data/lib/ziya/components/chart_pref.rb +2 -2
  38. data/lib/ziya/components/chart_rect.rb +1 -1
  39. data/lib/ziya/helpers/base_helper.rb +46 -25
  40. data/lib/ziya/version.rb +1 -2
  41. data/lib/ziya/ziya_helper.rb +50 -75
  42. data/spec/charts/base_spec.rb +6 -0
  43. data/spec/ziya_helper_spec.rb +3 -3
  44. metadata +11 -6
  45. data/charts/full_screen.swf +0 -0
  46. data/cp_doc.sh +0 -1
  47. data/fred.rb +0 -36
@@ -15,25 +15,27 @@ charts/charts_library/brst.swf
15
15
  charts/charts_library/buno.swf
16
16
  charts/charts_library/cl3d.swf
17
17
  charts/charts_library/clfl.swf
18
+ charts/charts_library/clim.swf
18
19
  charts/charts_library/clno.swf
19
20
  charts/charts_library/clp3.swf
20
21
  charts/charts_library/cls3.swf
21
22
  charts/charts_library/clst.swf
22
23
  charts/charts_library/cnno.swf
24
+ charts/charts_library/dollar.jpg
23
25
  charts/charts_library/dono.swf
24
26
  charts/charts_library/lnno.swf
25
27
  charts/charts_library/mxno.swf
26
28
  charts/charts_library/pi3d.swf
29
+ charts/charts_library/pie.jpg
30
+ charts/charts_library/piim.swf
27
31
  charts/charts_library/pino.swf
28
32
  charts/charts_library/pono.swf
29
33
  charts/charts_library/scno.swf
30
- charts/full_screen.swf
31
34
  charts/scripts/output_jpg.php
32
35
  charts/sliders/black.swf
33
36
  charts/sliders/preview_handle_1.swf
34
37
  charts/sliders/preview_handle_2.swf
35
- cp_doc.sh
36
- fred.rb
38
+ charts/ziya.js
37
39
  gauges/designs/circle.yml
38
40
  gauges/designs/signal.yml
39
41
  gauges/designs/thermo.yml
@@ -48,9 +50,12 @@ lib/ziya/charts/bubble.rb
48
50
  lib/ziya/charts/candle_stick.rb
49
51
  lib/ziya/charts/column.rb
50
52
  lib/ziya/charts/column_threed.rb
53
+ lib/ziya/charts/custom.rb
51
54
  lib/ziya/charts/donut.rb
52
55
  lib/ziya/charts/floating_bar.rb
53
56
  lib/ziya/charts/floating_column.rb
57
+ lib/ziya/charts/image_column.rb
58
+ lib/ziya/charts/image_pie.rb
54
59
  lib/ziya/charts/line.rb
55
60
  lib/ziya/charts/mixed.rb
56
61
  lib/ziya/charts/parallel_threed_column.rb
data/README.txt CHANGED
@@ -11,6 +11,7 @@ ziya
11
11
  2.0.3 - README file update - Thanks to Paul James !
12
12
  2.0.4 - Fixed missing encoding on composite urls - published gem on github
13
13
  2.0.5 - Fixed merb app support issue
14
+ 2.0.6 - Updates to support xml/swf 5.0.5
14
15
 
15
16
  == DESCRIPTION:
16
17
 
data/Rakefile CHANGED
@@ -41,4 +41,4 @@ end
41
41
 
42
42
  task 'gem:package' => 'manifest:assert'
43
43
 
44
- depend_on "logging", "~> 0.9.0"
44
+ depend_on "logging", ">= 0.9.0"
Binary file
@@ -0,0 +1,66 @@
1
+ // Embed chart in a site
2
+ function ziya_micro( host_url, callback_url, size, background )
3
+ {
4
+ var html = "";
5
+ html += ziya_setup( host_url );
6
+ html += ziya_gen( host_url, callback_url, size, background );
7
+
8
+ document.write( html );
9
+ }
10
+
11
+ // setup js script
12
+ function ziya_setup( host_url )
13
+ {
14
+ var html = "";
15
+ html += "<script language=\"javascript\" type=\"text/javascript\">";
16
+ html += "AC_FL_RunContent = 0;";
17
+ html += "DetectFlashVer = 0;";
18
+ html += "</script>";
19
+
20
+ html += "<script src=\"" + host_url + "/AC_RunActiveContent.js\" language=\"javascript\" type=\"text/javascript\"></script>";
21
+ html += "<script language=\"javascript\" type=\"text/javascript\">";
22
+ html += "var requiredMajorVersion = 9;"
23
+ html += "var requiredMinorVersion = 0;"
24
+ html += "var requiredRevision = 45;"
25
+ html += "</script>"
26
+ return html;
27
+ }
28
+
29
+ function ziya_gen( host_url, callback_url, size, background )
30
+ {
31
+ var tokens = size.split( "x" );
32
+ var width = tokens[0];
33
+ var height = tokens[1];
34
+ var html = "";
35
+ html += "<script language=\"javascript\" type=\"text/javascript\">";
36
+ html += "var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);";
37
+ html += "if( hasRightVersion ) {";
38
+ html += "AC_FL_RunContent(";
39
+ html += "'codebase' , 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0',";
40
+ html += "'width' , '" + width + "',";
41
+ html += "'height' , '" + height + "}',";
42
+ html += "'scale' , 'noscale',";
43
+ html += "'salign' , 'tl',";
44
+ html += "'bgcolor' , '" + background + "',";
45
+ html += "'wmode' , 'opaque',";
46
+ html += "'movie' , '" + host_url + "/charts',";
47
+ html += "'src' , '" + host_url + "/charts',";
48
+ html += "'FlashVars' , 'library_path=" + host_url + "/charts_library&xml_source=" + escape( callback_url ) + "',";
49
+ html += "'id' , 'chart',";
50
+ html += "'name' , 'chart}',";
51
+ html += "'allowScriptAccess','sameDomain',";
52
+ html += "'quality' , 'high',";
53
+ html += "'align' , 'l',";
54
+ html += "'pluginspage' , 'http://www.macromedia.com/go/getflashplayer',";
55
+ html += "'play' , 'true',";
56
+ html += "'devicefont' , 'false'";
57
+ html += ");";
58
+ html += "}";
59
+ html += "else {";
60
+ html += "var alternateContent = 'This content requires the Adobe Flash Player. '";
61
+ html += "+ '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';";
62
+ html += "document.write(alternateContent);";
63
+ html += "}";
64
+ html += "</script>";
65
+ return html;
66
+ }
@@ -105,7 +105,8 @@ module Ziya::Charts
105
105
  # Example:
106
106
  # my_chart = Ziya::Charts::Bar.new
107
107
  # my_chart.add( :axis_category_text, ['2004', '2005', '2006'] )
108
- # my_chart.add( :series, 'series A', [ 10, 20, 30], [ '10 dogs', '20 cats', '30 rats'] )
108
+ # my_chart.add( :axis_category_label, [ '10 dogs', '20 cats', '30 rats'] )
109
+ # my_chart.add( :series, 'series A', [ 10, 20, 30] )
109
110
  # my_chart.add( :axis_value_label, [ 'my dogs', 'my cats', 'my rats'] )
110
111
  # my_chart.add( :user_data, :mykey, "Fred" )
111
112
  #
@@ -162,15 +163,19 @@ module Ziya::Charts
162
163
  raise ArgumentError, "Must specify an array of values" if values.empty?
163
164
  @options[directive] = values
164
165
  when :series
166
+ series = {}
165
167
  legend = args.first.is_a?(String) ? args.shift : ""
166
168
  if args.first.is_a?( Array )
167
169
  points = args.shift || []
168
170
  raise ArgumentError, "Must specify an array of data points" if points.empty?
169
171
  points.insert( 0, legend )
170
- @series_desc << points
172
+ series[:points] = points
171
173
  else
172
174
  raise ArgumentError, "Must specify an array of data points"
173
175
  end
176
+ url = args.shift
177
+ series[:url] = url if url
178
+ @series_desc << series
174
179
  when :user_data
175
180
  key = args.first.is_a?(Symbol) ? args.shift : ""
176
181
  raise ArgumentError, "Must specify a key" if key.to_s.empty?
@@ -360,50 +365,48 @@ module Ziya::Charts
360
365
  # ------------------------------------------------------------------------
361
366
  # generates chart data row
362
367
  # TODO Validate options !!
363
- def gen_row_data( value, opts=nil )
368
+ def gen_row_data( value, opts=nil, xml=@xml )
364
369
  if value.instance_of? String
365
- gen_string_data( value, opts )
370
+ gen_string_data( value, opts, xml )
366
371
  elsif value.respond_to? :zero?
367
- gen_number_data( value, opts )
372
+ gen_number_data( value, opts, xml )
368
373
  end
369
374
  end
370
375
 
371
376
  # -------------------------------------------------------------------------
372
377
  # generates string chart_value
373
- def gen_string_data( value, opts )
374
- if opts
375
- @xml.string( opts ) { |x| x.text!( value ) }
376
- else
377
- @xml.string( value )
378
- end
378
+ def gen_string_data( value, opts, xml )
379
+ opts ? xml.string( opts ) { |x| x.text!( value ) } : xml.string( value )
379
380
  end
380
381
 
381
382
  # -------------------------------------------------------------------------
382
383
  # generates number chart_value
383
- def gen_number_data( value, opts )
384
- if opts
385
- @xml.number( opts ) { |x| x.text!( value.to_s ) }
386
- else
387
- @xml.number( value )
388
- end
384
+ def gen_number_data( value, opts, xml )
385
+ opts ? xml.number( opts ) { |x| x.text!( value.to_s ) } : xml.number( value )
389
386
  end
390
387
 
391
388
  # -------------------------------------------------------------------------
392
389
  # generates chart data points
393
390
  # BOZO !! Check args on hash
394
391
  def gen_chart_data( series )
395
- @xml.row do
396
- series.each do |row|
392
+ block = lambda {
393
+ series[:points].each do |row|
397
394
  if row.nil?
398
395
  @xml.null
399
396
  elsif row.instance_of? Hash
400
397
  value = row.delete( :value )
401
- gen_row_data( value, row )
398
+ gen_row_data( value, row, @xml )
402
399
  else
403
- gen_row_data( row )
400
+ gen_row_data( row, nil, @xml )
404
401
  end
405
402
  end
406
- end
403
+ }
404
+
405
+ if series[:url]
406
+ @xml.row( :url => series[:url], &block )
407
+ else
408
+ @xml.row( &block )
409
+ end
407
410
  end
408
411
 
409
412
  # -------------------------------------------------------------------------
@@ -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,7 +10,7 @@ module Ziya::Charts
10
10
  # <tt>:chart_id</tt>:: the name of the chart style sheet.
11
11
  def initialize( license=nil, chart_id=nil )
12
12
  super( license, chart_id )
13
- @type = "3d area"
13
+ @type = "stacked 3d area"
14
14
  end
15
15
  end
16
16
  end
@@ -13,9 +13,9 @@ module Ziya::Components
13
13
  # for additional documentation, examples and futher detail.
14
14
  #
15
15
  class ChartPref < Base
16
- has_attribute :line_thickness, :point_shape, :point_size, :fill_shape,
16
+ has_attribute :line_thickness, :point_shape, :point_size, :fill_shape, :connect, :tip,
17
17
  :type, :bull_color, :bear_color,
18
- :reverse, :drag, :min_x, :min_y, :max_x, :max_y,
18
+ :drag, :min_x, :min_y, :max_x, :max_y,
19
19
  :trend_thickness, :trend_alpha, :line_alpha, :rotation_x,
20
20
  :rotation_y, :grid, :select, :empty_center
21
21
  end
@@ -30,7 +30,7 @@ module Ziya::Components
30
30
  #
31
31
  class ChartRect < Base
32
32
  has_attribute :x, :y, :width, :height, :positive_color, :negative_color,
33
- :positive_alpha, :negative_alpha,
33
+ :positive_alpha, :negative_alpha, :hide,
34
34
  :shadow, :bevel, :blur, :glow,
35
35
  :corner_tl, :corner_tr, :corner_bl, :corner_br
36
36
  end
@@ -5,66 +5,87 @@ module Ziya::Helpers
5
5
  module BaseHelper
6
6
  include Ziya::Utils::Text, Ziya::Helper
7
7
 
8
- # -------------------------------------------------------------------------
9
- # generates a swf chart path from the given url. Used as helper to embed
10
- # chart
8
+ # Defines various helpers to assist in writing ZiYa yaml stylesheets.
9
+
10
+ # generates a swf chart path from the given url. Used as helper to embed a chart
11
+ # within a chart
12
+ # ==== Example
13
+ # <%= chart_url( chart_1_path ) %>
14
+ #
15
+ # => /charts/charts.swf?library_path=/charts/charts_library&xml_source=http://fred/load_chart_1.xml
11
16
  def chart_url( url, swf_chart_dir="/charts" )
12
17
  gen_composite_path( swf_chart_dir, url )
13
18
  end
14
19
 
15
- # -------------------------------------------------------------------------
16
20
  # indent yaml content vy multiples of 2 spaces
17
21
  def indent( multiple= 1 )
18
22
  " " * multiple
19
23
  end
20
24
 
21
- # -------------------------------------------------------------------------
22
- # YAML Convenience for gauge class
25
+ # generates a gauge yaml class declaration
26
+ # ==== Example
27
+ # <%= gauge :thermo %>
28
+ #
29
+ # produces:
30
+ #
31
+ # --- !ruby/object:Ziya::Gauges::Thermo
32
+ # components: !omap
23
33
  def gauge( class_name )
24
34
  "--- #{clazz( class_name, 'Gauges' )}\n#{dials}"
25
35
  end
26
36
 
27
- # -------------------------------------------------------------------------
28
- # YAML Convenience for gauge component declaration
37
+ # generates a gauge element declaration
38
+ # ==== Example
39
+ # <%= dial :rect %>
40
+ # => --- !ruby/object:Ziya::Gauges::Support::Rect
29
41
  def dial( comp_class, comp_name=nil )
30
42
  clazz = clazz( comp_class, "Gauges::Support" )
31
43
  comp_name ? "- :#{comp_name}: #{clazz}" : "- #{clazz}"
32
44
  end
33
45
 
34
- # -------------------------------------------------------------------------
35
- # YAML dials declaration
46
+ # generates a yaml hash of dials
47
+ # ==== Example
48
+ # <%= dials %>
49
+ # => components: !omap
36
50
  def dials
37
51
  "components: !omap"
38
52
  end
39
53
 
40
- # -------------------------------------------------------------------------
41
- # YAML Convenience for component declaration
54
+ # generates a component yaml class declaration
55
+ # ==== Example
56
+ # <%= component :axis_category %>
57
+ # => axis_category: --- !ruby/object:Ziya::Components::AxisCategory
42
58
  def component( component_name )
43
59
  "#{component_name}: #{clazz component_name, :Components}"
44
60
  end
45
61
  alias :comp :component
46
62
 
47
- # -------------------------------------------------------------------------
48
- # YAML Convenience for draw component class
63
+ # generates a drawing yaml class declaration
64
+ # ==== Example
65
+ # <%=drawing :rect %>
66
+ # => --- !ruby/object:Ziya::Components::Rect
49
67
  def drawing( class_name )
50
68
  clazz( class_name, :Components )
51
69
  end
52
70
  alias_method :filter_type, :drawing
53
71
  alias_method :area , :drawing
54
72
 
55
- # -------------------------------------------------------------------------
56
- # YAML Convenience for chart class
73
+ # generates a yaml chart declaration
74
+ # ==== Example
75
+ # <%= chart :bar %>
76
+ # => --- !ruby/object:Ziya::Charts::Bar
57
77
  def chart( class_name )
58
78
  "--- #{clazz( class_name, :Charts )}"
59
79
  end
60
-
61
- # -------------------------------------------------------------------------
62
- # YAML Convenience for chart name setting
63
- def clazz( class_name, module_name=nil )
64
- buff = "!ruby/object:Ziya::"
65
- buff << "#{module_name}::" unless module_name.nil?
66
- buff << "#{camelize(class_name.to_s)}"
67
- buff
68
- end
80
+
81
+ private
82
+
83
+ # generates a yaml class declaration
84
+ def clazz( class_name, module_name=nil ) #:nodoc:
85
+ buff = "!ruby/object:Ziya::"
86
+ buff << "#{module_name}::" unless module_name.nil?
87
+ buff << "#{camelize(class_name.to_s)}"
88
+ buff
89
+ end
69
90
  end
70
91
  end
@@ -2,10 +2,9 @@ module Ziya
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
- TINY = 5
5
+ TINY = 6
6
6
 
7
7
  # Returns the version string for the library.
8
- #
9
8
  def self.version
10
9
  [ MAJOR, MINOR, TINY].join( "." )
11
10
  end
@@ -1,17 +1,14 @@
1
- # -----------------------------------------------------------------------------
2
1
  # Generates necessary html flash tag to support ZiYa
3
2
  #
4
- # TODO !! Rewrite to use content tag block instead...
3
+ # TODO -- Rewrite to use content tag block instead...
5
4
  #
6
5
  # Author: Fernand Galiana
7
- # -----------------------------------------------------------------------------
8
6
  require 'cgi'
9
7
  require 'erb'
10
8
 
11
9
  module Ziya
12
10
  module Helper
13
11
 
14
- # -------------------------------------------------------------------------
15
12
  # generates a javascript tag to include the js script to create object and
16
13
  # embed tags
17
14
  def ziya_javascript_include_tag
@@ -55,7 +52,9 @@ module Ziya
55
52
  # setup width and height
56
53
  setup_movie_size( options )
57
54
 
58
- xml_swf_path = charts_swf % [options[:swf_path], escape_url(url)]
55
+ flash_vars = url ? charts_swf : charts_swf_no_src
56
+ xml_swf_path = flash_vars % [options[:swf_path], escape_url(url)]
57
+ xml_swf_path << "&chart_id=#{options[:id]}"
59
58
  xml_swf_path << "&timestamp=#{Time.now.to_i}" if options[:cache] == false
60
59
  xml_swf_path << "&timeout=#{options[:timeout]}&retry=#{options[:retry]}" if options[:timeout]
61
60
  xml_swf_path << "&stage_width=#{options[:width]}&stage_height=#{options[:height]}" if options[:use_stage] == true
@@ -101,7 +100,6 @@ module Ziya
101
100
  JS
102
101
  end
103
102
 
104
- # -------------------------------------------------------------------------
105
103
  # generates necessary html tags to display a gauge.
106
104
  def ziya_gauge( url, gauge_options={} )
107
105
  options = { :width => "200",
@@ -121,7 +119,6 @@ module Ziya
121
119
  generate_old_style_flash_tag( url, gauges_swf, options )
122
120
  end
123
121
 
124
- # -------------------------------------------------------------------------------------
125
122
  # generates neccessary html tags to display a chart.
126
123
  def ziya_chart( url, chart_options = {} )
127
124
  options = { :width => "400",
@@ -138,7 +135,8 @@ module Ziya
138
135
  :use_stage => false
139
136
  }.merge!(chart_options)
140
137
 
141
- generate_flash_tag( url, charts_swf, "charts.swf", options )
138
+ flash_vars = url ? charts_swf : charts_swf_no_src
139
+ generate_flash_tag( url, flash_vars, "charts.swf", options )
142
140
  end
143
141
 
144
142
  # flash chart library path
@@ -150,19 +148,20 @@ module Ziya
150
148
  # private
151
149
 
152
150
  # Const accessors...
153
- def mime() "application/x-shockwave-flash"; end
154
- def composite_url() "%s/charts.swf?library_path=%s/charts_library&xml_source=%s" end
155
- def charts_swf() "library_path=%s/charts_library&xml_source=%s"; end
156
- def plugin_url() "http://www.macromedia.com/go/getflashplayer"; end
157
- def gauges_swf() "%s/gauge.swf?xml_source=%s"; end
158
- def gauge_path() "/gauges"; end
159
- def chart_path() "/charts"; end
160
- def class_id() "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" end
161
- def codebase() "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0"; end
151
+ def mime() "application/x-shockwave-flash"; end
152
+ def composite_url() "%s/charts.swf?library_path=%s/charts_library&xml_source=%s" end
153
+ def charts_swf_no_src() "library_path=%s/charts_library"; end
154
+ def charts_swf() "#{charts_swf_no_src}&xml_source=%s"; end
155
+ def plugin_url() "http://www.macromedia.com/go/getflashplayer"; end
156
+ def gauges_swf() "%s/gauge.swf?xml_source=%s"; end
157
+ def gauge_path() "/gauges"; end
158
+ def chart_path() "/charts"; end
159
+ def class_id() "clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" end
160
+ def codebase() "http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0"; end
162
161
 
163
162
  # generates swf path
164
163
  def gen_swf_path( path_directive, swf_dir, url )
165
- path_directive % [swf_dir, escape_url( url )]
164
+ path_directive % [swf_dir, escape_url( url )]
166
165
  end
167
166
 
168
167
  def generate_old_style_flash_tag( url, swf_path, options )
@@ -230,69 +229,45 @@ module Ziya
230
229
  xml_swf_path << "&timeout=#{options[:timeout]}" if options[:timeout]
231
230
  xml_swf_path << "&stage_width=#{options[:width]}&stage_height=#{options[:height]}" if options[:use_stage] == true
232
231
 
233
- # if options[:tag_type] == "object"
234
- tags = <<-TAGS
235
- <object codebase="#{codebase}" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="#{options[:id]}" height="#{options[:height]}" width="#{options[:width]}">
236
- <param name="scale" value="noscale">
237
- <param name="salign" value="#{options[:salign]}">
238
- <param name="bgcolor" value="#{options[:bgcolor]}">
239
- <param name="wmode" value="#{options[:wmode]}">
240
- <param name="movie" value="#{options[:swf_path]}/#{swf_file}">
241
- <param name="FlashVars" value="#{xml_swf_path}&chart_id=#{options[:id]}">
242
- <param name="menu" value="true">
243
- <param name="allowFullScreen" value="true">
244
- <param name="allowScriptAccess" value="sameDomain">
245
- <param name="quality" value="high">
246
- <param name="play" value="true">
247
- <param name="devicefont" value="false">
248
- <embed scale="noscale"
249
- allowfullscreen="true"
250
- allowscriptaccess="sameDomain"
251
- bgcolor="#{options[:bgcolor]}"
252
- devicefont="false"
253
- flashvars="#{xml_swf_path}"
254
- menu="true"
255
- name="#{options[:id]}"
256
- play="true"
257
- pluginspage="http://www.macromedia.com/go/getflashplayer"
258
- quality="high"
259
- salign="#{options[:salign]}"
260
- src="#{options[:swf_path]}/#{swf_file}"
261
- type="application/x-shockwave-flash"
262
- wmode="#{options[:wmode]}"
263
- align="#{options[:align]}"
264
- height="#{options[:height]}"
265
- width="#{options[:width]}"/>
232
+ tags = <<-TAGS
233
+ <object codebase="#{codebase}" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" id="#{options[:id]}" height="#{options[:height]}" width="#{options[:width]}">
234
+ <param name="scale" value="noscale">
235
+ <param name="salign" value="#{options[:salign]}">
236
+ <param name="bgcolor" value="#{options[:bgcolor]}">
237
+ <param name="wmode" value="#{options[:wmode]}">
238
+ <param name="movie" value="#{options[:swf_path]}/#{swf_file}">
239
+ <param name="Flashvars" value="#{xml_swf_path}&chart_id=#{options[:id]}">
240
+ <param name="menu" value="true">
241
+ <param name="allowFullScreen" value="true">
242
+ <param name="allowScriptAccess" value="sameDomain">
243
+ <param name="quality" value="high">
244
+ <param name="play" value="true">
245
+ <param name="devicefont" value="false">
246
+ <embed scale="noscale"
247
+ allowfullscreen = "true"
248
+ allowscriptaccess = "sameDomain"
249
+ bgcolor = "#{options[:bgcolor]}"
250
+ devicefont = "false"
251
+ flashvars = "#{xml_swf_path}&chart_id=#{options[:id]}"
252
+ menu = "true"
253
+ name = "#{options[:id]}"
254
+ play = "true"
255
+ pluginspage = "http://www.macromedia.com/go/getflashplayer"
256
+ quality = "high"
257
+ salign = "#{options[:salign]}"
258
+ src = "#{options[:swf_path]}/#{swf_file}"
259
+ type = "application/x-shockwave-flash"
260
+ wmode = "#{options[:wmode]}"
261
+ align = "#{options[:align]}"
262
+ height = "#{options[:height]}"
263
+ width = "#{options[:width]}"/>
266
264
  </object>
267
265
  TAGS
268
- # else
269
- # tags = <<-TAGS
270
- # <embed scale="noscale"
271
- # allowfullscreen="true"
272
- # allowscriptaccess="sameDomain"
273
- # bgcolor="#{options[:bgcolor]}"
274
- # devicefont="false"
275
- # flashvars="#{xml_swf_path}"
276
- # menu="true"
277
- # name="#{options[:id]}"
278
- # play="true"
279
- # pluginspage="http://www.macromedia.com/go/getflashplayer"
280
- # quality="high"
281
- # salign="#{options[:salign]}"
282
- # src="#{options[:swf_path]}/#{swf_file}"
283
- # type="application/x-shockwave-flash"
284
- # wmode="#{options[:wmode]}"
285
- # align="#{options[:align]}"
286
- # height="#{options[:height]}"
287
- # width="#{options[:width]}"/>
288
- # TAGS
289
- # end
290
- tags
291
266
  end
292
267
 
293
268
  # escape url
294
269
  def escape_url( url )
295
- CGI.escape( url.gsub( /&amp;/, '&' ) )
270
+ url ? CGI.escape( url.gsub( /&amp;/, '&' ) ) : url
296
271
  end
297
272
 
298
273
  # setup up wmode
@@ -82,6 +82,12 @@ describe Ziya::Charts::Base do
82
82
  @chart.add( :series, "test", [ {:value => 10, :glow => "glow1" }, { :value => 20, :blur => "blur2" } ] )
83
83
  @chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart><chart_data><row><null/><string>dog</string><string>cat</string></row><row><string>test</string><number glow=\"glow1\">10</number><number blur=\"blur2\">20</number></row></chart_data></chart>"
84
84
  end
85
+
86
+ it "should support adding an image to a series" do
87
+ @chart.add( :axis_category_text, %w[dog cat] )
88
+ @chart.add( :series, "test", [ 10, 20 ], "some_url" )
89
+ @chart.to_xml.should == "<?xml version=\"1.0\" encoding=\"UTF-8\"?><chart><chart_data><row><null/><string>dog</string><string>cat</string></row><row url=\"some_url\"><string>test</string><number>10</number><number>20</number></row></chart_data></chart>"
90
+ end
85
91
 
86
92
  it "should error if a series is defined but no axis_category is specified" do
87
93
  @chart.add( :series, "test", [10,20] )
@@ -25,11 +25,11 @@ describe Ziya::Helper do
25
25
 
26
26
  describe "ziya_chart" do
27
27
  it "should generate the correct embed tag with the default options" do
28
- ziya_chart( @url, :tag_type => "embed" ).should == " <object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" id=\"ziya_chart\" height=\"300\" width=\"400\">\n <param name=\"scale\" value=\"noscale\">\n <param name=\"salign\" value=\"tl\"> \n <param name=\"bgcolor\" value=\"#FFFFFF\">\n <param name=\"wmode\" value=\"transparent\"> \n <param name=\"movie\" value=\"/charts/charts.swf\"> \n <param name=\"FlashVars\" value=\"library_path=/charts/charts_library&xml_source=%2Ffred%2Fblee%2Fduh&chart_id=ziya_chart\">\n <param name=\"menu\" value=\"true\">\n <param name=\"allowFullScreen\" value=\"true\">\n <param name=\"allowScriptAccess\" value=\"sameDomain\"> \n <param name=\"quality\" value=\"high\">\n <param name=\"play\" value=\"true\"> \n <param name=\"devicefont\" value=\"false\">\n <embed scale=\"noscale\" \n allowfullscreen=\"true\" \n allowscriptaccess=\"sameDomain\" \n bgcolor=\"#FFFFFF\" \n devicefont=\"false\" \n flashvars=\"library_path=/charts/charts_library&xml_source=%2Ffred%2Fblee%2Fduh\" \n menu=\"true\" \n name=\"ziya_chart\" \n play=\"true\" \n pluginspage=\"http://www.macromedia.com/go/getflashplayer\" \n quality=\"high\" \n salign=\"tl\" \n src=\"/charts/charts.swf\" \n type=\"application/x-shockwave-flash\" \n wmode=\"transparent\" \n align=\"l\" \n height=\"300\" \n width=\"400\"/> \n </object> \n"
28
+ ziya_chart( @url, :tag_type => "embed" ).should == " <object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" id=\"ziya_chart\" height=\"300\" width=\"400\">\n <param name=\"scale\" value=\"noscale\">\n <param name=\"salign\" value=\"tl\"> \n <param name=\"bgcolor\" value=\"#FFFFFF\">\n <param name=\"wmode\" value=\"transparent\"> \n <param name=\"movie\" value=\"/charts/charts.swf\">\n <param name=\"Flashvars\" value=\"library_path=/charts/charts_library&xml_source=%2Ffred%2Fblee%2Fduh&chart_id=ziya_chart\">\n <param name=\"menu\" value=\"true\">\n <param name=\"allowFullScreen\" value=\"true\">\n <param name=\"allowScriptAccess\" value=\"sameDomain\"> \n <param name=\"quality\" value=\"high\">\n <param name=\"play\" value=\"true\"> \n <param name=\"devicefont\" value=\"false\">\n <embed scale=\"noscale\" \n allowfullscreen = \"true\" \n allowscriptaccess = \"sameDomain\" \n bgcolor = \"#FFFFFF\" \n devicefont = \"false\" \n flashvars = \"library_path=/charts/charts_library&xml_source=%2Ffred%2Fblee%2Fduh&chart_id=ziya_chart\" \n menu = \"true\" \n name = \"ziya_chart\" \n play = \"true\" \n pluginspage = \"http://www.macromedia.com/go/getflashplayer\" \n quality = \"high\" \n salign = \"tl\" \n src = \"/charts/charts.swf\" \n type = \"application/x-shockwave-flash\" \n wmode = \"transparent\" \n align = \"l\" \n height = \"300\" \n width = \"400\"/> \n </object> \n"
29
29
  end
30
30
 
31
31
  it "should generate the correct object tag with the default options" do
32
- ziya_chart( @url, :tag_type => "object" ).should == " <object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" id=\"ziya_chart\" height=\"300\" width=\"400\">\n <param name=\"scale\" value=\"noscale\">\n <param name=\"salign\" value=\"tl\"> \n <param name=\"bgcolor\" value=\"#FFFFFF\">\n <param name=\"wmode\" value=\"transparent\"> \n <param name=\"movie\" value=\"/charts/charts.swf\"> \n <param name=\"FlashVars\" value=\"library_path=/charts/charts_library&xml_source=%2Ffred%2Fblee%2Fduh&chart_id=ziya_chart\">\n <param name=\"menu\" value=\"true\">\n <param name=\"allowFullScreen\" value=\"true\">\n <param name=\"allowScriptAccess\" value=\"sameDomain\"> \n <param name=\"quality\" value=\"high\">\n <param name=\"play\" value=\"true\"> \n <param name=\"devicefont\" value=\"false\">\n <embed scale=\"noscale\" \n allowfullscreen=\"true\" \n allowscriptaccess=\"sameDomain\" \n bgcolor=\"#FFFFFF\" \n devicefont=\"false\" \n flashvars=\"library_path=/charts/charts_library&xml_source=%2Ffred%2Fblee%2Fduh\" \n menu=\"true\" \n name=\"ziya_chart\" \n play=\"true\" \n pluginspage=\"http://www.macromedia.com/go/getflashplayer\" \n quality=\"high\" \n salign=\"tl\" \n src=\"/charts/charts.swf\" \n type=\"application/x-shockwave-flash\" \n wmode=\"transparent\" \n align=\"l\" \n height=\"300\" \n width=\"400\"/> \n </object> \n"
32
+ ziya_chart( @url, :tag_type => "object" ).should == " <object codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,45,0\" classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" id=\"ziya_chart\" height=\"300\" width=\"400\">\n <param name=\"scale\" value=\"noscale\">\n <param name=\"salign\" value=\"tl\"> \n <param name=\"bgcolor\" value=\"#FFFFFF\">\n <param name=\"wmode\" value=\"transparent\"> \n <param name=\"movie\" value=\"/charts/charts.swf\">\n <param name=\"Flashvars\" value=\"library_path=/charts/charts_library&xml_source=%2Ffred%2Fblee%2Fduh&chart_id=ziya_chart\">\n <param name=\"menu\" value=\"true\">\n <param name=\"allowFullScreen\" value=\"true\">\n <param name=\"allowScriptAccess\" value=\"sameDomain\"> \n <param name=\"quality\" value=\"high\">\n <param name=\"play\" value=\"true\"> \n <param name=\"devicefont\" value=\"false\">\n <embed scale=\"noscale\" \n allowfullscreen = \"true\" \n allowscriptaccess = \"sameDomain\" \n bgcolor = \"#FFFFFF\" \n devicefont = \"false\" \n flashvars = \"library_path=/charts/charts_library&xml_source=%2Ffred%2Fblee%2Fduh&chart_id=ziya_chart\" \n menu = \"true\" \n name = \"ziya_chart\" \n play = \"true\" \n pluginspage = \"http://www.macromedia.com/go/getflashplayer\" \n quality = \"high\" \n salign = \"tl\" \n src = \"/charts/charts.swf\" \n type = \"application/x-shockwave-flash\" \n wmode = \"transparent\" \n align = \"l\" \n height = \"300\" \n width = \"400\"/> \n </object> \n"
33
33
  end
34
34
 
35
35
  it "should generate the correct js tag" do
@@ -44,7 +44,7 @@ describe Ziya::Helper do
44
44
  html = ziya_chart( @url, :bgcolor => "ffffff" )
45
45
  # html.index (/name=\"wmode\" value=\"opaque\"/).should_not be_nil
46
46
  # html.index (/'wmode'\s+,\s'opaque'/).should_not be_nil
47
- html.index( /wmode=\"opaque\"/ ).should_not be_nil
47
+ html.index( /wmode\s+=\s\"opaque\"/ ).should_not be_nil
48
48
  end
49
49
 
50
50
  it "should handle the size has widthxheight" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ziya
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.5
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fernand Galiana
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-09-02 00:00:00 -06:00
12
+ date: 2008-10-01 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -18,7 +18,7 @@ dependencies:
18
18
  version_requirement:
19
19
  version_requirements: !ruby/object:Gem::Requirement
20
20
  requirements:
21
- - - ~>
21
+ - - ">="
22
22
  - !ruby/object:Gem::Version
23
23
  version: 0.9.0
24
24
  version:
@@ -51,25 +51,27 @@ files:
51
51
  - charts/charts_library/buno.swf
52
52
  - charts/charts_library/cl3d.swf
53
53
  - charts/charts_library/clfl.swf
54
+ - charts/charts_library/clim.swf
54
55
  - charts/charts_library/clno.swf
55
56
  - charts/charts_library/clp3.swf
56
57
  - charts/charts_library/cls3.swf
57
58
  - charts/charts_library/clst.swf
58
59
  - charts/charts_library/cnno.swf
60
+ - charts/charts_library/dollar.jpg
59
61
  - charts/charts_library/dono.swf
60
62
  - charts/charts_library/lnno.swf
61
63
  - charts/charts_library/mxno.swf
62
64
  - charts/charts_library/pi3d.swf
65
+ - charts/charts_library/pie.jpg
66
+ - charts/charts_library/piim.swf
63
67
  - charts/charts_library/pino.swf
64
68
  - charts/charts_library/pono.swf
65
69
  - charts/charts_library/scno.swf
66
- - charts/full_screen.swf
67
70
  - charts/scripts/output_jpg.php
68
71
  - charts/sliders/black.swf
69
72
  - charts/sliders/preview_handle_1.swf
70
73
  - charts/sliders/preview_handle_2.swf
71
- - cp_doc.sh
72
- - fred.rb
74
+ - charts/ziya.js
73
75
  - gauges/designs/circle.yml
74
76
  - gauges/designs/signal.yml
75
77
  - gauges/designs/thermo.yml
@@ -84,9 +86,12 @@ files:
84
86
  - lib/ziya/charts/candle_stick.rb
85
87
  - lib/ziya/charts/column.rb
86
88
  - lib/ziya/charts/column_threed.rb
89
+ - lib/ziya/charts/custom.rb
87
90
  - lib/ziya/charts/donut.rb
88
91
  - lib/ziya/charts/floating_bar.rb
89
92
  - lib/ziya/charts/floating_column.rb
93
+ - lib/ziya/charts/image_column.rb
94
+ - lib/ziya/charts/image_pie.rb
90
95
  - lib/ziya/charts/line.rb
91
96
  - lib/ziya/charts/mixed.rb
92
97
  - lib/ziya/charts/parallel_threed_column.rb
Binary file
data/cp_doc.sh DELETED
@@ -1 +0,0 @@
1
- scp -r docs derailed@rubyforge.org:/var/www/gforge-projects/ziya
data/fred.rb DELETED
@@ -1,36 +0,0 @@
1
- # GAUGE IDEAS ??
2
-
3
- css_parser for ruby
4
-
5
- gauge = Ziya::Gauges::Base.new( :id => 'volume' )
6
- gauge.add( Ziya::Gauges::Support::RadialTicks.new( :id => 'ticks' ) )
7
-
8
- gauge 'volume'
9
- radial_ticks 'volume_ticks'
10
- rotate( circle( :circle_1), circle( :circle_2 ) )
11
-
12
-
13
- gauge#volume {
14
- x: 100;
15
- y: 100;
16
- radius: 35;
17
- }
18
-
19
- gauge#volume rotate {
20
- x: 100;
21
- y: 75;
22
- }
23
-
24
- gauge = Ziya::Gauges::Base.new( :id => "fred" )
25
- gauge.add( :ticks, :volume_ticks )
26
- gauge.add( :circle, :circle_1 )
27
- gauge.add( :circle, :circle_2 )
28
- gauge.add( :rotate, :circle_1, :circle_2 )
29
- gauge.to_xml
30
-
31
- gauge#fred {
32
- }
33
-
34
- gauge#fred circle#volume_ticks {
35
-
36
- }