openFlashChart_elements.py 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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. # title class
  18. class title(dict):
  19. def __init__(self, title, style=None):
  20. self['text'] = title
  21. self.set_style(style)
  22. def set_style(self, style):
  23. self['style'] = style if style else '{color: #000000; font-size: 12px;}'
  24. class y_legend(title):
  25. pass
  26. class x_legend(title):
  27. pass
  28. ##########################################
  29. # axis classes
  30. class axis(dict):
  31. def __init__(self, stroke = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, offset = None):
  32. self.set_stroke(stroke)
  33. self.set_colour(colour)
  34. self.set_grid_colour(grid_colour)
  35. self.set_labels(labels)
  36. self.set_steps(steps)
  37. self.set_offset(offset)
  38. self.set_max(max)
  39. self.set_min(min)
  40. def set_stroke(self, stroke):
  41. if stroke:
  42. self['stroke'] = stroke
  43. def set_colour(self, colour):
  44. if colour:
  45. self['colour'] = colour
  46. def set_grid_colour(self, grid_colour):
  47. if grid_colour:
  48. self['grid-colour'] = grid_colour
  49. def set_labels(self, labels):
  50. if labels:
  51. self['labels'] = labels
  52. def set_steps(self, steps):
  53. if steps:
  54. self['steps'] = steps
  55. def set_offset(self, offset):
  56. if offset is not None:
  57. self['offset'] = offset
  58. def set_max(self, max):
  59. if max:
  60. self['max'] = max
  61. def set_min(self, min):
  62. if min:
  63. self['min'] = min
  64. class x_axis(axis):
  65. 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):
  66. axis.__init__(self, stroke, colour, grid_colour, labels, max, min, steps, offset)
  67. self.set_tick_height(tick_height)
  68. self.set_3d(three_d)
  69. def set_tick_height(self, tick_height):
  70. if tick_height:
  71. self['tick-height'] = tick_height
  72. def set_3d(self, three_d):
  73. if three_d:
  74. self['3d'] = three_d
  75. class y_axis(axis):
  76. def __init__(self, stroke = None, tick_length = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, offset = None):
  77. axis.__init__(self, stroke, colour, grid_colour, labels, max, min, steps, offset)
  78. self.set_tick_length(tick_length)
  79. self.set_offset(offset)
  80. def set_tick_length(self, tick_length):
  81. if tick_length:
  82. self['tick-length'] = tick_length
  83. class radar_axis(axis):
  84. def __init__(self, stroke = None, tick_height = None, colour = None, grid_colour = None, labels = None, max = None, min = None, steps = None, spoke_labels = None):
  85. axis.__init__(self, stroke, colour, grid_colour, labels, max, min, steps)
  86. self.set_tick_height(tick_height)
  87. self.set_spoke_labels(spoke_labels)
  88. def set_tick_height(self, tick_height):
  89. if tick_height:
  90. self['tick-height'] = tick_height
  91. def set_spoke_labels(self, spoke_labels):
  92. if spoke_labels:
  93. self['spoke-labels'] = {'labels': spoke_labels}
  94. ##########################################
  95. # tooltip class
  96. class tooltip(dict):
  97. def __init__(self, shadow = None, stroke = None, colour = None, bg_colour = None, title_style = None, body_style = None, behaviour = None):
  98. self.set_shadow(shadow)
  99. self.set_stroke(stroke)
  100. self.set_colour(colour)
  101. self.set_background(bg_colour)
  102. self.set_title(title_style)
  103. self.set_body(body_style)
  104. self.set_behaviour(behaviour)
  105. def set_shadow(self, shadow):
  106. if shadow is not None:
  107. self['shadow'] = shadow
  108. def set_stroke(self, stroke):
  109. if stroke:
  110. self['stroke'] = stroke
  111. def set_colour(self, colour):
  112. if colour:
  113. self['colour'] = colour
  114. def set_background(self, background):
  115. if background:
  116. self['background'] = background
  117. def set_title(self, title):
  118. if title:
  119. self['title'] = title
  120. def set_body(self, body):
  121. if body:
  122. self['body'] = body
  123. def set_behaviour(self, behaviour):
  124. if behaviour == 'proximity':
  125. self['mouse'] = 1
  126. if behaviour == 'hover':
  127. self['mouse'] = 2