Show asset annotations in asset charts#2312
Open
Flix6x wants to merge 7 commits into
Open
Conversation
Asset (and account) annotations now appear in the asset chart as a lightly shaded time band across all subcharts. Hovering the band darkens it in the hovered subchart only, and shows a tooltip with the annotation text, type, source and time window. Alert annotations get a warning hue; instant (zero-duration) annotations render as a vertical rule with a top marker. - New GET /api/v3_0/assets/<id>/chart_annotations endpoint (mirrors the sensor endpoint, includes account annotations) - Annotation layers are injected per subchart of the vconcat chart, all bound to one shared named dataset, with per-subchart hover/select params - The hover_x_brush/hover_nearest_brush selections ignore events on annotation marks (their datums lack the binned event_start field) - graphs.html annotation fetching generalized to asset pages Signed-off-by: F.N. Claessen <felix@seita.nl> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LQFkeGxDwErydUV5ZmHmki
Signed-off-by: F.N. Claessen <felix@seita.nl> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LQFkeGxDwErydUV5ZmHmki
Documentation build overview
21 files changed ·
|
…tips Rework of the annotation interaction after review: - Annotation bands/rules/markers are now drawn behind the data layers, and no longer define their own tooltip, so the regular data tooltip keeps working everywhere, including inside annotation bands - Hover/pin params capture the time (event_start) of the hovered/clicked datum; annotations highlight when that time falls inside their window (with a one-resolution-bin tolerance for instant annotations, which also makes the 1px rule easy to hover) - On hover or click-to-pin, the annotation text is shown below the hovered subchart, in the gap between the datetime axis labels and the next subchart, without affecting the chart layout (like the sensor page's annotation text layer) - Enlarged the instant-annotation top marker (size 60 -> 200) - Add PR screenshots under .github/screenshots/pr2312 (can be dropped before merging if preferred) Signed-off-by: F.N. Claessen <felix@seita.nl> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LQFkeGxDwErydUV5ZmHmki
Image blobs bloat .git permanently; the PR's screenshots now live in the dedicated FlexMeasures/screenshots repo and the PR description links there instead. Signed-off-by: F.N. Claessen <felix@seita.nl> Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LQFkeGxDwErydUV5ZmHmki
…annotations Signed-off-by: F.N. Claessen <felix@seita.nl>
Now that the fast (canvas) charts are the default renderer (#2234), the annotation layers get an ECharts implementation mirroring the Vega-Lite one: - bands and instant rules (with a top triangle marker) are drawn behind the data in every subplot, colored by type (alert: warm hue, others: --gray); - hovering darkens the annotation and reveals its text below the hovered subplot ONLY, driven by zrender mouse events (pixel position -> subplot, time domain -> annotation), since the linked axisPointer can't tell subplots apart; instants match within one resolution bin of the subplot's finest sensor; - clicking (tapping, on touch) pins the highlight, clicking again releases; - the data tooltip keeps working inside bands (marks are silent); - a fixed text strip below each subplot keeps the layout stable on hover. The replay ruler moved into the shared markLine builder, so it coexists with instant-annotation rules on the same series. Verified with headless Chrome against a two-subplot harness: hover scoping, pinning, alert coloring, instant highlighting, tooltip-inside-band, and constant SVG/container height all as designed. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HBYFTyXL1dLcqX6M76Av6e Signed-off-by: F.N. Claessen <felix@seita.nl>
Member
Author
|
Updated now that #2234 (ECharts fast charts) landed on main:
Verified the ECharts path with headless Chrome driving |
Signed-off-by: F.N. Claessen <felix@seita.nl>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Asset annotations (and account annotations) are now shown in the asset chart. Motivation: the CommunityScheduler plugin writes "reason for interfering" alert annotations (projected breach / DSO restriction) on community assets, and those should be visible on the community asset's chart page.
Implemented for both chart renderers: the ECharts fast charts (the default since #2234 landed) and the Vega-Lite charts (the opt-out fallback). Behavior is the same in both:
var(--gray)CSS-var pattern for theme safety). The annotation text is colored accordingly.GET /api/v3_0/assets/<id>/chart_annotations, mirroring the sensor endpoint (clipping, wrapping and stacking viaprepare_annotations_for_chart), including account annotations.documentation/changelog.rstImplementation notes:
asset_<id>_annotations) feeds the annotation layers of every subchart; each subchart gets its own hover/pin params, which capture the time of the hovered/clicked datum (events bubble to the view level), and annotations highlight when that time falls in their window. This is what lets the annotation marks stay non-obtrusive below the data while still reacting to hover.fast-chart.js): bands aremarkAreas and instant rules aremarkLines on the first series of each subplot, silent and behind the data. Hover/pin is driven from zrender mouse events: the pointer's pixel position identifies the hovered subplot (the linked axisPointer can't tell subplots apart) and converting it to the time domain identifies the annotation. Clicking pins the highlight (so touch users can reach the text); clicking again releases it. A fixed text strip below each subplot keeps the layout stable on hover. The replay ruler moved into the shared markLine builder so it coexists with instant-annotation rules.Look & Feel
ECharts fast charts (default mode)
Vega-Lite charts (fallback mode)
How to test
sensors_to_showsubcharts and some data.POST /api/v3_0/assets/<id>/annotations(one with"type": "alert", one"label", and one withstart == end).pytest flexmeasures/api/v3_0/tests/test_assets_api.py -k annotationcovers the endpoint and the generated (Vega-Lite) chart specs (per-subchart layers, unique hover params).Vega-Lite path verified end-to-end with a headless browser against the toy account (two subcharts: Prices, Power flows) with an alert band, a label band and an instant annotation: hover darkening scoped to the hovered subchart, data tooltip inside bands, annotation text in the axis gap with total SVG height unchanged (667px before/during/after hover), no console errors.
ECharts path verified with headless Chrome driving
renderFastCharton a two-subplot chart with the same three annotations (16 scripted checks): resting/hover/pin opacities and per-type colors, hover darkening scoped to the hovered subplot, pin persists until released, instant-rule highlighting within one resolution bin, data tooltip inside bands, and container height constant across all states; no console errors.Appendix: earlier iteration (tooltip-based)
The first iteration showed the annotation details in a tooltip on the band itself, which swallowed the data tooltip inside bands and was dropped in review.
🤖 Generated with Claude Code
https://claude.ai/code/session_01LQFkeGxDwErydUV5ZmHmki
https://claude.ai/code/session_01HBYFTyXL1dLcqX6M76Av6e