[TASK] bugfix chart if array length less than 2

This commit is contained in:
Marie Birner 2023-10-01 18:53:52 +02:00 committed by philipp
parent 705eebb0ec
commit 5315fe8dfc

View File

@ -8,6 +8,7 @@ export interface Data {
if(sessionStorage.getItem('userStats')) { if(sessionStorage.getItem('userStats')) {
const data = JSON.parse(sessionStorage.getItem('userStats') || '{}') as Data[]; const data = JSON.parse(sessionStorage.getItem('userStats') || '{}') as Data[];
if(data.length >= 2) {
const margin = { top: 20, right: 20, bottom: 50, left: 50 }; const margin = { top: 20, right: 20, bottom: 50, left: 50 };
const width: number = 960 - margin.left - margin.right; const width: number = 960 - margin.left - margin.right;
const height: number = 500 - margin.top - margin.bottom; const height: number = 500 - margin.top - margin.bottom;
@ -48,6 +49,7 @@ if(sessionStorage.getItem('userStats')) {
svg.append('g') svg.append('g')
.call(d3.axisLeft(y)); .call(d3.axisLeft(y));
}
} }