diff --git a/documentation/changelog.rst b/documentation/changelog.rst index a1a095c08..11ab4d345 100644 --- a/documentation/changelog.rst +++ b/documentation/changelog.rst @@ -18,6 +18,7 @@ New features Bugfixes ----------- * Do not fail asset page if entity addresses cannot be built [see `PR #457 `_] +* Asynchronous reloading of a chart's dataset relies on that chart already having been embedded [see `PR #472 `_] * Time scale axes in sensor data charts now match the requested date range, rather than stopping at the edge of the available data [see `PR #449 `_] * The docker-based tutorial now works with UI on all platforms (port 5000 did not expose on MacOS) [see `PR #465 `_] * Fix interpretation of scheduling results in toy tutorial [see `PR #466 `_] diff --git a/flexmeasures/ui/templates/crud/asset.html b/flexmeasures/ui/templates/crud/asset.html index a53655aea..73e008148 100644 --- a/flexmeasures/ui/templates/crud/asset.html +++ b/flexmeasures/ui/templates/crud/asset.html @@ -229,7 +229,6 @@

All sensors for {{ asset.name }}

signal = controller.signal $("#spinner").show(); - embedAndLoad(chartSpecsPath + 'event_starts_after=' + queryStartDate + '&event_ends_before=' + queryEndDate + '&', elementId, datasetName, previousResult, startDate, endDate); Promise.all([ // Fetch time series data fetch(assetPath + '/chart_data/?event_starts_after=' + queryStartDate + '&event_ends_before=' + queryEndDate, { @@ -246,8 +245,10 @@

All sensors for {{ asset.name }}

headers: {"Content-Type": "application/json"}, signal: signal, }) - .then(function(response) { return response.json(); }) + .then(function(response) { return response.json(); }), */ + + embedAndLoad(chartSpecsPath + 'event_starts_after=' + queryStartDate + '&event_ends_before=' + queryEndDate + '&', elementId, datasetName, previousResult, startDate, endDate), ]).then(function(result) { $("#spinner").hide(); vegaView.change(datasetName, vega.changeset().remove(vega.truthy).insert(result[0])).resize().run(); diff --git a/flexmeasures/ui/templates/views/sensors.html b/flexmeasures/ui/templates/views/sensors.html index 5c06332b1..29ab7817f 100644 --- a/flexmeasures/ui/templates/views/sensors.html +++ b/flexmeasures/ui/templates/views/sensors.html @@ -110,7 +110,6 @@ signal = controller.signal $("#spinner").show(); - embedAndLoad(chartSpecsPath + 'event_starts_after=' + queryStartDate + '&event_ends_before=' + queryEndDate + '&', elementId, datasetName, previousResult, startDate, endDate); Promise.all([ // Fetch time series data fetch(sensorPath + '/chart_data/?event_starts_after=' + queryStartDate + '&event_ends_before=' + queryEndDate, { @@ -124,7 +123,10 @@ method: "GET", headers: {"Content-Type": "application/json"}, }) - .then(function(response) { return response.json(); }) + .then(function(response) { return response.json(); }), + + // Embed chart + embedAndLoad(chartSpecsPath + 'event_starts_after=' + queryStartDate + '&event_ends_before=' + queryEndDate + '&', elementId, datasetName, previousResult, startDate, endDate), ]).then(function(result) { $("#spinner").hide(); vegaView.change(datasetName, vega.changeset().remove(vega.truthy).insert(result[0])).resize().run();