Fix incorrect added total/average

https://forums.ankiweb.net/t/anki-2-1-56-release-candidate/26001/18
This commit is contained in:
Damien Elmes 2023-01-10 09:45:54 +10:00
parent 25def4f741
commit 5db95c97e3

View file

@ -75,14 +75,15 @@ export function buildHistogram(
.thresholds(scale.ticks(desiredBars))(data.daysAdded.entries() as any);
// empty graph?
if (!sum(bins, (bin) => bin.length)) {
const accessor = getNumericMapBinValue as any;
if (!sum(bins, accessor)) {
return [null, []];
}
const adjustedRange = scaleLinear().range([0.7, 0.3]);
const colourScale = scaleSequential((n) => interpolateBlues(adjustedRange(n)!)).domain([xMax!, xMin!]);
const totalInPeriod = sum(bins, (bin) => bin.length);
const totalInPeriod = sum(bins, accessor);
const periodDays = Math.abs(xMin!);
const cardsPerDay = Math.round(totalInPeriod / periodDays);
const tableData = [
@ -102,7 +103,7 @@ export function buildHistogram(
_percent: number,
): string {
const day = dayLabel(bin.x0!, bin.x1!);
const cards = tr.statisticsCards({ cards: getNumericMapBinValue(bin as any) });
const cards = tr.statisticsCards({ cards: accessor(bin) });
const total = tr.statisticsRunningTotal();
const totalCards = tr.statisticsCards({ cards: cumulative });
return `${day}:<br>${cards}<br>${total}: ${totalCards}`;