From dbb895c32cf01a538e715c63a55e21a8f6ca0344 Mon Sep 17 00:00:00 2001 From: Emily Doherty Date: Sat, 26 Nov 2022 02:10:34 -0800 Subject: [PATCH] Initial implementation of efficient chart updater --- src/index.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/index.js b/src/index.js index f5e635d..94eff04 100644 --- a/src/index.js +++ b/src/index.js @@ -80,11 +80,22 @@ function updateRegionalToken(region, data) { current_price_hash[region] = data['price_data'][region]; if (region === current_region_selection) { formatToken(); + add_data_to_chart(region, data); } } } +function add_data_to_chart(region, data) { + if (token_chart) { + const datum = {'time': data['current_time'], 'value': data['price_data'][region]} + token_chart.data.datasets.forEach((dataset) => { + dataset.data.push(datum); + }) + token_chart.update(); + } +} + export function updateRegionPreference(newRegion) { if (newRegion !== current_region_selection) { token_chart.destroy();