Folium-Visualizable Data Item¶
visualizable_data_item
¶
VisualizableDataItem
¶
Bases: ABC
Abstract interface for data items that can be visualized on maps.
Defines the contract for all data items that can be processed by the folium visualization system. Provides attribute access, tooltip data generation, and text representation for map elements.
This abstraction enables polymorphic handling of different data sources (model DataFrames, KPI objects, custom data) within the visualization pipeline while maintaining consistent interface expectations.
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
get_name
abstractmethod
¶
get_name() -> str
Get a representative name for the object.
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
34 35 36 37 | |
get_text_representation
abstractmethod
¶
get_text_representation() -> str
Get a representative text for the object.
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
39 40 41 42 | |
get_tooltip_data
abstractmethod
¶
get_tooltip_data(**kwargs) -> dict
Get data for tooltip display.
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
44 45 46 47 | |
get_object_attribute
abstractmethod
¶
get_object_attribute(attribute: str) -> Any
Get value for styling from specified column.
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
49 50 51 52 | |
ModelDataItem
¶
Bases: VisualizableDataItem
Visualizable data item for model DataFrame rows.
Wraps pandas Series objects (DataFrame rows) to provide the VisualizableDataItem interface. Commonly used for visualizing static model data like network topology, geographic boundaries, or reference datasets.
The attributes are the values of the row. The name is the row index.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
object_data
|
Series
|
Pandas Series representing a DataFrame row |
required |
object_type
|
str | Any
|
Optional type identifier for the object |
None
|
**kwargs
|
Any
|
Additional attributes to set on the data item |
{}
|
Examples:
>>> item = ModelDataItem(dataset.fetch('Country.Model').loc['C1'], object_type='Country')
>>> item.get_name()
'C1'
>>> item.get_tooltip_data()
{'ID': 'C1', 'name': 'Country 1'}
>>> item.get_object_attribute('geometry')
<POLYGON ((9 46, 9 50, 5 50, 5 46, 9 46))>
The generators wrap each row of a model DataFrame in a ModelDataItem.
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
get_tooltip_data
¶
get_tooltip_data(**kwargs) -> dict
Return the ID and the column values of the row, as text.
Leaves out missing values and geometries. Cuts a value longer than 50
characters to 47 characters and ....
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | |
KPIDataItem
¶
Bases: VisualizableDataItem
Visualizable data item for KPI objects.
Wraps a KPI for the map. get_object_attribute reads the attributes of the
model object of the KPI; kpi_value, value and kpi give the KPI value
when the model object has no attribute of that name. The text is the KPI
value in its pretty unit.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
kpi
|
KPI
|
KPI with its value and attributes |
required |
kpi_collection
|
KPICollection
|
Optional KPI collection for context |
None
|
**kwargs
|
Any
|
Additional attributes to set on the data item |
{}
|
Examples:
>>> from mesqual.kpis import Aggregations, FlagAggKPIBuilder
>>> dataset.add_kpis_from_definitions(
... FlagAggKPIBuilder().for_flag('Country.Results.price').with_aggregation(Aggregations.Mean).build()
... )
>>> item = KPIDataItem(dataset.kpi_collection.filter(object_name='C1')[0], dataset.kpi_collection)
>>> print(round(item.get_object_attribute('kpi_value'), 2))
42.1
>>> item.get_object_attribute('name')
'Country 1'
>>> item.get_text_representation()
'42.1 €/MWh'
The generators wrap each KPI of a collection in a KPIDataItem.
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 | |
get_text_representation
¶
get_text_representation(converter: QuantityToTextConverter = None) -> str
Get formatted text representation of the KPI value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
converter
|
QuantityToTextConverter
|
Optional QuantityToTextConverter for custom formatting |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Formatted string representation of the KPI value |
Source code in src/mesqual/visualizations/folium_viz_system/visualizable_data_item.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 | |