Skip to content

component

Module for analysis components.

AnalysisComponent

Bases: PyCelonisBaseModel

Class for analysis components.

id class-attribute

id: typing.Optional[str]

Id of component.

type class-attribute

type: typing.Optional[str]

Type of component (e.g. pql-table).

title class-attribute

title: typing.Optional[str]

Title of component shown in UI.

componentFilter class-attribute

componentFilter: typing.Optional[str]

Raw component filter.

get_filter

get_filter()

Returns filter of component.

Returns:

  • typing.Optional[PQLFilter]

    Component filter.

Examples:

Adding component filter to custom query and extract data:

sheet = analysis.get_content().draft.document.sheets[0]
olap_table = sheet.components.find("#{OLAP Table}", search_attribute="title")

query = PQL() + PQLColumn(name="TEST", query="<query")
query += olap_table.get_filter()

data_query, query_environment = analysis.resolve_query(query)
df = data_model.export_data_frame(data_query, query_environment)

DataComponent

Bases: ABC, AnalysisComponent

Abstract component class for components displaying data.

get_query

get_query(use_translated_names=True)

Returns full query with column and filter for component.

Parameters:

  • use_translated_names (bool) –

    If true, the translated names will be used as column names. If false, default names will be used.

Returns:

  • PQL

    A PQL query.

Examples:

Adding component query (columns + filters) to custom query and extract data:

sheet = analysis.get_content().draft.document.sheets[0]
olap_table = sheet.components.find("#{OLAP Table}", search_attribute="title")

query = PQL() + PQLColumn(name="TEST", query="<query")
query += olap_table.get_query()

data_query, query_environment = analysis.resolve_query(query)
df = data_model.export_data_frame(data_query, query_environment)

get_columns

get_columns(use_translated_names=True)

Returns all columns of component including dimensions and kpis.

Parameters:

  • use_translated_names (bool) –

    If true, the translated names will be used as column names. If false, default names will be used.

Returns:

  • typing.List[PQLColumn]

    List of PQLColumns.

Examples:

Adding component columns to custom query and extract data:

sheet = analysis.get_content().draft.document.sheets[0]
olap_table = sheet.components.find("#{OLAP Table}", search_attribute="title")

query = PQL() + PQLColumn(name="TEST", query="<query")
query += olap_table.get_columns()

data_query, query_environment = analysis.resolve_query(query)
df = data_model.export_data_frame(data_query, query_environment)

SingleKPI

Bases: DataComponent

Class for gauges, numbers, fills, etc.

TYPE class-attribute

TYPE: typing.ClassVar[str] = 'single-kpi'

formula class-attribute

formula: typing.Dict

PQLTable

Bases: DataComponent

Class for OLAP tables, column charts, line charts, etc.

TYPE class-attribute

TYPE: typing.ClassVar[str] = 'pql-table'

distinct class-attribute

distinct: typing.Optional[bool]

axis0 class-attribute

axis0: typing.List[typing.Dict]

axis1 class-attribute

axis1: typing.List[typing.Dict]

axis2 class-attribute

axis2: typing.List[typing.Dict]

get_query

get_query(use_translated_names=True)

Returns full query with all columns and filter for component.

Parameters:

  • use_translated_names (bool) –

    If true, the translated names will be used as column names. If false, default names will be used.

Returns:

  • PQL

    A PQL query.

Examples:

Adding table query to custom query and extract data:

sheet = analysis.get_content().draft.document.sheets[0]
olap_table = sheet.components.find("#{OLAP Table}", search_attribute="title")

query = PQL() + PQLColumn(name="TEST", query="<query")
query += olap_table.get_query()

data_query, query_environment = analysis.resolve_query(query)
df = data_model.export_data_frame(data_query, query_environment)

get_order_by_columns

get_order_by_columns()

Returns order by columns of component.

Returns:

PivotTable

Bases: DataComponent

Class for Pivot Tables.

TYPE class-attribute

TYPE: typing.ClassVar[str] = 'pivot'

axis0 class-attribute

axis0: typing.List[typing.Dict]

axis1 class-attribute

axis1: typing.List[typing.Dict]

axis2 class-attribute

axis2: typing.List[typing.Dict]

Boxplot

Bases: DataComponent

Class for Box Plots.

TYPE class-attribute

TYPE: typing.ClassVar[str] = 'boxplot'

dimension class-attribute

dimension: typing.Dict

distribution class-attribute

distribution: typing.Dict

WorldMap

Bases: DataComponent

Class for World Map Plots.

TYPE class-attribute

TYPE: typing.ClassVar[str] = 'world-map'

formula class-attribute

formula: typing.Dict

kpiFormula class-attribute

kpiFormula: typing.Dict

tooltipFormula class-attribute

tooltipFormula: typing.Dict

ComponentFactory

Factory class to create AnalysisComponent with given type.

get_component staticmethod

get_component(component)

Returns instance of AnalysisComponent depending on type.

Parameters:

  • component (AnalysisComponent) –

    AnalysisComponent containing properties of component.

Returns:

get_components staticmethod

get_components(components)

Returns instances of AnalysisComponent depending on type.

Parameters:

  • components (typing.List[AnalysisComponent]) –

    List of AnalysisComponent containing properties of components.

Returns: