Back to index

moin  1.9.0~rc2
Public Member Functions | Public Attributes | Static Public Attributes
MoinMoin.stats.chart.Chart Class Reference

List of all members.

Public Member Functions

def __init__
def addData
def option
def draw

Public Attributes

 options
 datasets

Static Public Attributes

tuple DEFAULTS = gdchart.option()

Detailed Description

Wrapper for "gdchart".

    All GDC* constants are available as class attributes.

Definition at line 37 of file chart.py.


Constructor & Destructor Documentation

Definition at line 45 of file chart.py.

00045 
00046     def __init__(self):
00047         # Get a copy of the default options
00048         self.options = self.DEFAULTS.copy()
00049         self.datasets = []
00050 
00051         self.option(
00052             bg_color=0xffffff,
00053             line_color=0x000000,
00054         )


Member Function Documentation

def MoinMoin.stats.chart.Chart.addData (   self,
  data 
)

Definition at line 55 of file chart.py.

00055 
00056     def addData(self, data):
00057         self.datasets.append(data)

def MoinMoin.stats.chart.Chart.draw (   self,
  style,
  size,
  output,
  labels = None 
)

Definition at line 62 of file chart.py.

00062 
00063     def draw(self, style, size, output, labels=None):
00064         args = []
00065         colors = []
00066         for dataset in self.datasets:
00067             if isinstance(dataset, ChartData):
00068                 args.append(dataset.data)
00069                 colors.append(dataset.color)
00070             else:
00071                 args.append(dataset)
00072                 colors.append('black')
00073 
00074         # Default for X axis labels (numbered 1..n)
00075         if not labels:
00076             labels = [str(i) for i in range(1, len(args[0])+1)]
00077 
00078         # set colors for the data sets
00079         if colors:
00080             self.option(set_color=[int(Color(c)) for c in colors])
00081 
00082         # pass options to gdchart and render the chart
00083         gdchart.option(**self.options)
00084 
00085         # limit label length in order to workaround bugs in gdchart
00086         labels = [x[:32] for x in labels]
00087         gdchart.chart(*((style, size, output, labels) + tuple(args)))
00088 
00089 
# copy GDC constants to Chart's namespace

Here is the call graph for this function:

def MoinMoin.stats.chart.Chart.option (   self,
  args 
)

Definition at line 58 of file chart.py.

00058 
00059     def option(self, **args):
00060         # Save option values in the object's dictionary.
00061         self.options.update(args)

Here is the caller graph for this function:


Member Data Documentation

Definition at line 48 of file chart.py.

tuple MoinMoin.stats.chart.Chart.DEFAULTS = gdchart.option() [static]

Definition at line 43 of file chart.py.

Definition at line 47 of file chart.py.


The documentation for this class was generated from the following file: