ziya 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -20,6 +20,7 @@ charts/charts_library/clp3.swf
20
20
  charts/charts_library/cls3.swf
21
21
  charts/charts_library/clst.swf
22
22
  charts/charts_library/cnno.swf
23
+ charts/charts_library/dono.swf
23
24
  charts/charts_library/lnno.swf
24
25
  charts/charts_library/mxno.swf
25
26
  charts/charts_library/pi3d.swf
@@ -27,9 +28,11 @@ charts/charts_library/pino.swf
27
28
  charts/charts_library/pono.swf
28
29
  charts/charts_library/scno.swf
29
30
  charts/full_screen.swf
31
+ charts/scripts/output_jpg.php
30
32
  charts/sliders/black.swf
31
33
  charts/sliders/preview_handle_1.swf
32
34
  charts/sliders/preview_handle_2.swf
35
+ cp_doc.sh
33
36
  fred.rb
34
37
  gauges/designs/circle.yml
35
38
  gauges/designs/signal.yml
@@ -45,6 +48,7 @@ lib/ziya/charts/bubble.rb
45
48
  lib/ziya/charts/candle_stick.rb
46
49
  lib/ziya/charts/column.rb
47
50
  lib/ziya/charts/column_threed.rb
51
+ lib/ziya/charts/donut.rb
48
52
  lib/ziya/charts/floating_bar.rb
49
53
  lib/ziya/charts/floating_column.rb
50
54
  lib/ziya/charts/line.rb
@@ -75,6 +79,7 @@ lib/ziya/components/chart_pref.rb
75
79
  lib/ziya/components/chart_rect.rb
76
80
  lib/ziya/components/chart_transition.rb
77
81
  lib/ziya/components/circle.rb
82
+ lib/ziya/components/context_menu.rb
78
83
  lib/ziya/components/draw.rb
79
84
  lib/ziya/components/draw_base.rb
80
85
  lib/ziya/components/filter.rb
@@ -86,10 +91,9 @@ lib/ziya/components/link.rb
86
91
  lib/ziya/components/link_data.rb
87
92
  lib/ziya/components/rect.rb
88
93
  lib/ziya/components/scroll.rb
94
+ lib/ziya/components/series.rb
89
95
  lib/ziya/components/series_color.rb
90
96
  lib/ziya/components/series_explode.rb
91
- lib/ziya/components/series_gap.rb
92
- lib/ziya/components/series_switch.rb
93
97
  lib/ziya/components/shadow.rb
94
98
  lib/ziya/components/text.rb
95
99
  lib/ziya/components/update.rb
@@ -126,9 +130,10 @@ spec/components/area_spec.rb
126
130
  spec/components/draw_spec.rb
127
131
  spec/components/filter_spec.rb
128
132
  spec/components/link_spec.rb
133
+ spec/components/series.rb
129
134
  spec/components/series_color_spec.rb
135
+ spec/components/series_explode.rb
130
136
  spec/components/series_explode_spec.rb
131
- spec/components/series_switch_spec.rb
132
137
  spec/designs/circle.yml
133
138
  spec/designs/crapping_out.yml
134
139
  spec/designs/gauge_1.yml
data/charts/charts.swf CHANGED
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,23 @@
1
+ <?php
2
+ if(!function_exists("imagecreate")) die("Sorry, the GD library is needed to run this script.");
3
+
4
+ $data = explode(",", $_POST['img']);
5
+ $width = $_POST['width'];
6
+ $height = $_POST['height'];
7
+ $image=imagecreatetruecolor( $width ,$height );
8
+ $background = imagecolorallocate( $image ,0 , 0 , 0 );
9
+ //Copy pixels
10
+ $i = 0;
11
+ for($x=0; $x<=$width; $x++){
12
+ for($y=0; $y<=$height; $y++){
13
+ $int = hexdec($data[$i++]);
14
+ $color = ImageColorAllocate ($image, 0xFF & ($int >> 0x10), 0xFF & ($int >> 0x8), 0xFF & $int);
15
+ imagesetpixel ( $image , $x , $y , $color );
16
+ }
17
+ }
18
+ //Output image and clean
19
+ header( "Content-type: image/jpeg" );
20
+ ImageJPEG( $image );
21
+ imagedestroy( $image );
22
+ ?>
23
+
data/cp_doc.sh ADDED
@@ -0,0 +1 @@
1
+ scp -r docs derailed@rubyforge.org:/var/www/gforge-projects/ziya
@@ -32,9 +32,9 @@ module Ziya::Charts
32
32
  :chart_rect, :chart_border, :chart_grid_h, :chart_grid_v,
33
33
  :chart_transition, :chart_label, :chart_guide, :legend,
34
34
  :filter, :draw,
