mirror of
https://github.com/ankitects/anki.git
synced 2026-01-10 20:44:28 -05:00
added comments to review.ts
This commit is contained in:
parent
bc6bd05fee
commit
722c5a58a5
1 changed files with 3 additions and 0 deletions
|
|
@ -113,12 +113,15 @@ export function renderReviews(
|
||||||
|
|
||||||
// Create initial scale to determine tick spacing
|
// Create initial scale to determine tick spacing
|
||||||
let x = scaleLinear().domain([xMin!, xMax]);
|
let x = scaleLinear().domain([xMin!, xMax]);
|
||||||
|
// Generate thresholds: these define where bins are split (e.g., [-5, -10, -15, ...])
|
||||||
|
// D3's bin() will create bins between consecutive thresholds: [threshold[i], threshold[i+1])
|
||||||
let thresholds = x.ticks(desiredBars);
|
let thresholds = x.ticks(desiredBars);
|
||||||
// Adjust xMin to align with tick spacing so the oldest bin has the same width as others
|
// Adjust xMin to align with tick spacing so the oldest bin has the same width as others
|
||||||
if (thresholds.length >= 2) {
|
if (thresholds.length >= 2) {
|
||||||
const spacing = thresholds[1] - thresholds[0];
|
const spacing = thresholds[1] - thresholds[0];
|
||||||
const partial = thresholds[0] - xMin!;
|
const partial = thresholds[0] - xMin!;
|
||||||
if (spacing > 0 && partial > 0 && partial < spacing) {
|
if (spacing > 0 && partial > 0 && partial < spacing) {
|
||||||
|
// Extend xMin backward to align with tick spacing, but cap at originalXMin for fixed ranges
|
||||||
xMin = Math.max(thresholds[0] - spacing, shouldCapRange ? originalXMin! : -Infinity);
|
xMin = Math.max(thresholds[0] - spacing, shouldCapRange ? originalXMin! : -Infinity);
|
||||||
x = scaleLinear().domain([xMin, xMax]);
|
x = scaleLinear().domain([xMin, xMax]);
|
||||||
thresholds = x.ticks(desiredBars);
|
thresholds = x.ticks(desiredBars);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue