Skip to content
This repository was archived by the owner on Feb 4, 2025. It is now read-only.

Commit b4c6065

Browse files
authored
Merge pull request #547 from redpwn/fix/graph-x
fix(graph): limit graph label count for long ctfs
2 parents 1dd16ff + 395208c commit b4c6065

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

client/src/components/graph.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,13 @@ const pointsToPolyline = ({ id, name, currentScore, points, maxX, minX, maxY, wi
3838

3939
const getXLabels = ({ minX, maxX, width }) => {
4040
const labels = []
41+
const step = Math.ceil((maxX - minX) / width * 200 / day) * day
4142
let labelStart = new Date(minX).setHours(0, 0, 0, 0)
42-
if (labelStart % day !== 0) {
43-
labelStart += day
43+
if (labelStart % step !== 0) {
44+
labelStart += step
4445
}
4546

46-
for (let label = labelStart; label <= maxX; label += day) {
47+
for (let label = labelStart; label <= maxX; label += step) {
4748
labels.push({
4849
label: new Date(label).toLocaleDateString(),
4950
x: timeToX({ minX, maxX, time: label, width })

0 commit comments

Comments
 (0)