Formatters Reference

cubes.create_formatter(formatter_type, convert_options=False, **options)

Create a formatter of type formatter_type with initialization options.

If convert_values is True then values are considered to be strings and are converted into their respective types as specified in the formatter metadata. This should be used as convenience conversion from web server, for example.

cubes.register_formatter(formatter_type, factory)

Register formatter factory with type name formatter_type

Formatters

class cubes.TextTableFormatter(measure_format=None)
class cubes.SimpleDataTableFormatter(count_label=None, levels=None)

Creates a formatter that formats result into a tabular structure. count_label is default label to be used for record_count aggregation.

class cubes.SimpleHTMLTableFormatter(count_label=None, create_links=True, table_style=None)

Create a simple HTML table formatter

class cubes.CrossTableFormatter(measures_as=None, measure_labels=None, aggregation_labels=None, measure_label_format=None, count_label=None)

Creates a cross-table formatter.

Arguments:

  • measures_as – specify how to put measures in the table. Might be one of rows, columns or cells (default).
  • measure_labels – dictionary of labels to be used for measures
  • aggregation_labels – dictionary of labels of aggregations, used for default measure labeling
  • measure_label_format – format string for measure label, default is {measure} ({aggregation})
  • count_label – label to be used for record count. Overrides default setting

If measures are put on rows or columns, then respective row or column is added per measure. The data contains single measure values.

If measures are put in the table as cells, then the data contains tuples of measures in the order as specified in the measures argument of format() method.

If no measure_labels is provided or no key for a measure is found in the dictionary, then the label is constructect with form: “Measure (aggregation)”, for example: “Amount (sum)”.

If aggregation_labels is provided, then it is used to give measure aggregation label.

format(result, onrows=None, oncolumns=None, measures=None, measures_as=None)

Creates a cross table from a drilldown (might be any list of records). onrows contains list of attribute names to be placed at rows and oncolumns contains list of attribute names to be placet at columns. measures is a list of measures to be put into cells. If measures are not specified, then only record_count is used.

Returns a named tuble with attributes:

  • columns - labels of columns. The tuples correspond to values of attributes in oncolumns.
  • rows - labels of rows as list of tuples. The tuples correspond to values of attributes in onrows.
  • data - list of measure data per row. Each row is a list of measure tuples.
class cubes.HTMLCrossTableFormatter(measures_as=None, measure_labels=None, aggregation_labels=None, measure_label_format=None, count_label=None, table_style=None)

Create a simple HTML table formatter. See CrossTableFormatter for information about arguments.

See also

formatters
Formatters documentation.

Table Of Contents

Previous topic

Aggregation Browser Reference

Next topic

Aggregation Browsing Backends

This Page