├── .gitignore ├── LICENSE ├── MANIFEST.in ├── NEWS.rst ├── README.rst ├── pyofc2 ├── __init__.py └── ofc2.py ├── setup.cfg └── setup.py /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *~ 3 | build/ 4 | dist/ 5 | PyOFC2.egg-info/ 6 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | PyOFC2 - Python libraries for Open Flash Chart. 2 | Copyright 2009 Pradeep Kishore Gowda 3 | 4 | Permission is hereby granted, free of charge, to any person 5 | obtaining a copy of this software and associated documentation 6 | files (the "Software"), to deal in the Software without 7 | restriction, including without limitation the rights to use, 8 | copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the 10 | Software is furnished to do so, subject to the following 11 | conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 18 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 20 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 21 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 23 | OTHER DEALINGS IN THE SOFTWARE. 24 | -------------------------------------------------------------------------------- /MANIFEST.in: -------------------------------------------------------------------------------- 1 | include README.rst 2 | include NEWS.rst 3 | -------------------------------------------------------------------------------- /NEWS.rst: -------------------------------------------------------------------------------- 1 | NEWS 2 | ==== 3 | 4 | 0.1.5 5 | ----- 6 | 7 | *Release Date: 2010-09-21* 8 | 9 | * Fixed setup bug. Thx http://github.com/marcinn 10 | 11 | 12 | 0.1.4 13 | ----- 14 | *Release Date: 2010-09-21* 15 | 16 | * converted README to `.rst`. Added `NEWS.rst` for project release information. 17 | * better pypi documentation. 18 | 19 | 20 | 0.1.3 21 | ----- 22 | *Release Date: 2010-09-21* 23 | 24 | * Added `bar_on_show` option. Thanks to `lukaszb `_. 25 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | PyOFC2 - Python libraries for Open Flash Chart 2 | ============================================== 3 | 4 | PyOFC2 generates data files required for `Open Flash Chart 2 `_. 5 | 6 | Installation 7 | ------------ 8 | 9 | Using `Python Packaging Index `_: 10 | 11 | $ easy_install PyOFC2 12 | 13 | From the source: 14 | 15 | $ git://github.com/btbytes/pyofc2.git 16 | 17 | Online `Demo `_. 18 | 19 | 20 | Using PyOFC2 with Web Frameworks 21 | -------------------------------- 22 | `Django + PyOFC2 `_ example project. 23 | 24 | -------------------------------------------------------------------------------- /pyofc2/__init__.py: -------------------------------------------------------------------------------- 1 | # 2 | from ofc2 import * -------------------------------------------------------------------------------- /pyofc2/ofc2.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # encoding: utf-8 3 | """ 4 | ofc2.py 5 | 6 | Created by Pradeep Gowda on 2009-01-01. 7 | Copyright (c) 2009 Pradeep Gowda. 8 | Permission is hereby granted, free of charge, to any person 9 | obtaining a copy of this software and associated documentation 10 | files (the "Software"), to deal in the Software without 11 | restriction, including without limitation the rights to use, 12 | copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the 14 | Software is furnished to do so, subject to the following 15 | conditions: 16 | 17 | The above copyright notice and this permission notice shall be 18 | included in all copies or substantial portions of the Software. 19 | 20 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 21 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 22 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 23 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 24 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 25 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 27 | OTHER DEALINGS IN THE SOFTWARE. 28 | """ 29 | 30 | import anyjson 31 | 32 | class OFCBase(dict): 33 | type = None 34 | replace = { 35 | 'font_size':'font-size', 'fontsize': 'font-size', 36 | 'color':'colour', 'bg_color':'bg_colour', 'bgcolor':'bg_colour', 37 | 'dot_size': 'dot-size', 'dotsize':'dot-size', 'grid_colour': 'grid-colour', 38 | 'dot_style': 'dot-style', 39 | 'grid_color': 'grid-colour', 'tick_height': 'tick-height', 40 | 'on_click':'on-click', 'outline_color':'outline-colour', 41 | 'outline_colour':'outline-colour', 'fill_color':'fill', 42 | 'fill_colour':'fill', 'fill_alpha':'fill-alpha', 43 | 'halo_size':'halo-size', 'halosize':'halo-size', 44 | 'proximity': 'mouse', 'spoke_labels':'spoke-labels', 45 | 'visible_steps': 'visible-steps', 46 | 'javascript_function': 'javascript-function', 47 | 'on_show':'on-show', 48 | } 49 | 50 | def __setattr__(self, k, w): 51 | if k in self.acceptable: 52 | if k in self.replace.keys(): 53 | k = self.replace[k] 54 | self[k] = w 55 | self.__dict__.update({k:w}) 56 | 57 | 58 | def ofc_init(self, **kw): 59 | for k,w in kw.items(): 60 | if k in self.acceptable: 61 | if k in self.replace.keys(): 62 | k = self.replace[k] 63 | self[k] = w 64 | self.__dict__.update({k:w}) 65 | 66 | 67 | def ofc_factory(classname, acceptable): 68 | klass = type(classname, (OFCBase, ), {'acceptable':acceptable}) 69 | setattr(klass, '__init__', ofc_init ) 70 | return klass 71 | 72 | title = ofc_factory('title', ['text','style']) 73 | class x_legend(title): pass 74 | class y_legend(title): pass 75 | 76 | labels = ofc_factory('labels', ['labels', 'text']) 77 | x_axis_label = ofc_factory('x_axis_label', ['text', 'steps', 'color', 'colour', 'size', 'visible', 'rotate' ]) 78 | x_axis_labels = ofc_factory('x_axis_labels', ['labels', 'rotate', 'steps', 'text', 'visible_steps']) 79 | radar_axis_labels = ofc_factory('radar_axis_labels', ['labels']) 80 | radar_spoke_labels = ofc_factory('radar_spoke_labels',['labels']) 81 | shapefactory = ofc_factory('_shape', ['type','colour', 'color', 'values']) 82 | shape = lambda **kw: shapefactory(type='shape', **kw) 83 | shape_value = ofc_factory('shape_value', ['x', 'y']) 84 | 85 | axis = ofc_factory('axis', ['stroke', 'tick_height', 'colour', 86 | 'grid_colour', 'steps', 'min', 'max', 'labels', 'offset', 'radar', 87 | 'spoke_labels' 88 | ]) 89 | class x_axis(axis): pass 90 | class y_axis(axis): pass 91 | class y_axis_right(axis): pass 92 | class radar_axis(axis): pass 93 | 94 | tooltip = ofc_factory('tooltip', ['shadow', 'stroke', 'colour', 'bg_colour', 'title_style', 'body_style', 'proximity']) 95 | 96 | element = ofc_factory('element', ['type','alpha', 'colour', 'color', 'text', 'fontsize', 'values']) 97 | 98 | entry = ofc_factory('values', ['text', 'fontsize', 'colour', 'color']) 99 | 100 | linefactory = ofc_factory('_line', ['type','alpha', 'colour','color', 'text', 101 | 'fontsize', 'font_size', 'values', 'halo_size', 'width', 'dot_size', 'on_click', 'tip', 102 | 'loop', 'dot_style', 'axis']) 103 | line = lambda **kw: linefactory(type='line',**kw) 104 | line_dot = lambda **kw: linefactory(type='line_dot', **kw) 105 | line_hollow = lambda **kw: linefactory(type='line_hollow', **kw) 106 | 107 | key = ofc_factory('key', ['text', 'size', 'colour', 'font-size']) 108 | dot_value = ofc_factory('value', ['value', 'colour', 'color', 'tip']) 109 | dotfactory = ofc_factory('_dot-style', ['type', 'dot_style', 'dot_size', 'halo_size', 'colour', 'rotation', 'hollow', 'on_click', 'style']) 110 | dot = lambda **kw: dotfactory(type='solid-dot', **kw) 111 | hollowdot = lambda **kw: dotfactory(type='hollow-dot', **kw) 112 | stardot = lambda **kw: dotfactory(type='star', **kw) 113 | 114 | bar_on_show = ofc_factory('_bar_on_show', ['type', 'cascade', 'delay']) 115 | 116 | barfactory = ofc_factory('_bar', ['type', 'values', 'alpha', 'color', 117 | 'colour', 'key', 'on_click', 'on_show', 'axis', 'text', 'tip']) 118 | bar = lambda **kw: barfactory(type='bar',**kw) 119 | bar_glass = lambda **kw: barfactory(type='bar_glass',**kw) 120 | 121 | barvalue = ofc_factory('values', ['colour', 'value', 'tip', 'top', 'bottom']) 122 | 123 | barfilledfactory = ofc_factory('_bar', ['type', 'values', 'alpha', 'color', 124 | 'colour', 'key', 'outline_colour', 'outline_color', 'on_show']) 125 | bar_filled = lambda **kw: barfilledfactory(type='bar_filled',**kw) 126 | 127 | hbarfactory = ofc_factory('_hbar', ['type', 'values', 'color', 'colour', 'tooltip', 'tip']) 128 | hbar = lambda **kw: hbarfactory(type='hbar', **kw) 129 | hbar_value = ofc_factory('hbar_factory', ['left', 'right', 'tip']) 130 | 131 | barstackfactory = ofc_factory('_barstack', ['type', 'values', 'keys', 'tip', 'color', 'colours', 'on_click']) 132 | bar_stack = lambda **kw: barstackfactory(type='bar_stack',**kw) 133 | 134 | area_linefactory = ofc_factory('_area_line', ['type', 'values', 'color', 'colour', 135 | 'tooltip', 'width', 'dot_size', 'dotsize', 'halo_size', 'halosize' 'key', 'fill_colour', 136 | 'fill_color', 'fill_alpha', 'loop', 'axis']) 137 | area_line = lambda **kw: area_linefactory(type='area_line', **kw) 138 | area_hollow = lambda **kw: area_linefactory(type='area_hollow', **kw) 139 | 140 | scatter_value = ofc_factory('values', ['x','y']) 141 | scatterfactory = ofc_factory('_scatter', ['type', 'dot_size', 'color', 'colour', 'values']) 142 | scatter = lambda **kw: scatterfactory(type='scatter', **kw) 143 | scatter_line = lambda **kw: scatterfactory(type='scatter_line', **kw) 144 | 145 | pie_value = ofc_factory('values', ['label', 'label-color', 'font-size', 'tooltip', 'color', 'colour', 'value', 'tip', 'on_click']) 146 | piefactory = ofc_factory('_pie', ['alpha', 'colour', 'color', 'text', 147 | 'fontsize', 'values', 'start_angle', 'animate', 'colours', 'label_colour', 148 | 'on_click', 'radius', 'type', 'tip']) 149 | pie = lambda **kw: piefactory(type='pie', **kw) 150 | 151 | menu = ofc_factory('menu', ['colour', 'outline_colour', 'values']) 152 | menu_value = ofc_factory('menu_item', ['type', 'text', 'javascript_function']) 153 | 154 | #TODO: derive open_flash_chart class from OFCBase . use ofc_factory 155 | class open_flash_chart(OFCBase): 156 | typetable = { 157 | 'title': title, 158 | 'x_legend':x_legend, 159 | 'y_legend':y_legend, 160 | 'x_axis': x_axis, 161 | 'y_axis': y_axis, 162 | 'y_axis_right': y_axis_right, 163 | 'tooltip' : tooltip, 164 | 'radar_axis': radar_axis, 165 | 'menu': menu, 166 | } 167 | 168 | def __setattr__(self, k, w): 169 | super(OFCBase, self).__setattr__(k,w) 170 | if k in self.typetable.keys(): 171 | assert(isinstance(w, self.typetable[k])) 172 | self[k] = w 173 | 174 | def add_element(self, element): 175 | try: 176 | self['elements'].append(element) 177 | except: 178 | self['elements'] = [element] 179 | 180 | def add_menu_value(self, menu_value): 181 | self['menu'] = self.get('menu', {}) 182 | try: 183 | self['menu']['values'].append(menu_value) 184 | except: 185 | self['menu']['values'] = [menu_value] 186 | 187 | def __str__(self): 188 | return anyjson.serialize(self) 189 | 190 | def render(self): 191 | return anyjson.serialize(self) 192 | -------------------------------------------------------------------------------- /setup.cfg: -------------------------------------------------------------------------------- 1 | [egg_info] 2 | tag_build = dev 3 | tag_svn_revision = true 4 | -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | from setuptools import setup, find_packages 2 | import sys, os 3 | here = os.path.abspath(os.path.dirname(__file__)) 4 | README = open(os.path.join(here, 'README.rst')).read() 5 | NEWS = open(os.path.join(here, 'NEWS.rst')).read() 6 | 7 | 8 | version = '0.1.5' 9 | 10 | setup(name='PyOFC2', 11 | version=version, 12 | description="Python library for Open Flash Chart 2", 13 | long_description=README + "\n\n" + NEWS, 14 | classifiers=[ 15 | "Development Status :: 4 - Beta", 16 | "License :: OSI Approved :: MIT License", 17 | "Operating System :: OS Independent", 18 | "Topic :: Internet", 19 | 20 | ], # Get strings from http://pypi.python.org/pypi?%3Aaction=list_classifiers 21 | keywords='flash graphics charts json visualisation visualization internet', 22 | author='Pradeep Kishore Gowda', 23 | author_email='pradeep+pyofc2@btbytes.com', 24 | url='http://pradeepgowda.com/', 25 | license='MIT', 26 | packages=find_packages(exclude=['ez_setup', 'examples', 'tests']), 27 | include_package_data=True, 28 | zip_safe=False, 29 | install_requires=[ 30 | "anyjson>=0.1", 31 | ], 32 | entry_points=""" 33 | # -*- Entry points: -*- 34 | """, 35 | ) 36 | --------------------------------------------------------------------------------