/
pie.rb
75 lines (61 loc) · 1.28 KB
/
pie.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
module OpenFlashChart
class PieValue < Base
def initialize(value, label, args={})
super args
@value = value
@label = label
@animate = []
end
def set_label(label, label_color, font_size)
self.label = label
self.label_colour = label_color
self.font_size = font_size
end
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 = []
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
@no_labels = true
end
def on_click(event)
@on_click = event
end
end
end