Skip to content

Commit 1c75f5e

Browse files
committed
fix movetime chart not showing for 300 move games
1 parent 2bebc50 commit 1c75f5e

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

ui/chart/src/movetime.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export default async function (el: HTMLCanvasElement, data: AnalyseData, trans:
5656
for (let i = 0; i <= firstPly; i++) {
5757
labels.push('');
5858
}
59-
let showTotal = !hunter;
59+
const showTotal = !hunter;
6060

6161
const logC = Math.pow(Math.log(3), 2);
6262

@@ -65,6 +65,7 @@ export default async function (el: HTMLCanvasElement, data: AnalyseData, trans:
6565

6666
moveCentis.forEach((centis: number, x: number) => {
6767
const node = tree[x + 1];
68+
if (!tree[x]) return;
6869
const ply = node ? node.ply : tree[x].ply + 1;
6970
const san = node ? node.san : '-';
7071
// Current behaviour: Game-ending action is assigned to the next color
@@ -97,8 +98,7 @@ export default async function (el: HTMLCanvasElement, data: AnalyseData, trans:
9798

9899
let clock = node ? node.clock : undefined;
99100
if (clock == undefined) {
100-
if (x < moveCentis.length - 1) showTotal = false;
101-
else if (data.game.status.name === 'outoftime') clock = 0;
101+
if (data.game.status.name === 'outoftime') clock = 0;
102102
else if (data.clock) {
103103
const prevClock = tree[x - 1].clock;
104104
if (prevClock) clock = prevClock + data.clock.increment - centis;
@@ -159,7 +159,6 @@ export default async function (el: HTMLCanvasElement, data: AnalyseData, trans:
159159
}))
160160
: lineBuilder(moveSeries, true);
161161
const divisionLines = division(trans, data.game.division);
162-
163162
const datasets: ChartDataset[] = [...moveSeriesSet];
164163
if (showTotal) datasets.push(...lineBuilder(totalSeries, false));
165164
datasets.push(plyLine(firstPly), ...divisionLines);

0 commit comments

Comments
 (0)