source: code/Website/python-ofc-library-2/openFlashChart_elements.py@ 7849

Last change on this file since 7849 was 7849, checked in by dennisw, 15 years ago
File size: 4.4 KB
Line 
1# This program is free software; you can redistribute it and/or modify
2# it under the terms of the GNU General Public License as published by
3# the Free Software Foundation; version 2 of the License.
4#
5# This program is distributed in the hope that it will be useful,
6# but WITHOUT ANY WARRANTY; without even the implied warranty of
7# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
8# GNU General Public License for more details.
9#
10# Author: Emanuel Fonseca
11# Email: emdfonseca<at>gmail<dot>com
12# Date: 25 August 2008
13#
14# Author: Eugene Kin Chee Yip
15# Date: 7 Nov 2008
16
17
18
19
20##########################################
21# title class
22class title(dict):
23 def __init__(self, title, style=None):
24 self['text'] = title
25 self.set_style(style)
26
27 def set_style(self, style):
28 self['style'] = style if style else '{color: #000000; font-size: 12px;}'
29
30class y_legend(title):
31 pass
32
33class x_legend(title):
34 pass
35
36##########################################
37# axis classes
38class axis(dict):
39 def __init__(self, stroke = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, offset = None):
40 self.set_stroke(stroke)
41 self.set_colour(colour)
42 self.set_grid_colour(grid_colour)
43 self.set_labels(labels)
44 self.set_steps(steps)
45 self.set_offset(offset)
46 self.set_max(max)
47 self.set_min(min)
48
49 def set_stroke(self, stroke):
50 if stroke:
51 self['stroke'] = stroke
52
53 def set_colour(self, colour):
54 if colour:
55 self['colour'] = colour
56
57 def set_grid_colour(self, grid_colour):
58 if grid_colour:
59 self['grid-colour'] = grid_colour
60
61 def set_labels(self, labels):
62 if labels:
63 self['labels'] = labels
64
65 def set_steps(self, steps):
66 if steps:
67 self['steps'] = steps
68
69 def set_offset(self, offset):
70 if offset is not None:
71 self['offset'] = offset
72
73 def set_max(self, max):
74 if max:
75 self['max'] = max
76
77 def set_min(self, min):
78 if min:
79 self['min'] = min
80
81class x_axis(axis):
82 def __init__(self, stroke = None, tick_height = None, colour = None, grid_colour = None, labels = None, three_d = None, max = None, min = None, steps = None, offset = None):
83 axis.__init__(self, stroke, colour, grid_colour, labels, max, min, steps, offset)
84 self.set_tick_height(tick_height)
85 self.set_3d(three_d)
86
87 def set_tick_height(self, tick_height):
88 if tick_height:
89 self['tick-height'] = tick_height
90
91 def set_3d(self, three_d):
92 if three_d:
93 self['3d'] = three_d
94
95class y_axis(axis):
96 def __init__(self, stroke = None, tick_length = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, offset = None):
97 axis.__init__(self, stroke, colour, grid_colour, labels, max, min, steps, offset)
98 self.set_tick_length(tick_length)
99 self.set_offset(offset)
100
101 def set_tick_length(self, tick_length):
102 if tick_length:
103 self['tick-length'] = tick_length
104
105class radar_axis(axis):
106 def __init__(self, stroke = None, tick_height = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, spoke_labels = None):
107 axis.__init__(self, stroke, colour, grid_colour, labels, max, min, steps)
108 self.set_tick_height(tick_height)
109 self.set_spoke_labels(spoke_labels)
110
111 def set_tick_height(self, tick_height):
112 if tick_height:
113 self['tick-height'] = tick_height
114
115 def set_spoke_labels(self, spoke_labels):
116 if spoke_labels:
117 self['spoke-labels'] = {'labels': spoke_labels}
118
119
120##########################################
121# tooltip class
122class tooltip(dict):
123 def __init__(self, shadow = None, stroke = None, colour = None, bg_colour = None, title_style = None, body_style = None, behaviour = None):
124 self.set_shadow(shadow)
125 self.set_stroke(stroke)
126 self.set_colour(colour)
127 self.set_background(bg_colour)
128 self.set_title(title_style)
129 self.set_body(body_style)
130 self.set_behaviour(behaviour)
131
132 def set_shadow(self, shadow):
133 if shadow is not None:
134 self['shadow'] = shadow
135
136 def set_stroke(self, stroke):
137 if stroke:
138 self['stroke'] = stroke
139
140 def set_colour(self, colour):
141 if colour:
142 self['colour'] = colour
143
144 def set_background(self, background):
145 if background:
146 self['background'] = background
147
148 def set_title(self, title):
149 if title:
150 self['title'] = title
151
152 def set_body(self, body):
153 if body:
154 self['body'] = body
155
156 def set_behaviour(self, behaviour):
157 if behaviour == 'proximity':
158 self['mouse'] = 1
159 if behaviour == 'hover':
160 self['mouse'] = 2
161
162
163
Note: See TracBrowser for help on using the repository browser.