fireant.widgets package¶
Submodules¶
fireant.widgets.base module¶
-
class
fireant.widgets.base.
TransformableWidget
(*items)[source]¶ Bases:
fireant.widgets.base.Widget
-
group_pagination
= False¶
-
transform
(data_frame, slicer, dimensions, references)[source]¶ - Main entry point -
Transformers the result set pd.DataFrame from a slicer query into the output format for this specific widget type.
Parameters: - data_frame – The data frame containing the data. Index must match the dimensions parameter.
- slicer – The slicer that is in use.
- dimensions – A list of dimensions that are being rendered.
- references – A list of references that are being rendered.
Returns: A dict meant to be dumped as JSON.
-
fireant.widgets.chart_base module¶
-
class
fireant.widgets.chart_base.
Axis
(series: Iterable[fireant.widgets.chart_base.Series], label=None, y_axis_visible=True)[source]¶ Bases:
object
-
class
fireant.widgets.chart_base.
ChartWidget
(*items)[source]¶ Bases:
fireant.widgets.base.Widget
-
class
AreaPercentageSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.AreaSeries
-
stacking
= 'percent'¶
-
-
class
AreaSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.ContinuousAxisSeries
-
type
= 'area'¶
-
-
class
AreaStackedSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.AreaSeries
-
stacking
= 'normal'¶
-
-
class
BarSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.Series
-
type
= 'bar'¶
-
-
class
ColumnSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.Series
-
type
= 'column'¶
-
-
class
LineSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.ContinuousAxisSeries
-
type
= 'line'¶
-
-
class
PieSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.Series
-
type
= 'pie'¶
-
-
class
StackedBarSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.BarSeries
-
stacking
= 'normal'¶
-
-
class
StackedColumnSeries
(metric: Union[fireant.dataset.fields.Field, fireant.dataset.operations.Operation], stacking=None)[source]¶ Bases:
fireant.widgets.chart_base.ColumnSeries
-
stacking
= 'normal'¶
-
-
axis
(*args, mutate=False, **kwargs)¶ Parameters: mutate – When True, overrides the immutable behavior of this decorator.
-
metrics
¶ Returns: A set of metrics used in this chart. This collects all metrics across all axes.
-
operations
¶
-
class
fireant.widgets.csv module¶
fireant.widgets.highcharts module¶
-
class
fireant.widgets.highcharts.
HighCharts
(title=None, colors=None, x_axis_visible=True, tooltip_visible=True)[source]¶ Bases:
fireant.widgets.chart_base.ChartWidget
,fireant.widgets.base.TransformableWidget
-
group_pagination
= True¶
-
transform
(data_frame, slicer, dimensions, references)[source]¶ - Main entry point -
Transforms a data frame into HighCharts JSON format.
See https://api.highcharts.com/highcharts/
Parameters: - data_frame – The data frame containing the data. Index must match the dimensions parameter.
- slicer – The slicer that is in use.
- dimensions – A list of dimensions that are being rendered.
- references – A list of references that are being rendered.
Returns: A dict meant to be dumped as JSON.
-
fireant.widgets.matplotlib module¶
-
class
fireant.widgets.matplotlib.
Matplotlib
(title=None)[source]¶ Bases:
fireant.widgets.chart_base.ChartWidget
,fireant.widgets.base.TransformableWidget
-
transform
(data_frame, slicer, dimensions, references)[source]¶ - Main entry point -
Transformers the result set pd.DataFrame from a slicer query into the output format for this specific widget type.
Parameters: - data_frame – The data frame containing the data. Index must match the dimensions parameter.
- slicer – The slicer that is in use.
- dimensions – A list of dimensions that are being rendered.
- references – A list of references that are being rendered.
Returns: A dict meant to be dumped as JSON.
-
fireant.widgets.pandas module¶
-
class
fireant.widgets.pandas.
Pandas
(metric: fireant.dataset.fields.Field, *metrics, pivot=(), transpose=False, sort=None, ascending=None, max_columns=None)[source]¶ Bases:
fireant.widgets.base.TransformableWidget
-
pivot_data_frame
(data_frame, pivot=(), transpose=False)[source]¶ Pivot and transpose the data frame. Dimensions including in the pivot arg will be unshifted to columns. If transpose is True the data frame will be transposed. If there is only index level in the data frame (ie. one dimension), and that dimension is pivoted, then the data frame will just be transposed. If there is a single metric in the data frame and at least one dimension pivoted, the metrics column level will be dropped for simplicity.
Parameters: - data_frame – The result set data frame
- pivot – A list of index aliases for data_frame of levels to shift
- transpose – A boolean true or false whether to transpose the data frame.
Returns: The shifted/transposed data frame
-
fireant.widgets.reacttable module¶
-
class
fireant.widgets.reacttable.
ReactTable
(metric, *metrics, pivot=(), transpose=False, sort=None, ascending=None, max_columns=None)[source]¶ Bases:
fireant.widgets.pandas.Pandas
This component does not work with react-table out of the box, some customization is needed in order to work with the transformed data.
// A Custom TdComponent implementation is required by Fireant in order to render display values const TdComponent = ({ toggleSort, className, children, ...rest }) => <div className={classNames('rt-td', className)} role="gridcell" {...rest}> {_.get(children, 'display', children.raw) || <span> </span>} </div>; const FireantReactTable = ({ config, // The payload from fireant }) => <ReactTable columns={config.columns} data={config.data} minRows={0} TdComponent={ DashmoreTdComponent} defaultSortMethod={(a, b, desc) => ReactTableDefaults.defaultSortMethod(a.raw, b.raw, desc)}> </ReactTable>;
-
static
format_data_frame
(data_frame)[source]¶ This function prepares the raw data frame for transformation by formatting dates in the index and removing any remaining NaN/NaT values. It also names the column as metrics so that it can be treated like a dimension level.
Parameters: - data_frame – The result set data frame
- dimensions –
Returns:
-
static
map_hyperlink_templates
(df, dimensions)[source]¶ Creates a mapping for each dimension to it’s hyperlink template if it is possible to create the hyperlink template for it.
The hyperlink template is a URL-like string containing curley braces enclosing dimension keys: {dimension}. While rendering this widget, the dimension key placeholders need to be replaced with the dimension values for that row.
Parameters: - df – The result data set that is being transformed. The data frame SHOULD be pivoted/transposed if that step is required, before calling this function, in order to prevent the template from being included for the dimension if one of the required dimensions is pivoted.
- dimensions – The list of dimensions included in the query that created the result data set df.
Returns: A dict with the dimension key as the key and the hyperlink template as the value. Templates will only be included if it will be possible to fill in the required parameters.
-
transform
(data_frame, slicer, dimensions, references)[source]¶ Transforms a data frame into a format for ReactTable. This is an object containing attributes columns and data which align with the props in ReactTable with the same name.
Parameters: - data_frame – The result set data frame
- slicer – The slicer that generated the data query
- dimensions – A list of dimensions that were selected in the data query
- references – A list of references that were selected in the data query
Returns: An dict containing attributes columns and data which align with the props in ReactTable with the same names.
-
static
transform_data
(data_frame, field_map, dimension_hyperlink_templates, is_transposed)[source]¶ Builds a list of dicts containing the data for ReactTable. This aligns with the accessors set by #transform_dimension_column_headers and #transform_metric_column_headers
Parameters: - data_frame – The result set data frame
- field_map – A mapping to all the fields in the slicer used for this query.
- dimension_hyperlink_templates –
- is_transposed –
-
static
transform_data_column_headers
(data_frame, field_map)[source]¶ Convert the metrics into ReactTable column header definitions. This includes any pivoted dimensions, which will result in multiple rows of headers.
Returns: Parameters: - data_frame – The result set data frame
- field_map – A map to find metrics/operations based on their keys found in the data frame.
Returns: A list of column header definitions with the following structure.
columns = [{ Header: 'Column A', columns: [{ Header: 'SubColumn A.0', accessor: 'a.0', }, { Header: 'SubColumn A.1', accessor: 'a.1', }] }, { Header: 'Column B', columns: [ ... ] }]
-
static
transform_index_column_headers
(data_frame, field_map)[source]¶ Convert the un-pivoted dimensions into ReactTable column header definitions.
Parameters: - data_frame – The result set data frame
- field_map –
Returns: A list of column header definitions with the following structure.
columns = [{ Header: 'Column A', accessor: 'a', }, { Header: 'Column B', accessor: 'b', }]
-
static
-
class
fireant.widgets.reacttable.
TotalsItem
[source]¶ Bases:
object
-
alias
= '$totals'¶
-
label
= 'Totals'¶
-
precision
= None¶
-
prefix
= None¶
-
suffix
= None¶
-
-
fireant.widgets.reacttable.
return_none
(*args, **kwargs)¶