mirror of
https://github.com/ankitects/anki.git
synced 2025-12-10 21:36:55 -05:00
Add search functional on interval graph
This commit is contained in:
parent
58950452e4
commit
1232fd7069
2 changed files with 22 additions and 2 deletions
|
|
@ -59,7 +59,7 @@
|
|||
</label>
|
||||
</div>
|
||||
|
||||
<HistogramGraph data={histogramData} {i18n} />
|
||||
<HistogramGraph data={histogramData} {i18n} on:search />
|
||||
|
||||
<TableData {i18n} {tableData} />
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -134,6 +134,26 @@ export function prepareIntervalData(
|
|||
return `${interval}<br>${total}: \u200e${percent.toFixed(1)}%`;
|
||||
}
|
||||
|
||||
function makeQuery(
|
||||
data: HistogramData,
|
||||
binIdx: number,
|
||||
): string {
|
||||
const onlyReview = "-(is:new or is:learn or is:suspended or is:buried)"
|
||||
|
||||
const bin = data.bins[binIdx];
|
||||
const start = bin.x0!;
|
||||
const end = bin.x1! - 1;
|
||||
|
||||
if (start === end) {
|
||||
return `prop:ivl=${start} ${onlyReview}`
|
||||
}
|
||||
|
||||
const fromQuery = `prop:ivl>=${start}`
|
||||
const tillQuery = `prop:ivl<=${end}`
|
||||
|
||||
return `${fromQuery} ${tillQuery} ${onlyReview}`
|
||||
}
|
||||
|
||||
const meanInterval = Math.round(mean(allIntervals) ?? 0);
|
||||
const meanIntervalString = timeSpan(i18n, meanInterval * 86400, false);
|
||||
const tableData = [
|
||||
|
|
@ -143,7 +163,7 @@ export function prepareIntervalData(
|
|||
},
|
||||
];
|
||||
return [
|
||||
{ scale, bins, total: totalInPeriod, hoverText, colourScale, showArea: true },
|
||||
{ scale, bins, total: totalInPeriod, hoverText, makeQuery, colourScale, showArea: true },
|
||||
tableData,
|
||||
];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue