Skip to content

Commit

Permalink
Added catch for null results
Browse files Browse the repository at this point in the history
  • Loading branch information
christof-wittreich committed Dec 2, 2024
1 parent 1e0f210 commit 9c7bce5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion web/js/components/sidebar/charting-mode-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,16 @@ function ChartingModeOptions(props) {
function formatEgisDataForRecharts(data) {
const combinedData = {};
console.log('Actual samples:', data.samples.length);
data.samples.forEach((item) => {
data.samples.filter((item) => item.value !== '').forEach((item) => {
if (!combinedData[item.attributes.StdTime]) {
combinedData[item.attributes.StdTime] = item;
combinedData[item.attributes.StdTime].values = [];
}
combinedData[item.attributes.StdTime].values.push(parseFloat(item.value));
});
if (Object.keys(combinedData).length === 0) {
return null;
}
const rechartsData = [];
Object.values(combinedData).sort((a, b) => a.attributes.StdTime - b.attributes.StdTime).forEach((item) => {
const temperatureValues = [...item.values];
Expand Down Expand Up @@ -730,6 +733,11 @@ function ChartingModeOptions(props) {
};

const rechartsData = formatEgisDataForRecharts(dataToRender);
if (rechartsData === null) {
updateChartRequestStatus(false, 'Chart request failed.');
return;
}

if (timeSpanSelection === 'range') {
displayChart({
title: dataToRender.title,
Expand Down

0 comments on commit 9c7bce5

Please sign in to comment.