Series#
- class leather.Series(data, x=None, y=None, name=None)#
Bases:
object
A series of data and its associated metadata.
Series object does not modify the data it is passed.
- Parameters:
data –
A sequence (rows) of sequences (columns), a.k.a.
csv.reader()
format. If thex
andy
are not specified then the first column is used as the X values and the second column is used for Y.Or, a sequence of (rows) of dicts (columns), a.k.a.
csv.DictReader
format. If this format is used thenx
andy
arguments must specify the columns to be charted.Or, a custom data format, in which case
x
andy
must specifykey_function()
.x –
If using sequence row data, then this may be either an integer index identifying the X column, or a
key_function()
.If using dict row data, then this may be either a key name identifying the X column, or a
key_function()
.If using a custom data format, then this must be a
key_function()
.`y – See
x
.name – An optional name to be used in labeling this series. This will be used as the chart title if rendered in a
Lattice
.
- data_type(dimension)#
Return the data type for a dimension of this series.
- data()#
Return data for this series.
- values(dimension)#
Get a flattened list of values for a given dimension of the data.
- min(dimension)#
Compute the minimum value of a given dimension.
- max(dimension)#
Compute the minimum value of a given dimension.
- leather.key_function(row, index)#
This example shows how to define a function to extract X and Y values from custom data.
- Parameters:
row – The function will be called with the row data, in whatever format it was provided to the
Series
.index – The row index in the series data will also be provided.
- Returns:
The function must return a chartable value.