Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.stsci.edu/spst/UnixTransition/doc/barchart.html
Дата изменения: Fri Apr 8 12:46:14 2016
Дата индексирования: Sun Apr 10 23:10:44 2016
Кодировка:
Python: module barchart
 
 
barchart (version $Id: barchart.py,v 2.1 1999/03/17 03:13:39 friedric Exp $, June 30, 1997)
index
barchart.py

Provides BarChart class which creates HTML 1D bar charts,
and StackedBarChart class to deal with multiple data plotting
for web pages. Only works for positive data values.
Also provides a DataList class to support the data handling needed.

 
Modules
       
UserList
string

 
Classes
       
UserList.UserList(_abcoll.MutableSequence)
DataList
BarChart
StackedBarChart

 
class BarChart
    Class which takes a DataList object and creates
the HTML to represent a color coded bar chart.
 
Values to be charted are limited to non-negative values.
 
  Methods defined here:
__init__(self, datalist=None)
datalist is an instance of class DataList
__str__(self)
Generate HTML for the entire table and caption.
color_code(self, value)
return a color string based on whether the given datum
falls beyond thresholds. Works off self.thresholds=(low,hi).
gen_bar(self, value, color='blue')
return Image object for the scaled bar graphic
gen_legend(self)
Return an HTML string which displays the legend for the chart.
initialize(self)
Initialize the chart properties.
 
This method is overloaded by child classes.
make_bar_cell(self, dict)
return a TD object containing the scaled bar
normalize(self)
Scale data to values between 0 and 400.
 
Determine peak value and set scale accordingly.  If the values
are clustered within 30% of each other, will shift the zero
point for the barchart up to exagerate the value differences.
To inhibit this, set the .bound_zero attribute to "yes".
pixels(self, magnitude)
returns the integer number of pixels to represent a given magnitude.

Data and other attributes defined here:
bar_shade = '#DDDDDD'
label_shade = '#FFFFFF'
max_width = 400
title = ''
value_shade = '#9999CC'
zero = 0

 
class DataList(UserList.UserList)
    Class supporting tabular storage and access of data.
 
Used by BarChart classes. Takes a list of sequences and loads
them into a list of dictionaries using the first item from the
sequence as a label key. The column names are from the
segment_names* attribute and *must be set prior to loading
multidimensional data. 
 
Supports some simple data processing methods.
 
 
Method resolution order:
DataList
UserList.UserList
_abcoll.MutableSequence
_abcoll.Sequence
_abcoll.Sized
_abcoll.Iterable
_abcoll.Container
__builtin__.object

Methods defined here:
__init__(self, list=None)
__str__(self)
Return tabular string representation of internal data.
add_column(self, name, pairs)
Take list of (label,value) pairs and add the data as a
new column named name.
cache_labels(self)
Create cache of indexes corresponding to the labels
to speed calles to index method.
decreasing(self, a, b)
increasing(self, a, b)
index(self, label)
return dictionary corresponding to label string.
load_tuple(self, t)
Load individual record of data into new dictionary.
 
Use first item in given sequence as label key and assigns
remaining items with keys from segment_names in order.
load_tuples(self, tt)
Load each item from the given sequence of sequences.
max(self, key='value')
return maximum value in column key
mean(self, key='value')
return mean (average) of values in column key
min(self, key='value')
return minimum value in column key
sort(self, key='label', direction='increasing')
Sort list according to key in direction.
 
Example: DLobject.sort('height', 'decreasing')
sum(self, key='value')
return sum of values in column key
sum_totals(self)
add new key 'total' to each dictionary

Data and other attributes defined here:
__abstractmethods__ = frozenset([])
segment_names = ('value',)

Methods inherited from UserList.UserList:
__add__(self, other)
__cmp__(self, other)
__contains__(self, item)
__delitem__(self, i)
__delslice__(self, i, j)
__eq__(self, other)
__ge__(self, other)
__getitem__(self, i)
__getslice__(self, i, j)
__gt__(self, other)
__iadd__(self, other)
__imul__(self, n)
__le__(self, other)
__len__(self)
__lt__(self, other)
__mul__(self, n)
__ne__(self, other)
__radd__(self, other)
__repr__(self)
__rmul__ = __mul__(self, n)
__setitem__(self, i, item)
__setslice__(self, i, j, other)
append(self, item)
count(self, item)
extend(self, other)
insert(self, i, item)
pop(self, i=-1)
remove(self, item)
reverse(self)

Data and other attributes inherited from UserList.UserList:
__hash__ = None

Methods inherited from _abcoll.Sequence:
__iter__(self)
__reversed__(self)

Class methods inherited from _abcoll.Sized:
__subclasshook__(cls, C) from abc.ABCMeta

Data descriptors inherited from _abcoll.Sized:
__dict__
dictionary for instance variables (if defined)
__weakref__
list of weak references to the object (if defined)

Data and other attributes inherited from _abcoll.Sized:
__metaclass__ = <class 'abc.ABCMeta'>
Metaclass for defining Abstract Base Classes (ABCs).
 
Use this metaclass to create an ABC.  An ABC can be subclassed
directly, and then acts as a mix-in class.  You can also register
unrelated concrete classes (even built-in classes) and unrelated
ABCs as 'virtual subclasses' -- these and their descendants will
be considered subclasses of the registering ABC by the built-in
issubclass() function, but the registering ABC won't show up in
their MRO (Method Resolution Order) nor will method
implementations defined by the registering ABC be callable (not
even via super()).

 
class StackedBarChart(BarChart)
    Represent up to six data values in a stacked barchart.
 
  Methods defined here:
gen_bar(self, values, colors)
return HTML string for the stacked bar graphic.
gen_legend(self)
Return an HTML string which displays the legend for the chart.
initialize(self)
Define StackedBarChart specific attributes.
make_bar_cell(self, dict)
return a TD object containing the scaled bar
segment(self, value, color='blue')
return HTML string for a bar segment given a magnitude and color.

Methods inherited from BarChart:
__init__(self, datalist=None)
datalist is an instance of class DataList
__str__(self)
Generate HTML for the entire table and caption.
color_code(self, value)
return a color string based on whether the given datum
falls beyond thresholds. Works off self.thresholds=(low,hi).
normalize(self)
Scale data to values between 0 and 400.
 
Determine peak value and set scale accordingly.  If the values
are clustered within 30% of each other, will shift the zero
point for the barchart up to exagerate the value differences.
To inhibit this, set the .bound_zero attribute to "yes".
pixels(self, magnitude)
returns the integer number of pixels to represent a given magnitude.

Data and other attributes inherited from BarChart:
bar_shade = '#DDDDDD'
label_shade = '#FFFFFF'
max_width = 400
title = ''
value_shade = '#9999CC'
zero = 0

 
Functions
       
simple_test()
stacked_test()
test()

 
Data
        AQUA = '#33CCCC'
BLACK = '#000000'
BLUE = '#0000FF'
BLUE1 = '#0000FF'
BLUE2 = '#0000EE'
BLUE3 = '#0000DD'
BLUE4 = '#0000CC'
BLUE5 = '#0000BB'
BLUE6 = '#000099'
BROWN = '#CC9966'
CADETBLUE = '#9999CC'
COPPER = '#CC6600'
GRAY = '#0C0C0C'
GRAY1 = '#EEEEEE'
GRAY2 = '#DDDDDD'
GRAY3 = '#CCCCCC'
GRAY4 = '#BBBBBB'
GRAY5 = '#AAAAAA'
GRAY6 = '#999999'
GREEN = '#00DD00'
GREEN1 = '#00EE00'
GREEN2 = '#00DD00'
GREEN3 = '#00CC00'
GREEN4 = '#00BB00'
GREEN5 = '#00AA00'
GREEN6 = '#009900'
GREY = '#0C0C0C'
GREY1 = '#EEEEEE'
GREY2 = '#DDDDDD'
GREY3 = '#CCCCCC'
GREY4 = '#BBBBBB'
GREY5 = '#AAAAAA'
GREY6 = '#999999'
LIME = '#CCFF66'
MOROON = '#CC3366'
OLIVE = '#999966'
ORANGE = '#FFCC33'
PEACH = '#FFCC99'
PINK = '#FF99CC'
PURPLE = '#CC66FF'
RED = '#EE0000'
RED1 = '#FF0000'
RED2 = '#EE0000'
RED3 = '#DD0000'
RED4 = '#CC0000'
RED5 = '#BB0000'
RED6 = '#990000'
SEAGREEN = '#0099CC'
SKYBLUE = '#99CCFF'
TAN = '#FFCCCC'
WHITE = '#FFFFFF'
YELLOW = '#FFFF66'
__author__ = 'Robin Friedrich'
__date__ = 'June 30, 1997'
__version__ = '$Id: barchart.py,v 2.1 1999/03/17 03:13:39 friedric Exp $'
barfiles = {'blue': '../image/bar-blue.gif', 'green': '../image/bar-green.gif', 'orange': '../image/bar-orange.gif', 'purple': '../image/bar-purple.gif', 'red': '../image/bar-red.gif', 'yellow': '../image/bar-yellow.gif'}

 
Author
        Robin Friedrich