A component like github-contribution-calendar based on AntV/G2Plot.
npm install g2plot-calendar> G2Plot-Calendar: plugin based on G2Plot v2. Live Demo, CodeSandbox.


``bash`
$ npm i --save g2plot-calendar
- render
`ts
import { P } from '@antv/g2plot';
import * as G2PlotCalendar from 'g2plot-calendar';
let plot;
fetch('https://gw.alipayobjects.com/os/antfincdn/nvYn7dOQB9/result.json')
.then((data) => data.json())
.then((data) => {
// 第一次默认渲染
plot = new P('container', {}, G2PlotCalendar.adaptor, {
...G2PlotCalendar.defaultOptions,
width: 800,
height: 100,
data,
});
plot.render();
});
`
- update
`ts`
plot.update({
data: [],
});
- browser
`ts`
`ts
type Datum = {
date: string;
value: number | null;
};
export interface CalendarOptions {
/* 数据 /
readonly data: Datum[];
/* 颜色, 默认: ['#ebedf0', '#9be9a8', '#40c463', '#30a14e', '#216e39'] /
readonly color: string[];
}
``
MIT@visiky.