mirror of
https://github.com/ankitects/anki.git
synced 2025-09-25 01:06:35 -04:00
Add: X tick format
This commit is contained in:
parent
cd2354142a
commit
47a6a8da96
1 changed files with 14 additions and 2 deletions
|
@ -74,6 +74,13 @@ export function renderWorkloadChart(
|
||||||
: n.toString();
|
: n.toString();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatter = new Intl.NumberFormat(undefined, {
|
||||||
|
style: "percent",
|
||||||
|
minimumFractionDigits: 0,
|
||||||
|
maximumFractionDigits: 0,
|
||||||
|
});
|
||||||
|
const xTickFormat = (n: number) => formatter.format(n / 100);
|
||||||
|
|
||||||
const formatY: (value: number) => string = ({
|
const formatY: (value: number) => string = ({
|
||||||
[SimulateWorkloadSubgraph.ratio]: (value: number) =>
|
[SimulateWorkloadSubgraph.ratio]: (value: number) =>
|
||||||
tr.deckConfigFsrsSimulatorRatioTooltip({ time: timeSpan(value) }),
|
tr.deckConfigFsrsSimulatorRatioTooltip({ time: timeSpan(value) }),
|
||||||
|
@ -85,7 +92,7 @@ export function renderWorkloadChart(
|
||||||
})[subgraph];
|
})[subgraph];
|
||||||
|
|
||||||
function formatX(dr: number) {
|
function formatX(dr: number) {
|
||||||
return `Desired Retention: ${dr}%<br>`;
|
return `Desired Retention: ${dr}%<br>`; // <---- Ooops
|
||||||
}
|
}
|
||||||
|
|
||||||
return _renderSimulationChart(
|
return _renderSimulationChart(
|
||||||
|
@ -94,6 +101,7 @@ export function renderWorkloadChart(
|
||||||
subgraph_data,
|
subgraph_data,
|
||||||
x,
|
x,
|
||||||
yTickFormat,
|
yTickFormat,
|
||||||
|
xTickFormat,
|
||||||
formatY,
|
formatY,
|
||||||
formatX,
|
formatX,
|
||||||
(_e: MouseEvent, _d: number) => undefined,
|
(_e: MouseEvent, _d: number) => undefined,
|
||||||
|
@ -170,6 +178,7 @@ export function renderSimulationChart(
|
||||||
subgraph_data,
|
subgraph_data,
|
||||||
x,
|
x,
|
||||||
yTickFormat,
|
yTickFormat,
|
||||||
|
(a) => a.toString(),
|
||||||
formatY,
|
formatY,
|
||||||
formatX,
|
formatX,
|
||||||
legendMouseMove,
|
legendMouseMove,
|
||||||
|
@ -182,6 +191,7 @@ function _renderSimulationChart<T extends { x: any; y: any; label: number }>(
|
||||||
subgraph_data: T[],
|
subgraph_data: T[],
|
||||||
x: any,
|
x: any,
|
||||||
yTickFormat: (n: number) => string,
|
yTickFormat: (n: number) => string,
|
||||||
|
xTickFormat: (n: number) => string,
|
||||||
formatY: (n: T["y"]) => string,
|
formatY: (n: T["y"]) => string,
|
||||||
formatX: (n: T["x"]) => string,
|
formatX: (n: T["x"]) => string,
|
||||||
legendMouseMove: (e: MouseEvent, d: number) => void,
|
legendMouseMove: (e: MouseEvent, d: number) => void,
|
||||||
|
@ -198,7 +208,9 @@ function _renderSimulationChart<T extends { x: any; y: any; label: number }>(
|
||||||
const trans = svg.transition().duration(600) as any;
|
const trans = svg.transition().duration(600) as any;
|
||||||
|
|
||||||
svg.select<SVGGElement>(".x-ticks")
|
svg.select<SVGGElement>(".x-ticks")
|
||||||
.call((selection) => selection.transition(trans).call(axisBottom(x).ticks(7).tickSizeOuter(0)))
|
.call((selection) =>
|
||||||
|
selection.transition(trans).call(axisBottom(x).ticks(7).tickSizeOuter(0).tickFormat(xTickFormat as any))
|
||||||
|
)
|
||||||
.attr("direction", "ltr");
|
.attr("direction", "ltr");
|
||||||
// y scale
|
// y scale
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue