Skip to content

Commit

Permalink
Remove null chart values instead of setting to 0
Browse files Browse the repository at this point in the history
  • Loading branch information
Robiquet committed Jul 14, 2023
1 parent 734aaba commit 77deca8
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions components/markets/MarketChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,20 @@ const MarketChart = ({
startDateISOString,
);

const chartData = prices?.map((price) => {
const time = new Date(price.timestamp).getTime();
const assetPrices = price.prices.reduce((obj, val, index) => {
// adjust prices over 1
return { ...obj, ["v" + index]: (val.price > 1 ? 1 : val.price) ?? 0 };
}, {});
const chartData = prices
?.filter((data) => data.prices.every((p) => p.price != null))
.map((price) => {
const time = new Date(price.timestamp).getTime();
const assetPrices = price.prices.reduce((obj, val, index) => {
// adjust prices over 1
return { ...obj, ["v" + index]: val.price > 1 ? 1 : val.price };
}, {});

return {
t: time,
...assetPrices,
};
});
return {
t: time,
...assetPrices,
};
});

const handleFilterChange = (filter: TimeFilter) => {
setChartFilter(filter);
Expand Down

0 comments on commit 77deca8

Please sign in to comment.