diff --git a/assets/open-flash-chart.swf b/assets/open-flash-chart.swf index 6f5f46f..3a01e52 100644 Binary files a/assets/open-flash-chart.swf and b/assets/open-flash-chart.swf differ diff --git a/lib/open_flash_chart/bar_base.rb b/lib/open_flash_chart/bar_base.rb index 53cce15..089ff25 100644 --- a/lib/open_flash_chart/bar_base.rb +++ b/lib/open_flash_chart/bar_base.rb @@ -1,3 +1,7 @@ module OpenFlashChart - class BarBase < Base; end + class BarBase < Base + def attach_to_right_y_axis + @axis = 'right' + end + end end diff --git a/lib/open_flash_chart/bar_glass.rb b/lib/open_flash_chart/bar_glass.rb index d44345a..5e0d5c9 100644 --- a/lib/open_flash_chart/bar_glass.rb +++ b/lib/open_flash_chart/bar_glass.rb @@ -1,5 +1,13 @@ module OpenFlashChart + class BarOnShow < Base + def initialize(type, cascade, delay) + @type = type + @cascade = cascade.to_f + @delay = delay.to_f + end + end + class BarGlass < BarBase def initialize args={} super @@ -7,6 +15,48 @@ def initialize args={} end end + class BarCylinder < BarBase + def initialize args={} + super + @type = "bar_cylinder" + end + end + + class BarCylinderOutline < BarBase + def initialize args={} + super + @type = "bar_cylinder_outline" + end + end + + class BarRoundedGlass < BarBase + def initialize args={} + super + @type = "bar_rounded_glass" + end + end + + class BarRound < BarBase + def initialize args={} + super + @type = "bar_round" + end + end + + class BarDome < BarBase + def initialize args={} + super + @type = "bar_dome" + end + end + + class BarRound3d < BarBase + def initialize args={} + super + @type = "bar_round3d" + end + end + class BarGlassValue < Base def initialize(top, args={}) @top = top @@ -14,4 +64,4 @@ def initialize(top, args={}) end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/bar_stack.rb b/lib/open_flash_chart/bar_stack.rb index 6ebe08a..2af5719 100644 --- a/lib/open_flash_chart/bar_stack.rb +++ b/lib/open_flash_chart/bar_stack.rb @@ -17,4 +17,13 @@ def initialize(val,colour, args={}) end end -end \ No newline at end of file + class BarStackKey < Base + def initialize(colour, text, font_size, args={}) + @colour = colour + @text = text + @font_size = font_size + super + end + end + +end diff --git a/lib/open_flash_chart/base.rb b/lib/open_flash_chart/base.rb index 94a32d7..6269554 100644 --- a/lib/open_flash_chart/base.rb +++ b/lib/open_flash_chart/base.rb @@ -24,9 +24,19 @@ def render # 9) tick_length as tick-length # 10) visible_steps as visible-steps # 11) key_on_click as key-on-click + # 12) barb_length as barb-length + # 13) on_show as on-show + # 14) negative_colour as negative-colour + # 15) line_style as line-style + # 16) on_click as on-click + # 17) javascript_function_name as javascript-function-name + # 18) pad_x to pad-x + # 19) pad_y to pad-y + # 20) align_x to align-x + # 21) align_y to align-y returning self.to_json2 do |output| output.gsub!("threed","3d") - %w(font_size dot_size outline_colour halo_size start_angle tick_height grid_colour tick_length no_labels label_colour gradient_fill fill_alpha on_click spoke_labels visible_steps key_on_click).each do |replace| + %w(font_size dot_size outline_colour halo_size start_angle tick_height grid_colour tick_length no_labels label_colour gradient_fill fill_alpha on_click spoke_labels visible_steps key_on_click barb_length on_show negative_colour line_style javascript_function_name pad_x pad_y align_x align_y).each do |replace| output.gsub!(replace, replace.gsub("_", "-")) end end @@ -83,6 +93,11 @@ def set_tooltip(tip) end alias_method "tooltip=", :set_tooltip + def attach_to_right_y_axis + @axis = 'right' + end + + def method_missing(method_name, *args, &blk) diff --git a/lib/open_flash_chart/candle.rb b/lib/open_flash_chart/candle.rb index 8127424..11fc0f4 100644 --- a/lib/open_flash_chart/candle.rb +++ b/lib/open_flash_chart/candle.rb @@ -1,20 +1,22 @@ module OpenFlashChart class Candle < Base - def initialize(args={}) + def initialize(colour, negative_colour, args={}) + @colour = colour + @negative_colour = negative_colour super args @type = "candle" end end class CandleValue < Base - def initialize( top, bottom, low, high, args={} ) - @top = top - @bottom = bottom + def initialize( high, open, close low, args={} ) + @top = open + @bottom = close @low = low @high = high super args end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/h_bar.rb b/lib/open_flash_chart/h_bar.rb index face8c2..c3a7c20 100644 --- a/lib/open_flash_chart/h_bar.rb +++ b/lib/open_flash_chart/h_bar.rb @@ -3,7 +3,7 @@ module OpenFlashChart class HBarValue < Base def initialize(left,right=nil, args={}) super args - @left = left + @left = left if right @right = right || left end end @@ -23,4 +23,4 @@ def set_values(v) end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/line.rb b/lib/open_flash_chart/line.rb index 0d5b9bc..fbe4155 100644 --- a/lib/open_flash_chart/line.rb +++ b/lib/open_flash_chart/line.rb @@ -1,10 +1,23 @@ module OpenFlashChart + class LineOnShow < Base + def initialize(type, cascade, delay) + @type = type + @cascade = cascade.to_F + @delay = delay.to_f + end + end + class Line < LineBase def initialize args={} super @type = "line" + @values = [] + end + + def set_default_dot_style(style) + @dot_style = style end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/line_base.rb b/lib/open_flash_chart/line_base.rb index 8cdd4ac..199a609 100644 --- a/lib/open_flash_chart/line_base.rb +++ b/lib/open_flash_chart/line_base.rb @@ -3,10 +3,10 @@ module OpenFlashChart class LineBase < Base def initialize args={} super - @type = "line_dot" + @type = "line" @text = "Page Views" @font_size = 10 - @values = [9,6,7,9,5,7,6,9,7] + @values = [] end def loop @@ -14,4 +14,4 @@ def loop end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/pie.rb b/lib/open_flash_chart/pie.rb index b219fca..1ef5596 100644 --- a/lib/open_flash_chart/pie.rb +++ b/lib/open_flash_chart/pie.rb @@ -5,6 +5,7 @@ def initialize(value, label, args={}) super args @value = value @label = label + @animate = [] end def set_label(label, label_color, font_size) @@ -16,18 +17,54 @@ def set_label(label, label_color, font_size) def on_click(event) @on_click = event end + + def add_animation animation + @animate ||= [] + @animate << animation + return self + end + end + + class BasePieAnimation < Base; end + + class PieFade < BasePieAnimation + def initialize args={} + @type = "fade" + super + end + end + + class PieBounce < BasePieAnimation + def initialize distance, args={} + @type = "bounce" + @distance = distance + super + end end class Pie < Base def initialize args={} @type = "pie" - @colours = ["#d01f3c","#356aa0","#C79810"] - @border = 2 + @colours = [] super end + def set_animate bool + self.add_animation PieFade.new if bool + end + + def add_animation animation + @animate ||= [] + @animate << animation + return self + end + + def set_gradient_fill + @gradient_fill = true + end + def set_no_labels - self.no_labels = true + @no_labels = true end def on_click(event) @@ -35,4 +72,4 @@ def on_click(event) end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/scatter.rb b/lib/open_flash_chart/scatter.rb index d5d8eeb..0a43e54 100644 --- a/lib/open_flash_chart/scatter.rb +++ b/lib/open_flash_chart/scatter.rb @@ -13,9 +13,10 @@ class Scatter < Base def initialize(colour, dot_size, args={}) @type = "scatter" @colour = colour - @dot_size = dot_size + @dot_style = dot_style + @values = [] super args end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/scatter_line.rb b/lib/open_flash_chart/scatter_line.rb index 67193d4..3b2e8ac 100644 --- a/lib/open_flash_chart/scatter_line.rb +++ b/lib/open_flash_chart/scatter_line.rb @@ -1,12 +1,20 @@ module OpenFlashChart class ScatterLine < Base - def initialize(colour, dot_size, args={}) + def initialize(colour, width, args={}) super args @type = 'scatter_line' @colour = colour - @dot_size = dot_size + @width = width + end + + def set_step_horizonal + @stepgraph = 'horizontal' + end + + def set_step_vertical + @stepgraph = 'vertical' end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/x_axis_labels.rb b/lib/open_flash_chart/x_axis_labels.rb index fb26cb0..ef180af 100644 --- a/lib/open_flash_chart/x_axis_labels.rb +++ b/lib/open_flash_chart/x_axis_labels.rb @@ -2,8 +2,8 @@ module OpenFlashChart class XAxisLabels < Base def set_vertical - @rotate = "vertical" + @rotate = 270 end end -end \ No newline at end of file +end diff --git a/lib/open_flash_chart/y_axis_base.rb b/lib/open_flash_chart/y_axis_base.rb index c005526..f1097ac 100644 --- a/lib/open_flash_chart/y_axis_base.rb +++ b/lib/open_flash_chart/y_axis_base.rb @@ -1,3 +1,7 @@ module OpenFlashChart - class YAxisBase < Base; end + class YAxisBase < Base + def set_vertical + @rotate = "vertical" + end + end end diff --git a/lib/open_flash_chart/y_axis_right.rb b/lib/open_flash_chart/y_axis_right.rb index a70eadb..66a431e 100644 --- a/lib/open_flash_chart/y_axis_right.rb +++ b/lib/open_flash_chart/y_axis_right.rb @@ -1,3 +1,4 @@ module OpenFlashChart - class YAxisRight < YAxisBase; end + class YAxisRight < YAxisBase + end end