@@ -184,34 +184,37 @@ function prepareChartData(fileName) {
184184}
185185
186186// Initialize when DOM is loaded
187- // --- Sim Wins Per Round Chart ---
188- let simWinsChart = null ;
189- let simWinsData = null ;
190187
191- function initializeSimWinsChart ( ) {
192- const simWinsDataElement = document . getElementById ( "sim-wins-data" ) ;
193- if ( ! simWinsDataElement ) return ;
188+ // --- Overview Scores Chart ---
189+ let overviewScoresChart = null ;
190+ let overviewScoresData = null ;
191+
192+ function initializeOverviewScoresChart ( ) {
193+ const overviewScoresDataElement = document . getElementById (
194+ "overview-scores-data" ,
195+ ) ;
196+ if ( ! overviewScoresDataElement ) return ;
194197 try {
195- simWinsData = JSON . parse ( simWinsDataElement . textContent ) ;
198+ overviewScoresData = JSON . parse ( overviewScoresDataElement . textContent ) ;
196199 if (
197- simWinsData &&
198- simWinsData . players &&
199- simWinsData . players . length > 0 &&
200- simWinsData . rounds &&
201- simWinsData . rounds . length > 0
200+ overviewScoresData &&
201+ overviewScoresData . players &&
202+ overviewScoresData . players . length > 0 &&
203+ overviewScoresData . rounds &&
204+ overviewScoresData . rounds . length > 0
202205 ) {
203- createSimWinsChart ( ) ;
206+ createOverviewScoresChart ( ) ;
204207 }
205208 } catch ( error ) {
206- console . error ( "Error parsing sim wins data:" , error ) ;
209+ console . error ( "Error parsing overview scores data:" , error ) ;
207210 }
208211}
209212
210- function createSimWinsChart ( ) {
211- const canvas = document . getElementById ( "sim-wins -chart" ) ;
212- if ( ! canvas || ! simWinsData ) return ;
213+ function createOverviewScoresChart ( ) {
214+ const canvas = document . getElementById ( "overview-scores -chart" ) ;
215+ if ( ! canvas || ! overviewScoresData ) return ;
213216 const ctx = canvas . getContext ( "2d" ) ;
214- if ( simWinsChart ) simWinsChart . destroy ( ) ;
217+ if ( overviewScoresChart ) overviewScoresChart . destroy ( ) ;
215218
216219 // Prepare datasets
217220 const colors = [
@@ -226,8 +229,11 @@ function createSimWinsChart() {
226229 "#FF6384" ,
227230 ] ;
228231 let colorIndex = 0 ;
229- const datasets = simWinsData . players . map ( ( player ) => {
230- const data = simWinsData . rounds . map ( ( round , i ) => ( { x : round , y : simWinsData . wins_by_player [ player ] [ i ] } ) ) ;
232+ const datasets = overviewScoresData . players . map ( ( player ) => {
233+ const data = overviewScoresData . rounds . map ( ( round , i ) => ( {
234+ x : round ,
235+ y : overviewScoresData . scores_by_player [ player ] [ i ] ,
236+ } ) ) ;
231237 const color = colors [ colorIndex % colors . length ] ;
232238 colorIndex ++ ;
233239 return {
@@ -241,7 +247,7 @@ function createSimWinsChart() {
241247 } ;
242248 } ) ;
243249
244- simWinsChart = new Chart ( ctx , {
250+ overviewScoresChart = new Chart ( ctx , {
245251 type : "line" ,
246252 data : { datasets } ,
247253 options : {
@@ -250,7 +256,7 @@ function createSimWinsChart() {
250256 plugins : {
251257 title : {
252258 display : true ,
253- text : `Simulations Won Per Round` ,
259+ text : `Scores Per Round` ,
254260 } ,
255261 legend : {
256262 display : true ,
@@ -264,17 +270,18 @@ function createSimWinsChart() {
264270 position : "bottom" ,
265271 } ,
266272 y : {
267- title : { display : true , text : "Simulations Won " } ,
273+ title : { display : true , text : "Score % " } ,
268274 beginAtZero : true ,
275+ max : 100 ,
269276 } ,
270277 } ,
271278 interaction : { intersect : false , mode : "index" } ,
272279 } ,
273280 } ) ;
274281}
275282
276- // Initialize both analyses when DOM is loaded
283+ // Initialize all analyses when DOM is loaded
277284document . addEventListener ( "DOMContentLoaded" , function ( ) {
278285 initializeAnalysis ( ) ;
279- initializeSimWinsChart ( ) ;
286+ initializeOverviewScoresChart ( ) ;
280287} ) ;
0 commit comments