Browse Source

minor improvements

pull/8/head
jaraco 17 years ago
parent
commit
d1f2523f80
  1. 9
      lib/SVG/__init__.py
  2. 21
      test/testing.py

9
lib/SVG/__init__.py

@ -1,3 +1,4 @@
#!python
# -*- coding: UTF-8 -*- # -*- coding: UTF-8 -*-
__all__ = ( 'Plot', 'TimeSeries' ) __all__ = ( 'Plot', 'TimeSeries' )
@ -66,7 +67,7 @@ Stephen Morgan for creating the TT template and SVG.
Jason R. Coombs <jaraco@jaraco.com> Jason R. Coombs <jaraco@jaraco.com>
Copyright 2005 Sandia National Laboratories Copyright © 2008 Jason R. Coombs
""" """
width= 500 width= 500
height= 300 height= 300
@ -112,8 +113,9 @@ Copyright 2005 Sandia National Laboratories
top_align = top_font = right_align = right_font = 0 top_align = top_font = right_align = right_font = 0
def __init__( self, config = {} ): def __init__( self, config = {} ):
"""Initialize the graph object with the graph settings. You won't """Initialize the graph object with the graph settings."""
instantiate this class directly; see the subclass for options.""" if self.__class__ is Graph:
raise NotImplementedError, "Graph is an abstract base class"
self.load_config( config ) self.load_config( config )
self.clear_data() self.clear_data()
@ -563,7 +565,6 @@ Copyright 2005 Sandia National Laboratories
def start_svg( self ): def start_svg( self ):
"Base SVG Document Creation" "Base SVG Document Creation"
impl = dom.getDOMImplementation() impl = dom.getDOMImplementation()
#dt = impl.createDocumentType( 'svg', 'PUBLIC'
self._doc = impl.createDocument( None, 'svg', None ) self._doc = impl.createDocument( None, 'svg', None )
self.root = self._doc.documentElement self.root = self._doc.documentElement
if hasattr( self, 'style_sheet' ): if hasattr( self, 'style_sheet' ):

21
test/testing.py

@ -1,9 +1,5 @@
import sys, os import sys, os
#sys.path.insert( 0, 'c:\documents and settings\jaraco\my documents\projects\jaraco' )
import SVG
from SVG import Plot from SVG import Plot
reload( SVG )
reload( Plot )
g = Plot.Plot( { g = Plot.Plot( {
'min_x_value': 0, 'min_x_value': 0,
'min_y_value': 0, 'min_y_value': 0,
@ -12,25 +8,24 @@ g = Plot.Plot( {
'stagger_y_labels': True, 'stagger_y_labels': True,
'show_x_guidelines': True 'show_x_guidelines': True
}) })
g.add_data( { 'data': [ 1, 25, 2, 30, 3, 45 ], 'title': 'foo' } ) g.add_data( { 'data': [ 1, 25, 2, 30, 3, 45 ], 'title': 'series 1' } )
g.add_data( { 'data': [ 1,30, 2, 31, 3, 40 ], 'title': 'foo2' } ) g.add_data( { 'data': [ 1,30, 2, 31, 3, 40 ], 'title': 'series 2' } )
g.add_data( { 'data': [ .5,35, 1, 20, 3, 10.5 ], 'title': 'foo2' } ) g.add_data( { 'data': [ .5,35, 1, 20, 3, 10.5 ], 'title': 'series 3' } )
res = g.burn() res = g.burn()
f = open( r'c:\sample.svg', 'w' ) f = open( r'Plot.py.svg', 'w' )
f.write( res ) f.write( res )
f.close() f.close()
from SVG import TimeSeries from SVG import TimeSeries
reload( TimeSeries )
g = TimeSeries.Plot( { } ) g = TimeSeries.Plot( { } )
g.timescale_divisions = '4 hours' g.timescale_divisions = '4 hours'
g.stagger_x_labels = True g.stagger_x_labels = True
g.x_label_format = '%d-%b' g.x_label_format = '%d-%b %H:%M'
#g.max_y_value = 200 g.max_y_value = 200
g.add_data( { 'data': [ '2005-12-21T00:00:00', 20, '2005-12-22T00:00:00', 21 ], 'title': 'foo' } ) g.add_data( { 'data': [ '2005-12-21T00:00:00', 20, '2005-12-22T00:00:00', 21 ], 'title': 'series 1' } )
res = g.burn() res = g.burn()
print g.field_width print g.field_width
@ -39,6 +34,6 @@ print g.right_font
print g.right_align print g.right_align
print g.get_x_labels() print g.get_x_labels()
f = open( r'c:\timeseries.py.svg', 'w' ) f = open( r'TimeSeries.py.svg', 'w' )
f.write( res ) f.write( res )
f.close() f.close()

Loading…
Cancel
Save