mirror of
https://github.com/ankitects/anki.git
synced 2025-09-18 14:02:21 -04:00
don't fill in blanks outside of year range
This commit is contained in:
parent
d24f34c238
commit
2b1bcda937
2 changed files with 11 additions and 3 deletions
|
@ -47,7 +47,8 @@
|
|||
graphData,
|
||||
targetYear,
|
||||
i18n,
|
||||
nightMode
|
||||
nightMode,
|
||||
revlogRange,
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@ import "d3-transition";
|
|||
import { select, mouse } from "d3-selection";
|
||||
import { scaleLinear, scaleSequential } from "d3-scale";
|
||||
import { showTooltip, hideTooltip } from "./tooltip";
|
||||
import { GraphBounds, setDataAvailable } from "./graphs";
|
||||
import { GraphBounds, setDataAvailable, RevlogRange } from "./graphs";
|
||||
import { timeDay, timeYear, timeWeek } from "d3-time";
|
||||
import { I18n } from "../i18n";
|
||||
|
||||
|
@ -54,7 +54,8 @@ export function renderCalendar(
|
|||
sourceData: GraphData,
|
||||
targetYear: number,
|
||||
i18n: I18n,
|
||||
nightMode: boolean
|
||||
nightMode: boolean,
|
||||
revlogRange: RevlogRange
|
||||
): void {
|
||||
const svg = select(svgElem);
|
||||
const now = new Date();
|
||||
|
@ -90,12 +91,18 @@ export function renderCalendar(
|
|||
|
||||
// fill in any blanks
|
||||
const startDate = timeYear(nowForYear);
|
||||
const oneYearAgoFromNow = new Date(now);
|
||||
oneYearAgoFromNow.setFullYear(now.getFullYear() - 1);
|
||||
for (let i = 0; i < 365; i++) {
|
||||
const date = new Date(startDate.getTime() + i * 86400 * 1000);
|
||||
if (date > now) {
|
||||
// don't fill out future dates
|
||||
continue;
|
||||
}
|
||||
if (revlogRange == RevlogRange.Year && date < oneYearAgoFromNow) {
|
||||
// don't fill out dates older than a year
|
||||
continue;
|
||||
}
|
||||
const yearDay = timeDay.count(timeYear(date), date);
|
||||
if (!dayMap.has(yearDay)) {
|
||||
const weekNumber = timeWeek.count(timeYear(date), date);
|
||||
|
|
Loading…
Reference in a new issue