35
- :series_color, :series_gap, :series_switch, :series_explode,
35
+ :series_color, :series, :series_explode,
36
36
  :chart_pref, :scroll,
37
- :update, :link_data, :link]
37
+ :update, :link_data, :link, :context_menu]
38
38
  @components.each { |a| attr_accessor a }
39
39
  end
40
40
  declare_components
@@ -51,11 +51,12 @@ module Ziya::Charts
51
51
  # NOTE: If chart_id is specified the framework will attempt to load the chart styles
52
52
  # from public/themes/theme_name/chart_id.yml
53
53
  def initialize( license=nil, chart_id=nil )
54
- @id = chart_id
55
- @license = license
56
- @options = {}
57
- @series = []
58
- @theme = default_theme
54
+ @id = chart_id
55
+ @license = license
56
+ @options = {}
57
+ @series_desc = []
58
+ @theme = default_theme
59
+ @render_mode = Base.all_styles
59
60
  initialize_components
60
61
  load_helpers( Ziya.helpers_dir ) if Ziya.helpers_dir
61
62
  end
@@ -65,6 +66,12 @@ module Ziya::Charts
65
66
  @components
66
67
  end
67
68
 
69
+ # don't render stylesheets just gen code for chart stylesheet and data
70
+ def self.data_only() 1; end
71
+
72
+ # renders everything
73
+ def self.all_styles() 0; end
74
+
68
75
  # -------------------------------------------------------------------------
69
76
  # Default ZiYa theme
70
77
  def default_theme # :nodoc:
@@ -151,12 +158,12 @@ module Ziya::Charts
151
158
  @options[directive] = values
152
159
  when :series
153
160
  legend = args.first.is_a?(String) ? args.shift : ""
154
- raise ArgumentError, "Must specify a series name" if legend.empty?
161
+ # raise ArgumentError, "Must specify a series name" if legend.empty?
155
162
  if args.first.is_a?( Array )
156
163
  points = args.shift || []
157
164
  raise ArgumentError, "Must specify an array of data points" if points.empty?
158
165
  points.insert( 0, legend )
159
- @series << points
166
+ @series_desc << points
160
167
  else
161
168
  raise ArgumentError, "Must specify an array of data points"
162
169
  end
@@ -178,6 +185,9 @@ module Ziya::Charts
178
185
  theme = args.first.is_a?(String) ? args.shift : ""
179
186
  raise ArgumentError, "Must specify a theme name" if theme.to_s.empty?
180
187
  @theme = "#{Ziya.themes_dir}/#{theme}"
188
+ when :mode
189
+ @render_mode = args.first.is_a?(Integer) ? args.shift : -1
190
+ raise ArgumentError, "Must specify a valid generation mode" if @render_mode == -1
181
191
  else raise ArgumentError, "Invalid directive must be one of " +
182
192
  ":axis_category_text, :axis_value, :series, :user_data"
183
193
  end
@@ -194,13 +204,15 @@ module Ziya::Charts
194
204
  @xml.instruct! :xml, :version => "1.0", :encoding => "UTF-8"
195
205
  @xml.chart do
196
206
  @xml.license( @license ) unless @license.nil?
197
- if !@type.nil?
198
- @xml.chart_type( @type )
199
- elsif @options[:chart_types].is_a? Array and ! @options[:chart_types].empty?
200
- @xml.chart_type do
201
- @options[:chart_types].each { |type| @xml.string( type ) }
207
+ if render_parents?
208
+ if !@type.nil?
209
+ @xml.chart_type( @type )
210
+ elsif @options[:chart_types].is_a? Array and ! @options[:chart_types].empty?
211
+ @xml.chart_type do
212
+ @options[:chart_types].each { |type| @xml.string( type ) }
213
+ end
202
214
  end
203
- end
215
+ end
204
216
  setup_lnf
205
217
  setup_series
206
218
  end
@@ -394,13 +406,13 @@ module Ziya::Charts
394
406
  # Lay down graph data points and labels if any
395
407
  # TODO Validate series sizes/label sizes
396
408
  def setup_series
397
- raise "You must specify an axis_category_text with your series." if !@series.empty? and ! @options[:axis_category_text]
409
+ raise "You must specify an axis_category_text with your series." if !@series_desc.empty? and ! @options[:axis_category_text]
398
410
 
399
411
  if @options[:axis_category_text]
400
412
  @xml.chart_data do
401
413
  gen_data_points( :axis_category_text )
402
414
  # render xml for each series
403
- @series.each do |series|
415
+ @series_desc.each do |series|
404
416
  gen_chart_data( series )
405
417
  end
406
418
  end
@@ -437,14 +449,21 @@ module Ziya::Charts
437
449
  end.compact!
