fix: undefined error

This commit is contained in:
apotdevin 2021-07-21 08:34:13 +02:00
parent e858cdd820
commit 6087e018ea
No known key found for this signature in database
GPG key ID: 4403F1DFBE779457
2 changed files with 6 additions and 2 deletions

View file

@ -86,7 +86,9 @@ const Chart = ({
const axisColor = themeContext.mode === 'light' ? 'black' : 'white';
const keys = Object.keys(data[0]).filter(d => d !== 'date');
const keys = Object.keys(data[0] || {}).filter(d => d !== 'date');
if (!keys.length) return null;
let tooltipTimeout: number;

View file

@ -57,7 +57,9 @@ const Chart = ({
const themeContext = useContext(ThemeContext);
const axisColor = themeContext.mode === 'light' ? 'black' : 'white';
const keys = Object.keys(data[0]).filter(d => d !== 'label');
const keys = Object.keys(data[0] || {}).filter(d => d !== 'label');
if (!keys.length) return null;
const maxValue = Math.max(
...data.map(d => Math.max(...keys.map(key => Number(d[key]))))