Skip to content

Commit

Permalink
feat: add last 90 days
Browse files Browse the repository at this point in the history
  • Loading branch information
alirezaJvh committed Sep 25, 2023
1 parent 2621db0 commit 0367225
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ var CalHeatMap = function () {
.offset([-5, 0])
.html(
d => `
${self.options.timeFormatter(d.t)}: <strong>${self.options.valueFormatter(
${self.options.timeFormatter(d.t)}: <strong>${d.v === null ? 0 : self.options.valueFormatter(
d.v,
)}</strong>
`,
Expand Down Expand Up @@ -742,7 +742,7 @@ var CalHeatMap = function () {
self.getSubDomain(d).map(function (d) {
return {
t: self._domainType[self.options.subDomain].extractUnit(d),
v: null,
v: 0,
};
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ enum DateType {
LastMonth = 'lastMonth',
LastYear = 'LastYear',
Last30Day = 'Last30Day',
Last90Day = 'Last90Day',
}

export function CustomFrame(props: FrameComponentProps) {
Expand Down Expand Up @@ -147,6 +148,14 @@ export function CustomFrame(props: FrameComponentProps) {
).format(MOMENT_FORMAT);
setSinceDate(moment(`${sinceDate} 00:00:00`, `YYYY/MM/DD HH:mm:ss`));
}
if (type === DateType.Last90Day) {
const sinceDate = moment().subtract(3, 'month').format(dateFormat);
sinceDatetime = moment(
`${sinceDate} 00:00:00`,
`YYYY/MM/DD HH:mm:ss`,
).format(MOMENT_FORMAT);
setSinceDate(moment(`${sinceDate} 00:00:00`, `YYYY/MM/DD HH:mm:ss`));
}
if (type === DateType.Month) {
sinceDatetime = moment().startOf('month').format(MOMENT_FORMAT);
setSinceDate(moment().startOf('month'));
Expand Down Expand Up @@ -185,7 +194,13 @@ export function CustomFrame(props: FrameComponentProps) {
onClick={() => selectDate(DateType.Last30Day)}
buttonStyle="link"
>
Last 30 Day
Last 30 Days
</Button>
<Button
onClick={() => selectDate(DateType.Last90Day)}
buttonStyle="link"
>
Last 90 Days
</Button>
<Button
onClick={() => selectDate(DateType.LastYear)}
Expand Down

0 comments on commit 0367225

Please sign in to comment.