mstrio > modeling > metric > metric_format¶
- class mstrio.modeling.metric.metric_format.FormatProperty(type, value)¶
Bases:
Dictable
Object that specifies a single format type and it’s value
- Parameters:
type (FormatType) –
value (str | Color) –
- type¶
specify what format type is to be set
- Type:
- value¶
specify what value to set the specified format type to
- Type:
string
- FormatType Values:
- Number Category - integer between 0 and 9, default is 9:
0 - Fixed 1 - Currency 2 - Date 3 - Time 4 - Percent 5 - Fraction 6 - Scientific 7 - Custom 8 - Special 9 - General
Number Decimal Places - integer between 0 and 30, default is 0 Number Thousand Separator - boolean (true or false), default is true Number Currency Symbol - string of 1-4 characters, default is $ Number Currency Position - integer between 0 and 3, default is 0:
0 - at the beginning, for example $10 1 - at the end, for example 10$ 2 - at the beginning with extra space, for example $ 10 3 - at the end with extra space, for example 10 $
- Number Format - string of maximum of 255 characters, default value is
General, example value: ###0.00;[RED]-###0.00
- Number Negative Numbers - integer between 1 and 5, default is 3:
1 - normal negative format, for example -10 2 - red color represents negative, -10 would be 10 in red color 3 - parentheses represent negative, -10 would be (10) 4 - both red color and parentheses represent negative, -10 would be
in red color
- 5 - minus sign and red color represent negative, -10 would be -10
in red color
- Alignment Horizontal - integer between 1 and 5, default value is 1:
1 - General 2 - Left 3 - Center 4 - Right 5 - Fill
- Alignment Vertical - integer between 1 and 3, default value is 1:
1 - Top 2 - Center 3 - Bottom
Alignment Text Wrap - boolean (true or false), default is false Alignment Text Direction - allowed values are -90, 0 and 90 Padding Left - double between 0.0 and 100.0, default value is 1.0 Padding Right - double between 0.0 and 100.0, default value is 1.0 Padding Top - double between 0.0 and 100.0, default value is 1.0 Padding Bottom - double between 0.0 and 100.0, default value is 1.0 Font Name - string representing font, default is Arial, if provided
font name does not exist or is not supported, default is used
Font Bold - boolean (true or false), default is false Font Italic - boolean (true or false), default is false Font Size - integer between 1 and 2147483647, recommended usable range
is between 8 and 72, other font sizes might render format unreadable
Font Strikeout - boolean (true or false), default is false Font Underline - boolean (true or false), default is false Font Color - FormatProperty.Color object representing font color in hex,
RGB and server readable formats
- Font Script - integer between 1 and 2147483647, default value is 0,
value represents corresponding font script, if the value has no corresponding script, the default will be used
- Border Top Style - integer between 0 and 6, default value is 1:
0 - empty border 1 - thin border 2 - hair border 3 - dashed border 4 - dotted border 5 - thick border 6 - double border
Border Right Style - the same rules as Top Style Border Left Style - the same rules as Top Style Border Bottom Style - the same rules as Top Style Border Top Color - FormatProperty.Color object representing border top
color in hex, RGB and server readable formats
- Border Right Color - FormatProperty.Color object representing border
right color in hex, RGB and server readable formats
- Border Left Color - FormatProperty.Color object representing border
left color in hex, RGB and server readable formats
- Border Bottom Color - FormatProperty.Color object representing border
bottom color in hex, RGB and server readable formats
- Background Fill Style - integer between 0 and 3, default value is 0:
0 - solid, only has fill color 1 - transparent 2 - gradient, has fill color and gradient color 3 - pattern, has fill color and gradient color
- Background Fill Color - FormatProperty.Color object representing
background fill color in hex, RGB and server readable formats
- Background Pattern Color - FormatProperty.Color object representing
background fill color in hex, RGB and server readable formats
Background Pattern Style - integer between 1 and 18, default value is 1 Background Gradient Color - FormatProperty.Color object representing
background gradient color in hex, RGB and server readable formats
Background Gradient Angle - allowed values are -90, 0 and 90 Gradient X Offset - allowed values are 0, 50 and 100 Gradient Y Offset - allowed values are 0, 50 and 100
- class Color(hex_value=None, red=None, green=None, blue=None, server_value=None)¶
Bases:
Dictable
- A class containing information about the color in different formats.
It is used as a value for FormatProperties that type related with colors.
- Parameters:
hex_value (str) –
red (str) –
green (str) –
blue (str) –
server_value (str) –
- hex_value¶
color expressed in hex format (e.g. ‘#ff02ef’)
- Type:
str
- server_value¶
color translated for server readable format
- Type:
str
- red¶
red component of a RGB format, expressed as decimal
- Type:
str
- green¶
green component of a RGB format, expressed as decimal
- Type:
str
- blue¶
blue component of a RGB format, expressed as decimal
- Type:
str
- classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)¶
Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of the objects that should be created.
source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
A list of objects of type T.
- Return type:
T
- classmethod from_dict(source, connection=None, to_snake_case=True, with_missing_value=False)¶
Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – A dictionary from which an object will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
An object of type T.
- Return type:
T
- to_dict(camel_case=True)¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- blue: str¶
- green: str¶
- hex_value: str¶
- red: str¶
- server_value: str¶
- enum FormatType(value)¶
Bases:
AutoName
Valid values are as follows:
- NUMBER_CATEGORY = FormatType.NUMBER_CATEGORY¶
- NUMBER_DECIMAL_PLACES = FormatType.NUMBER_DECIMAL_PLACES¶
- NUMBER_THOUSAND_SEPARATOR = FormatType.NUMBER_THOUSAND_SEPARATOR¶
- NUMBER_CURRENCY_SYMBOL = FormatType.NUMBER_CURRENCY_SYMBOL¶
- NUMBER_CURRENCY_POSITION = FormatType.NUMBER_CURRENCY_POSITION¶
- NUMBER_FORMAT = FormatType.NUMBER_FORMAT¶
- NUMBER_NEGATIVE_NUMBERS = FormatType.NUMBER_NEGATIVE_NUMBERS¶
- ALIGNMENT_HORIZONTAL = FormatType.ALIGNMENT_HORIZONTAL¶
- ALIGNMENT_VERTICAL = FormatType.ALIGNMENT_VERTICAL¶
- ALIGNMENT_TEXT_WRAP = FormatType.ALIGNMENT_TEXT_WRAP¶
- ALIGNMENT_TEXT_DIRECTION = FormatType.ALIGNMENT_TEXT_DIRECTION¶
- PADDING_LEFT = FormatType.PADDING_LEFT¶
- PADDING_RIGHT = FormatType.PADDING_RIGHT¶
- PADDING_TOP = FormatType.PADDING_TOP¶
- PADDING_BOTTOM = FormatType.PADDING_BOTTOM¶
- FONT_NAME = FormatType.FONT_NAME¶
- FONT_BOLD = FormatType.FONT_BOLD¶
- FONT_ITALIC = FormatType.FONT_ITALIC¶
- FONT_SIZE = FormatType.FONT_SIZE¶
- FONT_STRIKEOUT = FormatType.FONT_STRIKEOUT¶
- FONT_UNDERLINE = FormatType.FONT_UNDERLINE¶
- FONT_COLOR = FormatType.FONT_COLOR¶
- FONT_SCRIPT = FormatType.FONT_SCRIPT¶
- BORDER_TOP_STYLE = FormatType.BORDER_TOP_STYLE¶
- BORDER_LEFT_STYLE = FormatType.BORDER_LEFT_STYLE¶
- BORDER_BOTTOM_STYLE = FormatType.BORDER_BOTTOM_STYLE¶
- BORDER_RIGHT_STYLE = FormatType.BORDER_RIGHT_STYLE¶
- BORDER_TOP_COLOR = FormatType.BORDER_TOP_COLOR¶
- BORDER_LEFT_COLOR = FormatType.BORDER_LEFT_COLOR¶
- BORDER_BOTTOM_COLOR = FormatType.BORDER_BOTTOM_COLOR¶
- BORDER_RIGHT_COLOR = FormatType.BORDER_RIGHT_COLOR¶
- BACKGROUND_FILL_COLOR = FormatType.BACKGROUND_FILL_COLOR¶
- BACKGROUND_PATTERN_COLOR = FormatType.BACKGROUND_PATTERN_COLOR¶
- BACKGROUND_PATTERN_STYLE = FormatType.BACKGROUND_PATTERN_STYLE¶
- BACKGROUND_FILL_STYLE = FormatType.BACKGROUND_FILL_STYLE¶
- BACKGROUND_GRADIENT_COLOR = FormatType.BACKGROUND_GRADIENT_COLOR¶
- BACKGROUND_GRADIENT_ANGLE = FormatType.BACKGROUND_GRADIENT_ANGLE¶
- BACKGROUND_GRADIENT_X_OFFSET = FormatType.BACKGROUND_GRADIENT_X_OFFSET¶
- BACKGROUND_GRADIENT_Y_OFFSET = FormatType.BACKGROUND_GRADIENT_Y_OFFSET¶
- SERIES_FILL_STYLE = FormatType.SERIES_FILL_STYLE¶
- SERIES_FILL_COLOR = FormatType.SERIES_FILL_COLOR¶
- SERIES_GRADIENT_COLOR = FormatType.SERIES_GRADIENT_COLOR¶
- SERIES_GRADIENT_ANGLE = FormatType.SERIES_GRADIENT_ANGLE¶
- SERIES_GRADIENT_X_OFFSET = FormatType.SERIES_GRADIENT_X_OFFSET¶
- SERIES_GRADIENT_Y_OFFSET = FormatType.SERIES_GRADIENT_Y_OFFSET¶
- SERIES_PATTERN_STYLE = FormatType.SERIES_PATTERN_STYLE¶
- SERIES_PATTERN_COLOR = FormatType.SERIES_PATTERN_COLOR¶
- classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)¶
Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of the objects that should be created.
source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
A list of objects of type T.
- Return type:
T
- classmethod from_dict(source, connection=None, to_snake_case=True)¶
Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – A dictionary from which an object will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
An object of type T.
- Return type:
T
- to_dict(camel_case=True)¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- type: FormatType¶
- class mstrio.modeling.metric.metric_format.MetricFormat(values, header)¶
Bases:
Dictable
Object that specifies the formatting of the metric’s values and headers
- Parameters:
values (list[FormatProperty]) –
header (list[FormatProperty]) –
- values¶
list of format properties for the values of the metric
- Type:
list[FormatProperty]
- header¶
list of format properties for the header of the metric
- Type:
list[FormatProperty]
- classmethod bulk_from_dict(source_list, connection=None, to_snake_case=True, with_missing_value=False)¶
Creates multiple objects from a list of dictionaries. For each dictionary provided the keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in the object’s _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of the objects that should be created.
source_list (List[Dict[str, Any]]) – A list of dictionaries from which the objects will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
A list of objects of type T.
- Return type:
T
- classmethod from_dict(source, connection=None, to_snake_case=True, with_missing_value=False)¶
Creates an object from a dictionary. The dictionary’s keys in camel case are changed to object’s attribute names (by default in snake case) and dict values are composed to their proper data types such as Enums, list of Enums etc. as specified in _FROM_DICT_MAP.
- Parameters:
cls (T) – Class (type) of an object that should be created.
source (Dict[str, Any]) – A dictionary from which an object will be constructed.
connection (Connection, optional) – A MSTR Connection object. Defaults to None.
to_snake_case (bool, optional) – Set to True if attribute names should be converted from camel case to snake case. Defaults to True.
with_missing_value (bool) – (bool, optional): If True, class attributes possible to fetch and missing in source will be set as MissingValue objects.
- Returns:
An object of type T.
- Return type:
T
- to_dict(camel_case=True)¶
Converts an object to a dictionary excluding object’s private properties. When converting the object to a dictionary, the object’s attributes become the dictionary’s keys and are in camel case by default Attribute values stored as objects are automatically converted to non-/ primitive data structures.
- Parameters:
camel_case (bool, optional) – Set to True if attribute names should be converted from snake case to camel case. Defaults to True.
- Returns:
- A dictionary representation of object’s attributes and values.
By default, the dictionary keys are in camel case.
- Return type:
dict
- header: list[FormatProperty]¶
- values: list[FormatProperty]¶