thinkwee commited on
Commit
1c53c11
Β·
1 Parent(s): 41d056a

fix display

Browse files
Files changed (2) hide show
  1. charts.js +87 -91
  2. index.html +2 -2
charts.js CHANGED
@@ -377,9 +377,9 @@ document.querySelectorAll('.dim-btn:not(.probing-dim)').forEach(btn => {
377
  });
378
 
379
  // ============================================================================
380
- // RANKING COMPARISON - 3 Charts with animated mode switching
381
  // ============================================================================
382
- let currentRankingMode = 'comparison';
383
 
384
  function renderRankingCharts(mode) {
385
  const scenarios = [
@@ -389,120 +389,116 @@ function renderRankingCharts(mode) {
389
  ];
390
 
391
  scenarios.forEach(({ key, id }) => {
392
- const data = DDR_DATA.ranking[key];
393
- if (!data) return;
394
 
395
- const models = data.slice(0, 12); // Top 12 models for better fit
396
- const traces = [];
 
 
 
 
 
397
 
398
- // Get x-axis values based on mode
399
- const getXValue = (m) => {
400
- switch (mode) {
401
- case 'novelty': return m.bt_rank;
402
- case 'accuracy': return m.acc_rank;
403
- default: return m.bt_rank; // For comparison, use bt_rank as base
404
- }
405
- };
406
 
407
- if (mode === 'comparison') {
408
- // Connection lines
409
- models.forEach((m, i) => {
410
- traces.push({
411
- x: [m.bt_rank, m.acc_rank],
412
- y: [i, i],
413
- mode: 'lines',
414
- line: {
415
- color: 'rgba(148, 163, 184, 0.3)',
416
- width: 1.5,
417
- dash: 'dot'
418
- },
419
- showlegend: false,
420
- hoverinfo: 'skip'
421
- });
422
- });
423
 
424
- // Novelty rank points
425
- traces.push({
426
- x: models.map(m => m.bt_rank),
427
- y: models.map((_, i) => i),
428
- mode: 'markers',
429
- name: 'Novelty Rank',
430
- marker: {
431
- size: 10,
432
- symbol: 'circle',
433
- color: '#8B5CF6',
434
- line: { color: '#fff', width: 1 }
435
- },
436
- text: models.map(m => `${m.model}<br>Novelty: #${m.bt_rank}<br>Win Rate: ${m.win_rate}%`),
437
- hovertemplate: '%{text}<extra></extra>'
438
- });
439
 
440
- // Accuracy rank points
441
  traces.push({
442
- x: models.map(m => m.acc_rank),
443
- y: models.map((_, i) => i),
444
- mode: 'markers',
445
- name: 'Accuracy Rank',
446
- marker: {
447
- size: 10,
448
- symbol: 'diamond',
449
- color: '#22C55E',
450
- line: { color: '#fff', width: 1 }
451
  },
452
- text: models.map(m => `${m.model}<br>Accuracy: #${m.acc_rank}<br>${m.accuracy}%`),
453
- hovertemplate: '%{text}<extra></extra>'
454
  });
455
- } else {
456
- // Single mode - just points
457
- const xVals = models.map(m => mode === 'novelty' ? m.bt_rank : m.acc_rank);
458
- const color = mode === 'novelty' ? '#8B5CF6' : '#22C55E';
459
- const label = mode === 'novelty' ? 'Novelty' : 'Accuracy';
460
 
461
- traces.push({
462
- x: xVals,
463
- y: models.map((_, i) => i),
464
- mode: 'markers',
465
- name: label,
466
- marker: {
467
- size: 12,
468
- symbol: 'circle',
469
- color: color,
470
- line: { color: '#fff', width: 1 }
471
- },
472
- text: models.map(m => {
473
- if (mode === 'novelty') {
474
- return `${m.model}<br>Novelty: #${m.bt_rank}<br>Win Rate: ${m.win_rate}%`;
475
- } else {
476
- return `${m.model}<br>Accuracy: #${m.acc_rank}<br>${m.accuracy}%`;
477
- }
478
- }),
479
- hovertemplate: '%{text}<extra></extra>'
480
- });
481
- }
482
 
483
- const maxRank = Math.max(...models.map(m => Math.max(m.bt_rank, m.acc_rank)));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
484
 
485
  const layout = {
486
  ...darkLayout,
487
  xaxis: {
488
  ...darkLayout.xaxis,
489
  title: { text: 'Rank', font: { size: 11, color: '#e2e8f0' } },
490
- range: [maxRank + 1, 0],
491
- dtick: 2
 
492
  },
493
  yaxis: {
494
  ...darkLayout.yaxis,
495
  tickmode: 'array',
496
  tickvals: models.map((_, i) => i),
497
- ticktext: models.map(m => m.model.length > 18 ? m.model.substring(0, 16) + '...' : m.model),
498
- automargin: true
 
499
  },
500
  showlegend: true,
501
  legend: {
502
  ...darkLayout.legend,
503
- y: -0.15
 
 
 
504
  },
505
- margin: { ...darkLayout.margin, l: 130, b: 70 }
506
  };
507
 
508
  Plotly.react(`ranking-${id}`, traces, layout, plotlyConfig);
@@ -510,7 +506,7 @@ function renderRankingCharts(mode) {
510
  }
511
 
512
  function initRankingCharts() {
513
- renderRankingCharts('comparison');
514
  }
515
 
516
  // Ranking mode toggle event listener
 
377
  });
378
 
379
  // ============================================================================
380
+ // RANKING COMPARISON - 3 Charts with mode switching (novelty vs accuracy)
381
  // ============================================================================
382
+ let currentRankingMode = 'novelty';
383
 
384
  function renderRankingCharts(mode) {
385
  const scenarios = [
 
389
  ];
390
 
391
  scenarios.forEach(({ key, id }) => {
392
+ const rawData = DDR_DATA.ranking[key];
393
+ if (!rawData) return;
394
 
395
+ // Sort models by the primary ranking
396
+ let sortedModels;
397
+ if (mode === 'novelty') {
398
+ sortedModels = [...rawData].sort((a, b) => a.bt_rank - b.bt_rank);
399
+ } else {
400
+ sortedModels = [...rawData].sort((a, b) => a.acc_rank - b.acc_rank);
401
+ }
402
 
403
+ // Take top 12 for display
404
+ const models = sortedModels.slice(0, 12);
405
+ const traces = [];
 
 
 
 
 
406
 
407
+ // Define colors
408
+ const primaryColor = mode === 'novelty' ? '#8B5CF6' : '#22C55E';
409
+ const secondaryColor = mode === 'novelty' ? '#22C55E' : '#8B5CF6';
410
+ const primaryLabel = mode === 'novelty' ? 'Novelty Rank' : 'Accuracy Rank';
411
+ const secondaryLabel = mode === 'novelty' ? 'Accuracy Rank' : 'Novelty Rank';
 
 
 
 
 
 
 
 
 
 
 
412
 
413
+ // Connection lines (dashed) from primary to secondary
414
+ models.forEach((m, i) => {
415
+ const primaryX = mode === 'novelty' ? m.bt_rank : m.acc_rank;
416
+ const secondaryX = mode === 'novelty' ? m.acc_rank : m.bt_rank;
 
 
 
 
 
 
 
 
 
 
 
417
 
 
418
  traces.push({
419
+ x: [primaryX, secondaryX],
420
+ y: [i, i],
421
+ mode: 'lines',
422
+ line: {
423
+ color: 'rgba(148, 163, 184, 0.4)',
424
+ width: 1.5,
425
+ dash: 'dot'
 
 
426
  },
427
+ showlegend: false,
428
+ hoverinfo: 'skip'
429
  });
430
+ });
 
 
 
 
431
 
432
+ // Primary rank points (filled circles)
433
+ traces.push({
434
+ x: models.map(m => mode === 'novelty' ? m.bt_rank : m.acc_rank),
435
+ y: models.map((_, i) => i),
436
+ mode: 'markers',
437
+ name: primaryLabel,
438
+ marker: {
439
+ size: 11,
440
+ symbol: 'circle',
441
+ color: primaryColor,
442
+ line: { color: '#fff', width: 1.5 }
443
+ },
444
+ text: models.map(m => {
445
+ if (mode === 'novelty') {
446
+ return `<b>${m.model}</b><br>Novelty: #${m.bt_rank}<br>Win Rate: ${m.win_rate}%`;
447
+ } else {
448
+ return `<b>${m.model}</b><br>Accuracy: #${m.acc_rank}<br>${m.accuracy}%`;
449
+ }
450
+ }),
451
+ hovertemplate: '%{text}<extra></extra>'
452
+ });
453
 
454
+ // Secondary rank points (diamond outline)
455
+ traces.push({
456
+ x: models.map(m => mode === 'novelty' ? m.acc_rank : m.bt_rank),
457
+ y: models.map((_, i) => i),
458
+ mode: 'markers',
459
+ name: secondaryLabel,
460
+ marker: {
461
+ size: 9,
462
+ symbol: 'diamond-open',
463
+ color: secondaryColor,
464
+ line: { width: 2 }
465
+ },
466
+ text: models.map(m => {
467
+ if (mode === 'novelty') {
468
+ return `<b>${m.model}</b><br>Accuracy: #${m.acc_rank}<br>${m.accuracy}%`;
469
+ } else {
470
+ return `<b>${m.model}</b><br>Novelty: #${m.bt_rank}<br>Win Rate: ${m.win_rate}%`;
471
+ }
472
+ }),
473
+ hovertemplate: '%{text}<extra></extra>'
474
+ });
475
 
476
  const layout = {
477
  ...darkLayout,
478
  xaxis: {
479
  ...darkLayout.xaxis,
480
  title: { text: 'Rank', font: { size: 11, color: '#e2e8f0' } },
481
+ range: [23, 0], // Fixed range for all charts
482
+ dtick: 5,
483
+ tick0: 0
484
  },
485
  yaxis: {
486
  ...darkLayout.yaxis,
487
  tickmode: 'array',
488
  tickvals: models.map((_, i) => i),
489
+ ticktext: models.map(m => m.model.length > 16 ? m.model.substring(0, 14) + '...' : m.model),
490
+ automargin: true,
491
+ range: [-0.5, models.length - 0.5]
492
  },
493
  showlegend: true,
494
  legend: {
495
  ...darkLayout.legend,
496
+ y: -0.18,
497
+ orientation: 'h',
498
+ x: 0.5,
499
+ xanchor: 'center'
500
  },
501
+ margin: { t: 20, r: 15, b: 65, l: 120 }
502
  };
503
 
504
  Plotly.react(`ranking-${id}`, traces, layout, plotlyConfig);
 
506
  }
507
 
508
  function initRankingCharts() {
509
+ renderRankingCharts('novelty');
510
  }
511
 
512
  // Ranking mode toggle event listener
index.html CHANGED
@@ -88,10 +88,10 @@
88
  </p>
89
  </div>
90
  <div class="dimension-toggle">
91
- <button class="dim-btn ranking-dim active" data-mode="comparison">πŸ”€ Comparison View</button>
92
- <button class="dim-btn ranking-dim" data-mode="novelty">🎯 Novelty Rank</button>
93
  <button class="dim-btn ranking-dim" data-mode="accuracy">πŸ“Š Accuracy Rank</button>
94
  </div>
 
95
  <div class="charts-grid three-col">
96
  <div class="chart-card">
97
  <h3>MIMIC</h3>
 
88
  </p>
89
  </div>
90
  <div class="dimension-toggle">
91
+ <button class="dim-btn ranking-dim active" data-mode="novelty">🎯 Novelty Rank</button>
 
92
  <button class="dim-btn ranking-dim" data-mode="accuracy">πŸ“Š Accuracy Rank</button>
93
  </div>
94
+
95
  <div class="charts-grid three-col">
96
  <div class="chart-card">
97
  <h3>MIMIC</h3>