Repository navigation
Conversation
On an asset with charge points, the Default chart and the Charge Points chart shared one chart data request, which loaded every sensor in sensors_to_show. The Default chart skips the "Charge Point sessions" graph, so its session sensors were loaded and thrown away, and the Charge Points chart likewise loaded everything to draw a few graphs. GET /assets/<id>/chart_data now accepts chart-type and returns only the data of the sensors that chart type draws (GenericAsset.chart_sensors). Without it, it returns every sensor's data, as before. The asset page sends the selected chart type, and loads that chart's data when the user switches charts; the chart data cache no longer reuses records loaded for another chart type. Closes #2789. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
… graph titles Switching between the asset charts reloaded the data without stopping a replay, which would keep drawing the previous chart type's data; and stopping a replay redraws the Vega-Lite chart, so the reload now waits for it. The "Prices" and "Power flow by type" titles were spelled out again in GenericAsset.chart_sensors; both now come from belief_charts.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Ahmad-Wahid <ahmedwahid16101@gmail.com>
Co-authored-by: Ahmad-Wahid <59763365+Ahmad-Wahid@users.noreply.github.com>
… case of their titles The Vega-Lite Charge Points chart capitalizes graph titles before matching them, but chart_sensors compared the raw titles, so a graph titled "prices" or "power flow by type" was drawn without its data. One helper in belief_charts.py now decides which sensors of a graph the chart draws, used by both chart_for_chargepoint_sessions and chart_sensors. The power-flow filter now also matches the capitalized title, and no longer mutates the caller's sensors_to_show. The fast chart matches companion titles the same way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Per testing.instructions.md, modules using fresh_db end in _fresh_db.py. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
The field is new, so no older client sends chart_type, and legacy aliases are for renamed fields. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Also say that the Charge Points chart lists its session sensors first. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…nstants fast-chart.js and graphs.html kept their own copies of the graph titles and the power sensor name. They now get them from CHARGE_POINT_CHART_NAMES in belief_charts.py, through a Jinja global, so renaming one no longer needs edits in three places. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Brings in the registry of asset chart types (issue #2795), on which chart_data's chart-type is to build. Conflicts resolved as follows: chart_sensors keeps its rules, but takes the public chart type names, which the asset page now sends (legacy names are mapped); belief_charts.py keeps the registry's helpers next to CHARGE_POINT_CHART_NAMES and charge_point_chart_sensors; and the registry's fast chart test hands the fast chart the Charge Points chart's names, which it needs since #2790. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…, and refuse unknown chart types GenericAsset.chart_sensors now takes the sensors from the chart type's layout in the registry of asset chart types, instead of matching graph titles itself, so what chart_data loads and what the chart endpoint draws come from one place. chart_data checks its chart-type against the registry, and takes the same values as the chart endpoint: "default" and "charge-point-sessions", and the deprecated legacy names, under chart-type or its snake_case alias. Anything else gets a 422. Without chart-type, or with an empty one (which main ignored), chart_data still returns every sensor in sensors_to_show. The tests use the charge_hub_fresh_db fixture from flexmeasures/conftest.py, which this module's own fixture had become a copy of. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
… of asset chart types CHARGE_POINT_CHART_NAMES moves from belief_charts.py to chart_types.py, next to the layout of the Charge Points chart that it describes. The fast chart still lays out the graphs itself by these names, as before; taking the layout from the server is left for later (issue #2795). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ic names Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…'s names Without them, it drew an untitled sessions chart, or a default chart showing the session timestamps. includes/graphs.html always passes them, so a missing set is a mistake in the caller; throwing makes it show in the console and in tests, instead of in a subtly wrong chart. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…hart with its data GenericAsset.chart(include_data=True), which the CLI uses to save a chart, now takes the sensors from the chart type's layout, as chart_data does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…d the fast chart's lowercase titles fix Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…nly what it draws Also, flexmeasures show chart writes an image, so it holds no data to narrow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…e only Its values are the names of the chart functions, which public chart type names replace in v1.2.0 (#2795), so the official API makes no promise about it yet: the OpenAPI specs leave it out, as they do beliefs-after, and the API changelog no longer announces it. The endpoint still accepts it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
66efc23 The tree is unchanged: main's squash commit holds the same changes. This gives the merge of the local branch built on #2790 a merge base that already has #2790's commits. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
… registry of chart types Brings in the local branch built on #2790 and an earlier state of the registry (issue #2802): chart_data's chart-type takes the registry's public chart type names (and plugin ones), validated as on the chart endpoint, still accepts the legacy names, and reads an empty value as absent; GenericAsset.chart_sensors takes its sensors from the chart type's layout, so charge_point_chart_sensors and its own rules are dropped; an asset chart with its data inlines only the data of the chart type's sensors; and the fast chart takes the Charge Points chart's names from the page (now kept in chart_types.py), and fails loudly without them. Conflicts resolved as follows: the branch's side for the models, chart_data's field and its tests, which all build on the registry now; the sensor page's belief tooltip keeps the public 'bar-chart' name, which the registry introduced since; test_fast_chart.py keeps the registry's sensor chart type tests next to the branch's new ones; and the changelog entries move to the v1.2.0 and v3.0-41 sections, leaving #2790's own v1.1.0 entry as it was merged. chart-type on chart_data is now documented: AssetChartDataOpenAPISchema no longer excludes it, and its test checks it is in the published specs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
…ection renumbered to v3.0-35 Conflict resolved in documentation/api/change_log.rst: the base's entry on asset chart types loses its sentence on the 422 for an unknown chart-type (v3.0-34 already ships that), and this PR's two entries follow it. The section heading arrives as v3.0-35 from the base, so this branch carries no v3.0-41 any more. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf Signed-off-by: F.N. Claessen <claessen@seita.nl>
|
Merged the updated base (#2803) into this branch in d270088, which brings in main as well as the API section renumbered to v3.0-35 (v1.1.0 shipped with v3.0-34, see #2818). The one conflict was in the API change log: this PR's two entries now follow the base's entry on asset chart types, under v3.0-35. Nothing on this branch refers to v3.0-41 any more. The chart type and chart data tests (Python and JS, 182) pass locally. 🤖 Generated with Claude Code |
Flix6x
left a comment
There was a problem hiding this comment.
Self-review of #2805 (with #2803 below it), at d270088.
What holds. chart_data now loads exactly what each chart type draws: for default, charge-point-sessions and both legacy names, the sensors in the data are the sensors the Vega-Lite chart filters on, and chart?include-data=true inlines the same set. An unknown chart-type gets a 422 naming the registered types (before, it silently returned every sensor), an empty one counts as none, and a plugin's chart type loads its own layout. The new tests fail on #2803 alone (10 of them) and pass here; flexmeasures/api/v3_0, flexmeasures/ui and the chart type tests all pass.
Before merging
- Read the Docs fails on this PR and on #2803:
documentation/changelog.rstholds the v1.1.0 section twice (since #2803's merge of main, 03becfe), so the labelsv1.1.0-add-report-warningandv1.1.0-roles-warningare defined twice. - #2803 conflicts with main (both changelogs,
customisation.rst,generic_assets.py,time_series.py,fast-chart.js), and this PR addstest_fast_chart.pyto that. The API changelog entries sit inv3.0-35 | XX, 2026, while main's open section is v3.0-38 (and the PR description says v3.0-41).
We'll take care of both: merge main into #2803 (keeping the v1.1.0 section once and moving the API changelog entries to v3.0-38), then #2803 into this PR, and correct the version in the description.
For plugin authors. A chart type's layout decides what chart_data loads, and its builder what the Vega-Lite chart draws, and nothing ties the two: a plugin whose layout leaves out a graph its builder draws gets that graph empty. We'll push one line to this PR, in the AssetChartType docstring and in customisation.rst: the layout must hold every sensor the builder draws. That holds until #2795's renderer-neutral layouts make it structural.
Seen on the way (not from this PR). An asset without sensors_to_show gets suggested graphs in the old top-level sensors form, which the Vega-Lite builder skips, so its chart has no graphs while chart data loads the two sensors. We'll fix that in a separate PR off main: a missing sensors_to_show draws the suggested graphs again, and an explicit empty list means no graphs.
…in main Move this PR's API changelog entries along into main's open section, v3.0-38. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
Chart data is loaded for the layout's sensors only, so a graph a plugin's builder draws outside its layout comes up empty. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
…in main's sessions tests by public name Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
The replay and one-pass tests main brought in (#2882) render asset charts without opts.chargePointChart, which an asset chart needs since this PR. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
|
Follow-ups of the review of #2805, one line per action:
|
test_each_chart_type_draws_the_graphs_and_sensors_of_its_layout already checks that the built-in chart types' layouts hold what their builders draw; a test of the docstring's words only makes rewording it harder. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
Flix6x
left a comment
There was a problem hiding this comment.
Re-checked #2805 at 09d615b and #2803 at ae63c29, after the follow-ups of the review. The merges kept both sides of every conflict, except the fast chart's session hover helper, which main had removed along with the series it served; each PR's own diff is otherwise unchanged, apart from the changelog entries (now in v1.2.0 and v3.0-38, with the v1.1.0 section once) and main's new fast chart tests, which now use the public chart type names and pass the Charge Points chart's names. The chart type, API and UI tests pass, the fast chart tests with the real ECharts too.
One more commit drops the test of the layout note's wording, since the fresh-db test already checks each built-in chart type's layout against what it draws. Once CI is green with that commit, we merge this PR into #2803, merge main into #2803 again, and merge the stack.
…in main again Keep both New features entries in the changelog: this PR's chart data entry and main's #2713 entry. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: F.N. Claessen <claessen@seita.nl>
Closes #2802.
Stacked on #2803 (the registry of asset and sensor chart types); this PR targets
chart-type-registryand will be retargeted tomainonce #2803 merges.What changes
GET /api/v3_0/assets/<id>/chart_datatakes the registry's public chart type names aschart-type(default,charge-point-sessions, and any a plugin registers), validated as onGET /api/v3_0/assets/<id>/chart: an unknown name gets a422. The names the asset page sent in v1.1.0 (chart_for_multiple_sensors,chart_for_chargepoint_sessions) are still accepted, and an empty value counts as no chart type. The parameter is now documented in the OpenAPI specs.GenericAsset.chart_sensorstakes the sensors per chart type from the chart type's layout in the registry, so the separate rules (andcharge_point_chart_sensors) are gone: what chart data loads is what the chart draws, also for plugin chart types.asset.chart(include_data=True), and soGET /api/v3_0/assets/<id>/chart?include-data=trueand the chart's CSV export, inlines only the data of the chart type's own sensors, aschart_datadoes.CHARGE_POINT_CHART_NAMESinchart_types.py) from the page, and throws without them on an asset chart, rather than drawing the wrong graphs.The branch was built on #2790 before it was squash-merged; it records #2790's final head as merged (tree unchanged) and then merges the local branch, so the diff against
chart-type-registryholds only these changes.How to test
pytest flexmeasures/api/v3_0/tests/test_asset_chart_data_fresh_db.py flexmeasures/data/tests/test_chart_types.py flexmeasures/ui/tests/js/test_fast_chart.pychart-typeon thechart_datarequests).GET /api/v3_0/assets/<id>/chart_data?chart-type=charge-point-sessions&...returns the session sensors, the charge points power and the prices;chart-type=nopegets a422.🤖 Generated with Claude Code
https://claude.ai/code/session_01UBBvKZkzbfEPKctwTN8SDf