Skip to content

Commit

Permalink
fixed bug in touch label
Browse files Browse the repository at this point in the history
  • Loading branch information
bananahampster committed Apr 6, 2024
1 parent a165860 commit f766094
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/flagPace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,23 +325,22 @@ export default class FlagPaceChart {
.append('title')
.text(i => S[i]);

const touches: number[] = [];
for (const team in this.flagProgression) {
for (const flag of this.flagProgression[team]) {
touches.push(flag.length);
}
}
serie.append('g')
.attr('class', 'touch-labels')
.selectAll('text')
.data(function(d) { return d[1].filter(i => T[i] === 5); })
.join('text')
.attr('x', i => xScale(X[i]))
.attr('y', i => yScale(Y[i]))
.attr('dy', '-0.66em')
.text((_,i) => touches[i])
.append('title')
.text((i, index) => `${S[i]} (${touches[index]} touches)`);
const that = this;
serie.each(function (_, teamIndex) {
const touches = that.flagProgression![teamIndex].map(flag => flag.length);

d3.select<d3.BaseType, [string, number[]]>(this).append('g')
.attr('class', 'touch-labels')
.selectAll('text')
.data(function(d) { return d[1].filter(i => T[i] === 5); })
.join('text')
.attr('x', i => xScale(X[i]))
.attr('y', i => yScale(Y[i]))
.attr('dy', '-0.66em')
.text((_,i) => touches[i])
.append('title')
.text((i, index) => `${S[i]} (${touches[index]} touches)`);
});
}

return document.body.children[0].outerHTML;
Expand Down

0 comments on commit f766094

Please sign in to comment.