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 | import cjson
|
---|
18 |
|
---|
19 | from openFlashChart_elements import (title,
|
---|
20 | x_legend,
|
---|
21 | y_legend,
|
---|
22 | x_axis,
|
---|
23 | y_axis,
|
---|
24 | radar_axis,
|
---|
25 | tooltip)
|
---|
26 |
|
---|
27 |
|
---|
28 | def flashHTML(width, height, url, ofc_base_url="/flashes/", ofc_swf="OFC.swf" ):
|
---|
29 | return (
|
---|
30 | """
|
---|
31 | <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
|
---|
32 | codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,115,0"
|
---|
33 | width="%(width)s" height="%(height)s" id="chart" align="middle">
|
---|
34 | <param name="allowScriptAccess" value="sameDomain"/>
|
---|
35 | <param name="movie" value="%(ofc_base_url)s%(ofc_swf)s"/>
|
---|
36 | <param name="FlashVars" value="data-file=%(url)s"/>
|
---|
37 | <param name="quality" value="high"/>
|
---|
38 | <param name="bgcolor" value="#FFFFFF"/>
|
---|
39 | <embed src="%(ofc_base_url)s%(ofc_swf)s" FlashVars="data-file=%(url)s" quality="high" bgcolor="#FFFFFF"
|
---|
40 | width=%(width)s height=%(height)s name="chart" align="middle" allowScriptAccess="sameDomain"
|
---|
41 | type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"/>
|
---|
42 | </object>
|
---|
43 | """) % locals()
|
---|
44 |
|
---|
45 |
|
---|
46 |
|
---|
47 | class template(dict):
|
---|
48 | def __init__(self, title_string, style = None):
|
---|
49 | self['title'] = title(title_string, style)
|
---|
50 |
|
---|
51 | def set_x_legend(self, legend, style):
|
---|
52 | self['x_legend'] = x_legend(legend, style)
|
---|
53 |
|
---|
54 | def set_y_legend(self, legend, style):
|
---|
55 | self['y_legend'] = y_legend(legend, style)
|
---|
56 |
|
---|
57 | def set_x_axis(self, stroke = None, tick_height = None, colour = None, grid_colour = None, labels = None, three_d = None, max = None, min = None, steps = None, offset = None):
|
---|
58 | self['x_axis'] = x_axis(stroke, tick_height, colour, grid_colour, labels, three_d, max, min, steps, offset)
|
---|
59 |
|
---|
60 | def set_y_axis(self, stroke = None, tick_length = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, offset = None):
|
---|
61 | self['y_axis'] = y_axis(stroke, tick_length, colour, grid_colour, labels, max, min, steps, offset)
|
---|
62 |
|
---|
63 | def set_y_axis_right(self, stroke = None, tick_length = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, offset = None):
|
---|
64 | self['y_axis_right'] = y_axis(stroke, tick_length, colour, grid_colour, labels, max, min, steps, offset)
|
---|
65 |
|
---|
66 | def set_radar_axis(self, stroke = None, tick_height = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, spoke_labels = None):
|
---|
67 | self['radar_axis'] = radar_axis(stroke, tick_height, colour, grid_colour, labels, max, min, steps, spoke_labels)
|
---|
68 |
|
---|
69 |
|
---|
70 | def set_bg_colour(self, colour):
|
---|
71 | self['bg_colour'] = colour
|
---|
72 |
|
---|
73 | def set_tooltip(self, shadow = None, stroke = None, colour = None, bg_colour = None, title_style = None, body_style = None, behaviour = None):
|
---|
74 | self['tooltip'] = tooltip(shadow, stroke, colour, bg_colour, title_style, body_style, behaviour)
|
---|
75 |
|
---|
76 | def add_element(self, element):
|
---|
77 | try:
|
---|
78 | self['elements'].append(element)
|
---|
79 | except:
|
---|
80 | self['elements'] = [element]
|
---|
81 |
|
---|
82 | def encode(self):
|
---|
83 | return cjson.encode(self)
|
---|
84 |
|
---|
85 |
|
---|
86 |
|
---|
87 |
|
---|
88 |
|
---|