438
450
  end
439
451
 
452
+ # -------------------------------------------------------------------------
453
+ # Check if we should do the all monty or just render the instance styles
454
+ def render_parents?
455
+ (@render_mode == Base.all_styles)
456
+ end
457
+
440
458
  # -------------------------------------------------------------------------
441
459
  # Load up look and feel data
442
460
  def load_lnf
443
461
  unless @partial
444
462
  ancestors.each do |super_class|
463
+ o = nil
445
464
  if ( super_class == self.class )
446
465
  # Load class instance prefs
447
- o = inflate( super_class, theme )
466
+ o = inflate( super_class, theme ) if render_parents?
448
467
  setup_state( o ) unless o.nil?
449
468
  # Now load instance prefs if any
450
469
  unless id.nil?
@@ -452,7 +471,7 @@ module Ziya::Charts
452
471
  setup_state( o ) unless o.nil?
453
472
  end
454
473
  else
455
- o = inflate( super_class, theme, nil )
474
+ o = inflate( super_class, theme, nil ) if render_parents?
456
475
  setup_state( o ) unless o.nil?
457
476
  end
458
477
  end
@@ -0,0 +1,18 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Generates necessary xml for donut chart
3
+ #
4
+ # Author: Fernand
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/charts/base'
7
+
8
+ module Ziya::Charts
9
+ class Donut < Base
10
+ # Creates a donut 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 = "donut"
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # -----------------------------------------------------------------------------
2
+ # Defines an area on a chart. Typically used to embed links and buttons
3
+ #
4
+ # Author:: Fernand Galiana
5
+ # -----------------------------------------------------------------------------
6
+ require 'ziya/components/base'
7
+
8
+ module Ziya::Components
9
+ # Refines the default context menu by adding or removing default options
10
+ # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=context_menu
11
+ # for additional documentation, examples and futher detail.
12
+ class ContextMenu < Base
13
+ has_attribute :about, :print, :full_screen, :quality, :jpeg_url
14
+ end
15
+ 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
data/lib/ziya/version.rb CHANGED
@@ -2,7 +2,7 @@ module Ziya
2
2
  module Version
3
3
  MAJOR = 2
4
4
  MINOR = 0
5
- TINY = 0
5
+ TINY = 1
6
6
 
7
7
  # Returns the version string for the library.
8
8
  #
@@ -1,18 +1,18 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper]))
2
2
 
3
- describe Ziya::Components::SeriesSwitch do
3
+ describe Ziya::Components::Series do
4
4
  before( :each ) do
5
- @comp = Ziya::Components::SeriesSwitch.new
5
+ @comp = Ziya::Components::Series.new
6
6
  end
7
7
 
8
8
  it "should define the correct attribute methods" do
9
- lambda{ Ziya::Components::SeriesSwitch.attributes[@comp.class.name].each {
9
+ lambda{ Ziya::Components::Series.attributes[@comp.class.name].each {
10
10
  |m| @comp.send( m ) } }.should_not raise_error
11
11
  end
12
12
 
13
13
  it "should flatten component correctly" do
14
14
  xml = Builder::XmlMarkup.new
15
15
  @comp.switch = false
16
- @comp.flatten( xml ).should == "<series_switch>false</series_switch>"
16
+ @comp.flatten( xml ).should == "<series>false</series>"
17
17
  end
18
18
  end
@@ -0,0 +1,39 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), %w[.. spec_helper]))
2
+
3
+ describe Ziya::Components::SeriesExplode do
4
+ before( :each ) do
5
+ @comp = Ziya::Components::SeriesExplode.new
6
+ end
7
+
8
+ it "should define the correct attribute methods" do
9
+ lambda{ Ziya::Components::SeriesExplode.attributes[@comp.class.name].each {
10
+ |m| @comp.send( m ) } }.should_not raise_error
11
+ end
12
+
13
+ describe "#flatten" do
14
+ before( :each ) do
15
+ @xml = Builder::XmlMarkup.new
16
+ @results = "<series_explode><number>10</number><number>20</number><number>30</number></series_explode>"
17
+ end
18
+
19
+ it "should flatten string explode version correctly" do
20
+ @comp.numbers = "10,20,30"
21
+ @comp.flatten( @xml ).should == @results
22
+ end
23
+
24
+ it "should flatten string numbers with spaces explode version correctly" do
25
+ @comp.numbers = "10 , 20 , 30"
26
+ @comp.flatten( @xml ).should == @results
27
+ end
28
+
29
+ it "should flatten single string explode version correctly" do
30
+ @comp.numbers = 10
31
+ @comp.flatten( @xml ).should == "<series_explode><number>10</number></series_explode>"
32
+ end
33
+
34
+ it "should flatten array explode version correctly" do
35
+ @comp.numbers = %w[10 20 30]
36
+ @comp.flatten( @xml ).should == @results
37
+ end
38
+ end
39
+ end
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.0
4
+ version: 2.0.1
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-08-19 00:00:00 -06:00
12
+ date: 2008-08-20 00:00:00 -06:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -55,6 +55,7 @@ files:
55
55
  - charts/charts_library/cls3.swf
