|
|
@ -80,12 +80,16 @@ function getDataFromLocalStorage (key) { |
|
|
|
return data ? JSON.parse(data) : [] |
|
|
|
return data ? JSON.parse(data) : [] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function setDataToLocalStorage (key, data) { |
|
|
|
|
|
|
|
window.localStorage.setItem(key, JSON.stringify(data)) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getPriceData (marketHistoryData) { |
|
|
|
function getPriceData (marketHistoryData) { |
|
|
|
if (marketHistoryData.length === 0) { |
|
|
|
if (marketHistoryData.length === 0) { |
|
|
|
return getDataFromLocalStorage('priceData') |
|
|
|
return getDataFromLocalStorage('priceData') |
|
|
|
} |
|
|
|
} |
|
|
|
const data = marketHistoryData.map(({ date, closingPrice }) => ({ x: date, y: closingPrice })) |
|
|
|
const data = marketHistoryData.map(({ date, closingPrice }) => ({ x: date, y: closingPrice })) |
|
|
|
window.localStorage.setItem('priceData', JSON.stringify(data)) |
|
|
|
setDataToLocalStorage('priceData', data) |
|
|
|
return data |
|
|
|
return data |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -99,7 +103,7 @@ function getMarketCapData (marketHistoryData, availableSupply) { |
|
|
|
: availableSupply |
|
|
|
: availableSupply |
|
|
|
return { x: date, y: closingPrice * supply } |
|
|
|
return { x: date, y: closingPrice * supply } |
|
|
|
}) |
|
|
|
}) |
|
|
|
window.localStorage.setItem('marketCapData', JSON.stringify(data)) |
|
|
|
setDataToLocalStorage('marketCapData', data) |
|
|
|
return data |
|
|
|
return data |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|