Skip to content

Commit 3025ca3

Browse files
committed
fixed bug with graph displaying different values
1 parent 07f8901 commit 3025ca3

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/App.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,14 +127,14 @@
127127
let cacheEntry = $timeSliceCache.get(sensor + level + region);
128128
if (!cacheEntry) {
129129
callAPI(sEntry.id, sEntry.signal, level, '20100101-20500101', region).then(d => {
130-
// regionData.set(d.epidata);
131-
// timeSliceCache.update(m => m.set(sensor + level + region, d.epidata));
130+
// creating deepcopy to avoid tampering with the data stored in cache
131+
const epi_data = JSON.parse(JSON.stringify(d.epidata));
132+
timeSliceCache.update(m => m.set(sensor + level + region, epi_data));
132133
if (!checkIfCurrentRegionHasDataOnCurrentDate(d.epidata)) {
133134
currentRegion.set('');
134135
currentRegionName.set('');
135136
} else {
136137
regionData.set(d.epidata);
137-
timeSliceCache.update(m => m.set(sensor + level + region, d.epidata));
138138
}
139139
});
140140
} else {

src/Graph.svelte

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122
if (chartMax > 100 && $sensorMap.get(sensor).format === 'percent') {
123123
chartMax = 100;
124124
}
125-
126125
// scale x and y axes
127126
var x = d3
128127
.scaleTime()

0 commit comments

Comments
 (0)