56
56
  - charts/charts_library/clst.swf
57
57
  - charts/charts_library/cnno.swf
58
+ - charts/charts_library/dono.swf
58
59
  - charts/charts_library/lnno.swf
59
60
  - charts/charts_library/mxno.swf
60
61
  - charts/charts_library/pi3d.swf
@@ -62,9 +63,11 @@ files:
62
63
  - charts/charts_library/pono.swf
63
64
  - charts/charts_library/scno.swf
64
65
  - charts/full_screen.swf
66
+ - charts/scripts/output_jpg.php
65
67
  - charts/sliders/black.swf
66
68
  - charts/sliders/preview_handle_1.swf
67
69
  - charts/sliders/preview_handle_2.swf
70
+ - cp_doc.sh
68
71
  - fred.rb
69
72
  - gauges/designs/circle.yml
70
73
  - gauges/designs/signal.yml
@@ -80,6 +83,7 @@ files:
80
83
  - lib/ziya/charts/candle_stick.rb
81
84
  - lib/ziya/charts/column.rb
82
85
  - lib/ziya/charts/column_threed.rb
86
+ - lib/ziya/charts/donut.rb
83
87
  - lib/ziya/charts/floating_bar.rb
84
88
  - lib/ziya/charts/floating_column.rb
85
89
  - lib/ziya/charts/line.rb
@@ -110,6 +114,7 @@ files:
110
114
  - lib/ziya/components/chart_rect.rb
111
115
  - lib/ziya/components/chart_transition.rb
112
116
  - lib/ziya/components/circle.rb
117
+ - lib/ziya/components/context_menu.rb
113
118
  - lib/ziya/components/draw.rb
114
119
  - lib/ziya/components/draw_base.rb
115
120
  - lib/ziya/components/filter.rb
@@ -121,10 +126,9 @@ files:
121
126
  - lib/ziya/components/link_data.rb
122
127
  - lib/ziya/components/rect.rb
123
128
  - lib/ziya/components/scroll.rb
129
+ - lib/ziya/components/series.rb
124
130
  - lib/ziya/components/series_color.rb
125
131
  - lib/ziya/components/series_explode.rb
126
- - lib/ziya/components/series_gap.rb
127
- - lib/ziya/components/series_switch.rb
128
132
  - lib/ziya/components/shadow.rb
129
133
  - lib/ziya/components/text.rb
130
134
  - lib/ziya/components/update.rb
@@ -161,9 +165,10 @@ files:
161
165
  - spec/components/draw_spec.rb
162
166
  - spec/components/filter_spec.rb
163
167
  - spec/components/link_spec.rb
168
+ - spec/components/series.rb
164
169
  - spec/components/series_color_spec.rb
170
+ - spec/components/series_explode.rb
165
171
  - spec/components/series_explode_spec.rb
166
- - spec/components/series_switch_spec.rb
167
172
  - spec/designs/circle.yml
168
173
  - spec/designs/crapping_out.yml
169
174
  - spec/designs/gauge_1.yml
@@ -1,18 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Sets up the gap between bars/columns for bar and column charts.
3
- #
4
- # Applies to column and bar charts only, and sets the gap between bars and sets of bars.
5
- #
6
- # <tt></tt>:
7
- #
8
- # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=series_gap
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 SeriesGap < Base
16
- has_attribute :bar_gap, :set_gap
17
- end
18
- end
@@ -1,25 +0,0 @@
1
- # -----------------------------------------------------------------------------
2
- # Sets up whether to switch colors for each element in a serie. Only applies
3
- # to chart with only one serie
4
- #
5
- # Switches the series colors to be used for the categories instead.
6
- #
7
- # <tt></tt>:
8
- #
9
- # See http://www.maani.us/xml_charts/index.php?menu=Reference&submenu=series_switch
10
- # for additional documentation, examples and futher detail.
11
- #
12
- # Author:: Fernand Galiana
13
- # Date:: Dec 15th, 2006
14
- # -----------------------------------------------------------------------------
15
- module Ziya::Components
16
- class SeriesSwitch < Base
17
- has_attribute :switch
18
-
19
- # -------------------------------------------------------------------------
20
- # Dump has_attribute into xml element
21
- def flatten( xml )
22
- xml.series_switch( switch )
23
- end
24
- end
25
- end