How to use the calendar-graph.SVGGraph function in calendar-graph

To help you get started, we’ve selected a few calendar-graph examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github t9tio / tomato-pie / src / util / generateCalender.js View on Github external
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);

calendar-graph

Calendar graph like github using jsx support SVG, Canvas and SSR

MIT
Latest version published 3 years ago

Package Health Score

45 / 100
Full package analysis

Popular calendar-graph functions