diff --git a/index.html b/index.html index 0cf79eb..5bfd81c 100644 --- a/index.html +++ b/index.html @@ -1,172 +1,254 @@ - - - + + + +

Tennis Score Tracker

+ +
+
+ + + +
+
+ + + +
+
+ + +
+
+
+ + - + })); + + const setAnnotations = setIndicators.map(indicator => ({ + x: indicator.index + 1, + y: Math.max(...cumulativePoints), + xref: 'x', + yref: 'y', + text: `Set ${indicator.setNumber}`, + showarrow: true, + arrowhead: 4, + ax: 0, + ay: -40 + })); + + const gameShapes = gameIndicators.map(indicator => ({ + type: 'line', + x0: indicator.index + 1, + x1: indicator.index + 1, + y0: Math.min(...cumulativePoints), + y1: Math.max(...cumulativePoints), + line: { + color: 'green', // Different color for game indicators + width: 2, + dash: 'dashdot' + } + })); + + const gameAnnotations = gameIndicators.map(indicator => ({ + x: indicator.index + 1, + y: Math.max(...cumulativePoints), + xref: 'x', + yref: 'y', + text: `Game ${indicator.gameNumber}`, + showarrow: true, + arrowhead: 4, + ax: 0, + ay: -60, + font: { color: 'green' } // Font color for game annotations + })); + + const winnerShapes = winnerPoints.map(point => ({ + x: [point], + y: [cumulativePoints[point - 1]], + type: 'scatter', + mode: 'markers', + marker: { + symbol: 'circle', // Change to circle symbol for winner points + size: 15, + color: 'green' + } + })); + + const unforcedErrorShapes = unforcedErrorPoints.map(point => ({ + x: [point], + y: [cumulativePoints[point - 1]], + type: 'scatter', + mode: 'markers', + marker: { + symbol: 'circle', // Red circle symbol for unforced error points + size: 15, + color: 'red' + } + })); + + const doubleFaultShapes = doubleFaultPoints.map(point => ({ + x: [point], + y: [cumulativePoints[point - 1]], + type: 'scatter', + mode: 'markers', + marker: { + symbol: 'circle', // Black circle symbol for double fault points + size: 15, + color: 'black' + } + })); + + const layout = { + title: 'Cumulative Points', + xaxis: { title: 'Points' }, + yaxis: { title: 'Cumulative Points' }, + shapes: [...setShapes, ...gameShapes], + annotations: [...setAnnotations, ...gameAnnotations] + }; + + // Updating the winner, unforced error, and double fault points separately + Plotly.newPlot('graph', data, layout); + Plotly.addTraces('graph', [...winnerShapes, ...unforcedErrorShapes, ...doubleFaultShapes]); + } + + + +