|
|
@ -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 |
|
|
@ -78,42 +79,43 @@ Copyright 2005 Sandia National Laboratories |
|
|
|
stagger_x_labels= False |
|
|
|
stagger_x_labels= False |
|
|
|
rotate_x_labels= False |
|
|
|
rotate_x_labels= False |
|
|
|
step_x_labels= 1 |
|
|
|
step_x_labels= 1 |
|
|
|
step_include_first_x_label= True |
|
|
|
step_include_first_x_label= True |
|
|
|
show_y_labels= True |
|
|
|
show_y_labels= True |
|
|
|
rotate_y_labels= False |
|
|
|
rotate_y_labels= False |
|
|
|
stagger_y_labels= False |
|
|
|
stagger_y_labels= False |
|
|
|
step_include_first_y_label= True |
|
|
|
step_include_first_y_label= True |
|
|
|
step_y_labels= 1 |
|
|
|
step_y_labels= 1 |
|
|
|
scale_integers= False |
|
|
|
scale_integers= False |
|
|
|
show_x_title= False |
|
|
|
show_x_title= False |
|
|
|
x_title= 'X Field names' |
|
|
|
x_title= 'X Field names' |
|
|
|
show_y_title= False |
|
|
|
show_y_title= False |
|
|
|
y_title_text_direction= 'bt' # 'bt' for bottom to top; 'tb' for top to bottom |
|
|
|
y_title_text_direction= 'bt' # 'bt' for bottom to top; 'tb' for top to bottom |
|
|
|
y_title= 'Y Scale' |
|
|
|
y_title= 'Y Scale' |
|
|
|
show_graph_title= False |
|
|
|
show_graph_title= False |
|
|
|
graph_title= 'Graph Title' |
|
|
|
graph_title= 'Graph Title' |
|
|
|
show_graph_subtitle= False |
|
|
|
show_graph_subtitle= False |
|
|
|
graph_subtitle= 'Graph Subtitle' |
|
|
|
graph_subtitle= 'Graph Subtitle' |
|
|
|
key= True |
|
|
|
key= True |
|
|
|
key_position= 'right' # 'bottom' or 'right', |
|
|
|
key_position= 'right' # 'bottom' or 'right', |
|
|
|
|
|
|
|
|
|
|
|
font_size= 12 |
|
|
|
font_size= 12 |
|
|
|
title_font_size= 16 |
|
|
|
title_font_size= 16 |
|
|
|
subtitle_font_size= 14 |
|
|
|
subtitle_font_size= 14 |
|
|
|
x_label_font_size= 12 |
|
|
|
x_label_font_size= 12 |
|
|
|
x_title_font_size= 14 |
|
|
|
x_title_font_size= 14 |
|
|
|
y_label_font_size= 12 |
|
|
|
y_label_font_size= 12 |
|
|
|
y_title_font_size= 14 |
|
|
|
y_title_font_size= 14 |
|
|
|
key_font_size= 10 |
|
|
|
key_font_size= 10 |
|
|
|
|
|
|
|
|
|
|
|
no_css= False |
|
|
|
no_css= False |
|
|
|
add_popups= False |
|
|
|
add_popups= False |
|
|
|
|
|
|
|
|
|
|
|
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() |
|
|
|
|
|
|
|
|
|
|
@ -476,26 +478,26 @@ Copyright 2005 Sandia National Laboratories |
|
|
|
def draw_graph_subtitle( self ): |
|
|
|
def draw_graph_subtitle( self ): |
|
|
|
raise NotImplementedError |
|
|
|
raise NotImplementedError |
|
|
|
|
|
|
|
|
|
|
|
def draw_x_title( self ): |
|
|
|
def draw_x_title( self ): |
|
|
|
raise NotImplementedError |
|
|
|
raise NotImplementedError |
|
|
|
|
|
|
|
|
|
|
|
def draw_y_title( self ): |
|
|
|
def draw_y_title( self ): |
|
|
|
x = self.y_title_font_size |
|
|
|
x = self.y_title_font_size |
|
|
|
if self.y_title_text_direction=='bt': |
|
|
|
if self.y_title_text_direction=='bt': |
|
|
|
x += 3 |
|
|
|
x += 3 |
|
|
|
rotate = -90 |
|
|
|
rotate = -90 |
|
|
|
else: |
|
|
|
else: |
|
|
|
x -= 3 |
|
|
|
x -= 3 |
|
|
|
rotate = 90 |
|
|
|
rotate = 90 |
|
|
|
y = self.height / 2 |
|
|
|
y = self.height / 2 |
|
|
|
text = self._create_element( 'text', { |
|
|
|
text = self._create_element( 'text', { |
|
|
|
'x': str( x ), |
|
|
|
'x': str( x ), |
|
|
|
'y': str( y ), |
|
|
|
'y': str( y ), |
|
|
|
'class': 'yAxisTitle', |
|
|
|
'class': 'yAxisTitle', |
|
|
|
} ) |
|
|
|
} ) |
|
|
|
text.appendChild( self._doc.createTextNode( self.y_title ) ) |
|
|
|
text.appendChild( self._doc.createTextNode( self.y_title ) ) |
|
|
|
text.setAttribute( 'transform', 'rotate( %(rotate)d, %(x)s, %(y)s )' % vars() ) |
|
|
|
text.setAttribute( 'transform', 'rotate( %(rotate)d, %(x)s, %(y)s )' % vars() ) |
|
|
|
self.root.appendChild( text ) |
|
|
|
self.root.appendChild( text ) |
|
|
|
|
|
|
|
|
|
|
|
def keys( self ): |
|
|
|
def keys( self ): |
|
|
|
return map( itemgetter( 'title' ), self.data ) |
|
|
|
return map( itemgetter( 'title' ), self.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' ): |
|
|
|