flexmeasures.data.models.charts.defaults
Functions
- flexmeasures.data.models.charts.defaults.add_annotation_layers_to_vconcat(chart_specs: dict, annotations_dataset_name: str) None
Add annotation layers to each subchart of a vertically concatenated chart.
The band, rule and marker layers are drawn behind the data layers, keeping the data (and its tooltip hit-area) fully interactive, while the annotation text layer is drawn on top.
- flexmeasures.data.models.charts.defaults.apply_chart_defaults(fn)
- flexmeasures.data.models.charts.defaults.create_annotation_layers(annotations_dataset_name: str, row_index: int, resolution_ms: int = 3600000) tuple[list[dict], list[dict]]
Create annotation layers for one subchart (row) of a vconcat chart.
All rows bind to the same named annotations dataset, but each row gets its own hover/pin params, so that hovering an annotation band darkens it only in the hovered subchart, while the other subcharts keep the light shading.
The hover/pin params capture the event_start of the hovered/clicked datum (events bubble up to the view level, so they also fire on the invisible full-height data hit-rect above). Annotation highlighting then tests whether the captured time falls within the annotation window, with a one-resolution-bin tolerance for instant (zero-duration) annotations. This way, the data tooltip keeps working inside annotation bands.
Returns two lists of layers: - background layers (drawn behind the data):
a full-height rect band for annotations with a non-zero duration
a rule for instant annotations
a triangle marker at the top of each instant-annotation rule
foreground layers (drawn on top of the data): - a text mark showing the annotation content below the subchart
(in the gap between the axis labels and the next subchart) when the annotation is hovered or pinned
- flexmeasures.data.models.charts.defaults.merge_vega_lite_specs(child: dict, parent: dict) dict
Merge nested dictionaries, with child inheriting values from parent.
Child values are updated with parent values if they exist. In case a field is a string and that field is updated with some dict, the string is moved inside the dict under a field defined in vega_lite_field_mapping. For example, ‘title’ becomes ‘text’ and ‘mark’ becomes ‘type’.