* Prepare chart data for a specific file
(fileName)
| 124 | * Prepare chart data for a specific file |
| 125 | */ |
| 126 | function prepareChartData(fileName) { |
| 127 | const datasets = []; |
| 128 | const colors = [ |
| 129 | "#FF6384", |
| 130 | "#36A2EB", |
| 131 | "#FFCE56", |
| 132 | "#4BC0C0", |
| 133 | "#9966FF", |
| 134 | "#FF9F40", |
| 135 | "#FF6384", |
| 136 | "#C9CBCF", |
| 137 | "#4BC0C0", |
| 138 | "#FF6384", |
| 139 | ]; |
| 140 | |
| 141 | let colorIndex = 0; |
| 142 | |
| 143 | // Get all rounds across all players |
| 144 | const allRounds = new Set(); |
| 145 | Object.values(analysisData.line_counts_by_round).forEach((playerData) => { |
| 146 | Object.keys(playerData).forEach((round) => { |
| 147 | allRounds.add(parseInt(round)); |
| 148 | }); |
| 149 | }); |
| 150 | |
| 151 | const sortedRounds = Array.from(allRounds).sort((a, b) => a - b); |
| 152 | |
| 153 | // Create dataset for each player |
| 154 | Object.entries(analysisData.line_counts_by_round).forEach( |
| 155 | ([playerName, playerData]) => { |
| 156 | const data = []; |
| 157 | |
| 158 | sortedRounds.forEach((round) => { |
| 159 | const roundData = playerData[round]; |
| 160 | if (roundData && roundData[fileName] !== undefined) { |
| 161 | data.push({ |
| 162 | x: round, |
| 163 | y: roundData[fileName], |
| 164 | }); |
| 165 | } else { |
| 166 | // If file doesn't exist in this round, use 0 or previous value |
| 167 | const prevValue = data.length > 0 ? data[data.length - 1].y : 0; |
| 168 | data.push({ |
| 169 | x: round, |
| 170 | y: prevValue, |
| 171 | }); |
| 172 | } |
| 173 | }); |
| 174 | |
| 175 | datasets.push({ |
| 176 | label: playerName, |
| 177 | data: data, |
| 178 | borderColor: colors[colorIndex % colors.length], |
| 179 | backgroundColor: colors[colorIndex % colors.length] + "20", // Add transparency |
| 180 | borderWidth: 2, |
| 181 | fill: false, |
| 182 | tension: 0.1, |
| 183 | }); |
no outgoing calls
no test coverage detected