diff --git a/ts/graphs/CalendarGraph.svelte b/ts/graphs/CalendarGraph.svelte index 307bf1f5b..6b43590da 100644 --- a/ts/graphs/CalendarGraph.svelte +++ b/ts/graphs/CalendarGraph.svelte @@ -51,8 +51,9 @@ targetYear, i18n, nightMode, - revlogRange - ); + revlogRange, + calendarFirstDayOfWeek.set, + ) } const title = i18n.tr(i18n.TR.STATISTICS_CALENDAR_TITLE); diff --git a/ts/graphs/calendar.ts b/ts/graphs/calendar.ts index 7fa24bdce..62957bcad 100644 --- a/ts/graphs/calendar.ts +++ b/ts/graphs/calendar.ts @@ -85,7 +85,8 @@ export function renderCalendar( targetYear: number, i18n: I18n, nightMode: boolean, - revlogRange: RevlogRange + revlogRange: RevlogRange, + setFirstDayOfWeek: (d: number) => void, ): void { const svg = select(svgElem); const now = new Date(); @@ -181,7 +182,10 @@ export function renderCalendar( .attr("text-anchor", "end") .attr("font-size", "small") .attr("font-family", "monospace") - .style("user-select", "none"); + .style("user-select", "none") + .on("click", null) + .filter((d: number) => [Weekday.SUNDAY, Weekday.MONDAY, Weekday.FRIDAY, Weekday.SATURDAY].includes(d)) + .on("click", setFirstDayOfWeek); svg.select("g.days") .selectAll("rect") @@ -199,11 +203,5 @@ export function renderCalendar( .on("mouseout", hideTooltip) .transition() .duration(800) - .attr("fill", (d) => { - if (d.count === 0) { - return emptyColour; - } else { - return blues(d.count)!; - } - }); + .attr("fill", (d) => d.count === 0 ? emptyColour : blues(d.count)!); }