Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (pre[pre.length - 1].date === cur.date) {
pre[pre.length - 1].tomatoes.push(cur.tomatoes[0]);
return pre;
}
return pre.concat(cur);
}, [])
.map((tomatoGroup) => {
tomatoGroup.count = tomatoGroup.tomatoes.length;
return {
date: tomatoGroup.date,
count: tomatoGroup.count,
tomatoes: tomatoGroup.tomatoes,
};
});
const calender = new SVGGraph('.calendar', groupedTomatoes, {
// startDate: new Date(new Date().getTime() - 1000 * 60 * 60 * 24 * 365),
// endDate: new Date(),
// styleOptions: {
// textColor: '#959494',
// fontSize: '12px',
// fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif',
// },
colorFun: (v) => {
if (v.count > 0 && v.count <= 4) return '#c6e48b';
if (v.count > 4 && v.count <= 8) return '#7bc96f';
if (v.count > 8 && v.count <= 12) return '#239a3b';
if (v.count > 12) return '#196127';
return '#eee';
},
onClick: (v) => {
console.log(v);