Commit
·
9e66e53
1
Parent(s):
5e1bfc9
Improve confusion matrix layout and add metric tooltips
Browse files- direct_classifier.html +4 -4
- inverse_classifier.html +4 -4
- src/css/inverse_style.css +26 -19
- src/css/style.css +26 -19
- src/js/direct_classifier.js +76 -3
- src/js/inverse_classifier.js +75 -3
direct_classifier.html
CHANGED
|
@@ -40,12 +40,12 @@
|
|
| 40 |
</div>
|
| 41 |
<div class="chart-card">
|
| 42 |
<div class="chart-title">📋 Confusion Matrix</div>
|
| 43 |
-
<div class="matrix-
|
| 44 |
<div class="matrix-ylabel">TRUE class</div>
|
| 45 |
-
<div class="matrix-
|
| 46 |
-
<canvas id="matrixChart" width="
|
| 47 |
-
<div class="matrix-xlabel">PREDICTED class</div>
|
| 48 |
</div>
|
|
|
|
| 49 |
</div>
|
| 50 |
</div>
|
| 51 |
<div class="chart-card">
|
|
|
|
| 40 |
</div>
|
| 41 |
<div class="chart-card">
|
| 42 |
<div class="chart-title">📋 Confusion Matrix</div>
|
| 43 |
+
<div class="confusion-matrix-layout">
|
| 44 |
<div class="matrix-ylabel">TRUE class</div>
|
| 45 |
+
<div class="matrix-canvas-container">
|
| 46 |
+
<canvas id="matrixChart" width="300" height="300"></canvas>
|
|
|
|
| 47 |
</div>
|
| 48 |
+
<div class="matrix-xlabel">PREDICTED class</div>
|
| 49 |
</div>
|
| 50 |
</div>
|
| 51 |
<div class="chart-card">
|
inverse_classifier.html
CHANGED
|
@@ -54,12 +54,12 @@
|
|
| 54 |
</div>
|
| 55 |
<div class="chart-card">
|
| 56 |
<div class="chart-title">📋 Confusion Matrix</div>
|
| 57 |
-
<div class="matrix-
|
| 58 |
<div class="matrix-ylabel">TRUE class</div>
|
| 59 |
-
<div class="matrix-
|
| 60 |
-
<canvas id="matrixChart" width="
|
| 61 |
-
<div class="matrix-xlabel">PREDICTED class</div>
|
| 62 |
</div>
|
|
|
|
| 63 |
</div>
|
| 64 |
</div>
|
| 65 |
<div class="chart-card">
|
|
|
|
| 54 |
</div>
|
| 55 |
<div class="chart-card">
|
| 56 |
<div class="chart-title">📋 Confusion Matrix</div>
|
| 57 |
+
<div class="confusion-matrix-layout">
|
| 58 |
<div class="matrix-ylabel">TRUE class</div>
|
| 59 |
+
<div class="matrix-canvas-container">
|
| 60 |
+
<canvas id="matrixChart" width="300" height="300"></canvas>
|
|
|
|
| 61 |
</div>
|
| 62 |
+
<div class="matrix-xlabel">PREDICTED class</div>
|
| 63 |
</div>
|
| 64 |
</div>
|
| 65 |
<div class="chart-card">
|
src/css/inverse_style.css
CHANGED
|
@@ -165,34 +165,41 @@ h1 {
|
|
| 165 |
position: relative;
|
| 166 |
height: 300px;
|
| 167 |
margin-bottom: 20px;
|
| 168 |
-
display: flex;
|
| 169 |
-
justify-content: center;
|
| 170 |
-
align-items: center;
|
| 171 |
}
|
| 172 |
|
| 173 |
-
.matrix-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
}
|
| 181 |
|
| 182 |
-
.matrix-ylabel
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
margin-right: 15px;
|
| 187 |
color: #555;
|
| 188 |
font-style: italic;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 189 |
}
|
| 190 |
|
| 191 |
.matrix-xlabel {
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 196 |
}
|
| 197 |
|
| 198 |
#matrixChart {
|
|
|
|
| 165 |
position: relative;
|
| 166 |
height: 300px;
|
| 167 |
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
| 168 |
}
|
| 169 |
|
| 170 |
+
.confusion-matrix-layout {
|
| 171 |
+
position: relative;
|
| 172 |
+
width: 250px;
|
| 173 |
+
height: 250px;
|
| 174 |
+
margin: 0 auto; /* Center the block horizontally */
|
| 175 |
+
top: 50%; /* Center the block vertically */
|
| 176 |
+
transform: translateY(-50%);
|
| 177 |
}
|
| 178 |
|
| 179 |
+
.matrix-ylabel,
|
| 180 |
+
.matrix-xlabel {
|
| 181 |
+
position: absolute;
|
| 182 |
+
font-weight: bold;
|
|
|
|
| 183 |
color: #555;
|
| 184 |
font-style: italic;
|
| 185 |
+
white-space: nowrap;
|
| 186 |
+
}
|
| 187 |
+
|
| 188 |
+
.matrix-ylabel {
|
| 189 |
+
top: 50%;
|
| 190 |
+
left: -20px; /* Position label just outside the container */
|
| 191 |
+
transform: translateY(-50%) rotate(-90deg);
|
| 192 |
}
|
| 193 |
|
| 194 |
.matrix-xlabel {
|
| 195 |
+
bottom: -25px; /* Position label just outside the container */
|
| 196 |
+
left: 50%;
|
| 197 |
+
transform: translateX(-50%);
|
| 198 |
+
}
|
| 199 |
+
|
| 200 |
+
.matrix-canvas-container {
|
| 201 |
+
width: 100%;
|
| 202 |
+
height: 100%;
|
| 203 |
}
|
| 204 |
|
| 205 |
#matrixChart {
|
src/css/style.css
CHANGED
|
@@ -104,34 +104,41 @@ h1 {
|
|
| 104 |
position: relative;
|
| 105 |
height: 300px;
|
| 106 |
margin-bottom: 20px;
|
| 107 |
-
display: flex;
|
| 108 |
-
justify-content: center;
|
| 109 |
-
align-items: center;
|
| 110 |
}
|
| 111 |
|
| 112 |
-
.matrix-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
}
|
| 120 |
|
| 121 |
-
.matrix-ylabel
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
margin-right: 15px;
|
| 126 |
color: #555;
|
| 127 |
font-style: italic;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
}
|
| 129 |
|
| 130 |
.matrix-xlabel {
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 135 |
}
|
| 136 |
|
| 137 |
#matrixChart {
|
|
|
|
| 104 |
position: relative;
|
| 105 |
height: 300px;
|
| 106 |
margin-bottom: 20px;
|
|
|
|
|
|
|
|
|
|
| 107 |
}
|
| 108 |
|
| 109 |
+
.confusion-matrix-layout {
|
| 110 |
+
position: relative;
|
| 111 |
+
width: 250px;
|
| 112 |
+
height: 250px;
|
| 113 |
+
margin: 0 auto; /* Center the block horizontally */
|
| 114 |
+
top: 50%; /* Center the block vertically */
|
| 115 |
+
transform: translateY(-50%);
|
| 116 |
}
|
| 117 |
|
| 118 |
+
.matrix-ylabel,
|
| 119 |
+
.matrix-xlabel {
|
| 120 |
+
position: absolute;
|
| 121 |
+
font-weight: bold;
|
|
|
|
| 122 |
color: #555;
|
| 123 |
font-style: italic;
|
| 124 |
+
white-space: nowrap;
|
| 125 |
+
}
|
| 126 |
+
|
| 127 |
+
.matrix-ylabel {
|
| 128 |
+
top: 50%;
|
| 129 |
+
left: -20px; /* Position label just outside the container */
|
| 130 |
+
transform: translateY(-50%) rotate(-90deg);
|
| 131 |
}
|
| 132 |
|
| 133 |
.matrix-xlabel {
|
| 134 |
+
bottom: -25px; /* Position label just outside the container */
|
| 135 |
+
left: 50%;
|
| 136 |
+
transform: translateX(-50%);
|
| 137 |
+
}
|
| 138 |
+
|
| 139 |
+
.matrix-canvas-container {
|
| 140 |
+
width: 100%;
|
| 141 |
+
height: 100%;
|
| 142 |
}
|
| 143 |
|
| 144 |
#matrixChart {
|
src/js/direct_classifier.js
CHANGED
|
@@ -2,6 +2,39 @@
|
|
| 2 |
let dataChart, rocChart, metricsChart;
|
| 3 |
const N_SAMPLES_PER_CLASS = 100;
|
| 4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
// --- DATA GENERATION ---
|
| 6 |
function randomGaussian(mean = 0, stdDev = 1) {
|
| 7 |
let u = 0, v = 0;
|
|
@@ -106,8 +139,13 @@ function drawConfusionMatrix(canvasId, vp, fp, vn, fn) {
|
|
| 106 |
ctx.fillStyle = '#333'; ctx.font = 'bold 14px Segoe UI';
|
| 107 |
ctx.fillText('Negative', margin + cellW / 2, gridH + 20);
|
| 108 |
ctx.fillText('Positive', margin + cellW + cellW / 2, gridH + 20);
|
| 109 |
-
ctx.save();
|
| 110 |
-
ctx.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 111 |
ctx.restore();
|
| 112 |
}
|
| 113 |
|
|
@@ -177,7 +215,42 @@ function initCharts() {
|
|
| 177 |
type: 'bar',
|
| 178 |
data: { labels: ['AUC', 'Accuracy', 'Precision', 'Recall', 'Specificity', 'F1-Score'], datasets: [{ data: [], backgroundColor: ['#673AB7', '#009688', '#1E88E5', '#388E3C', '#FB8C00', '#9C27B0'] }] },
|
| 179 |
plugins: [customDatalabelsPlugin],
|
| 180 |
-
options: {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 181 |
});
|
| 182 |
}
|
| 183 |
|
|
|
|
| 2 |
let dataChart, rocChart, metricsChart;
|
| 3 |
const N_SAMPLES_PER_CLASS = 100;
|
| 4 |
|
| 5 |
+
const metricExplanations = {
|
| 6 |
+
'AUC': {
|
| 7 |
+
description: "Measures the model's ability to distinguish between positive and negative classes. It represents the probability that a random positive instance is ranked higher than a random negative instance.",
|
| 8 |
+
range: "Ranges from 0 (worst) to 1 (best). 0.5 is random chance.",
|
| 9 |
+
formula: "Area Under the ROC Curve"
|
| 10 |
+
},
|
| 11 |
+
'Accuracy': {
|
| 12 |
+
description: "The proportion of all predictions that are correct. It's a general measure of the model's performance.",
|
| 13 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 14 |
+
formula: "(TP + TN) / (TP + TN + FP + FN)"
|
| 15 |
+
},
|
| 16 |
+
'Precision': {
|
| 17 |
+
description: "Of all the positive predictions made by the model, how many were actually positive. High precision indicates a low false positive rate.",
|
| 18 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 19 |
+
formula: "TP / (TP + FP)"
|
| 20 |
+
},
|
| 21 |
+
'Recall': {
|
| 22 |
+
description: "Of all the actual positive instances, how many did the model correctly identify. Also known as Sensitivity or True Positive Rate.",
|
| 23 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 24 |
+
formula: "TP / (TP + FN)"
|
| 25 |
+
},
|
| 26 |
+
'Specificity': {
|
| 27 |
+
description: "Of all the actual negative instances, how many did the model correctly identify. Also known as True Negative Rate.",
|
| 28 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 29 |
+
formula: "TN / (TN + FP)"
|
| 30 |
+
},
|
| 31 |
+
'F1-Score': {
|
| 32 |
+
description: "The harmonic mean of Precision and Recall. It provides a single score that balances both concerns, useful for imbalanced classes.",
|
| 33 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 34 |
+
formula: "2 * (Precision * Recall) / (Precision + Recall)"
|
| 35 |
+
}
|
| 36 |
+
};
|
| 37 |
+
|
| 38 |
// --- DATA GENERATION ---
|
| 39 |
function randomGaussian(mean = 0, stdDev = 1) {
|
| 40 |
let u = 0, v = 0;
|
|
|
|
| 139 |
ctx.fillStyle = '#333'; ctx.font = 'bold 14px Segoe UI';
|
| 140 |
ctx.fillText('Negative', margin + cellW / 2, gridH + 20);
|
| 141 |
ctx.fillText('Positive', margin + cellW + cellW / 2, gridH + 20);
|
| 142 |
+
ctx.save();
|
| 143 |
+
ctx.translate(20, gridH / 2);
|
| 144 |
+
ctx.rotate(-Math.PI / 2);
|
| 145 |
+
ctx.textAlign = 'center';
|
| 146 |
+
ctx.textBaseline = 'middle';
|
| 147 |
+
ctx.fillText('Positive', -cellH / 2, 0);
|
| 148 |
+
ctx.fillText('Negative', cellH / 2, 0);
|
| 149 |
ctx.restore();
|
| 150 |
}
|
| 151 |
|
|
|
|
| 215 |
type: 'bar',
|
| 216 |
data: { labels: ['AUC', 'Accuracy', 'Precision', 'Recall', 'Specificity', 'F1-Score'], datasets: [{ data: [], backgroundColor: ['#673AB7', '#009688', '#1E88E5', '#388E3C', '#FB8C00', '#9C27B0'] }] },
|
| 217 |
plugins: [customDatalabelsPlugin],
|
| 218 |
+
options: {
|
| 219 |
+
responsive: true,
|
| 220 |
+
maintainAspectRatio: false,
|
| 221 |
+
indexAxis: 'x',
|
| 222 |
+
animation: { duration: 0 },
|
| 223 |
+
plugins: {
|
| 224 |
+
legend: { display: false },
|
| 225 |
+
tooltip: {
|
| 226 |
+
enabled: true,
|
| 227 |
+
backgroundColor: 'rgba(255, 255, 255, 0.95)',
|
| 228 |
+
titleColor: '#000',
|
| 229 |
+
bodyColor: '#000',
|
| 230 |
+
borderColor: '#555',
|
| 231 |
+
borderWidth: 1,
|
| 232 |
+
padding: 15,
|
| 233 |
+
displayColors: false,
|
| 234 |
+
callbacks: {
|
| 235 |
+
label: function (context) {
|
| 236 |
+
const label = context.chart.data.labels[context.dataIndex];
|
| 237 |
+
const value = context.raw.toFixed(3);
|
| 238 |
+
const explanation = metricExplanations[label];
|
| 239 |
+
let tooltipText = [`${label}: ${value}`];
|
| 240 |
+
if (explanation) {
|
| 241 |
+
tooltipText.push('');
|
| 242 |
+
const roleLines = `Role: ${explanation.description}`.match(/.{1,50}(\s|$)/g) || [];
|
| 243 |
+
roleLines.forEach(line => tooltipText.push(line.trim()));
|
| 244 |
+
tooltipText.push(`Range: ${explanation.range}`);
|
| 245 |
+
tooltipText.push(`Formula: ${explanation.formula}`);
|
| 246 |
+
}
|
| 247 |
+
return tooltipText;
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
},
|
| 252 |
+
scales: { y: { beginAtZero: true, max: 1 } }
|
| 253 |
+
}
|
| 254 |
});
|
| 255 |
}
|
| 256 |
|
src/js/inverse_classifier.js
CHANGED
|
@@ -1,5 +1,37 @@
|
|
| 1 |
// --- GLOBAL VARIABLES ---
|
| 2 |
let scoresChart, rocChart, metricsChart;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
let lockState = { tp: false, fp: false, tn: false, fn: false };
|
| 4 |
let currentState = { tp: 70, fp: 20, tn: 80, fn: 30 };
|
| 5 |
const TOTAL_SAMPLES = 200;
|
|
@@ -87,8 +119,13 @@ function drawConfusionMatrix(canvasId, tp, fp, tn, fn) {
|
|
| 87 |
ctx.fillStyle = '#333'; ctx.font = 'bold 14px Segoe UI';
|
| 88 |
ctx.fillText('Negative', margin + cellW / 2, gridH + 20);
|
| 89 |
ctx.fillText('Positive', margin + cellW + cellW / 2, gridH + 20);
|
| 90 |
-
ctx.save();
|
| 91 |
-
ctx.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
ctx.restore();
|
| 93 |
}
|
| 94 |
|
|
@@ -178,7 +215,42 @@ function initCharts() {
|
|
| 178 |
type: 'bar',
|
| 179 |
data: { labels: ['AUC', 'Accuracy', 'Precision', 'Recall', 'Specificity', 'F1-Score'], datasets: [{ data: [], backgroundColor: ['#673AB7', '#009688', '#1E88E5', '#388E3C', '#FB8C00', '#9C27B0'] }] },
|
| 180 |
plugins: [customDatalabelsPlugin],
|
| 181 |
-
options: {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 182 |
});
|
| 183 |
}
|
| 184 |
|
|
|
|
| 1 |
// --- GLOBAL VARIABLES ---
|
| 2 |
let scoresChart, rocChart, metricsChart;
|
| 3 |
+
const metricExplanations = {
|
| 4 |
+
'AUC': {
|
| 5 |
+
description: "Measures the model's ability to distinguish between positive and negative classes. It represents the probability that a random positive instance is ranked higher than a random negative instance.",
|
| 6 |
+
range: "Ranges from 0 (worst) to 1 (best). 0.5 is random chance.",
|
| 7 |
+
formula: "Area Under the ROC Curve"
|
| 8 |
+
},
|
| 9 |
+
'Accuracy': {
|
| 10 |
+
description: "The proportion of all predictions that are correct. It's a general measure of the model's performance.",
|
| 11 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 12 |
+
formula: "(TP + TN) / (TP + TN + FP + FN)"
|
| 13 |
+
},
|
| 14 |
+
'Precision': {
|
| 15 |
+
description: "Of all the positive predictions made by the model, how many were actually positive. High precision indicates a low false positive rate.",
|
| 16 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 17 |
+
formula: "TP / (TP + FP)"
|
| 18 |
+
},
|
| 19 |
+
'Recall': {
|
| 20 |
+
description: "Of all the actual positive instances, how many did the model correctly identify. Also known as Sensitivity or True Positive Rate.",
|
| 21 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 22 |
+
formula: "TP / (TP + FN)"
|
| 23 |
+
},
|
| 24 |
+
'Specificity': {
|
| 25 |
+
description: "Of all the actual negative instances, how many did the model correctly identify. Also known as True Negative Rate.",
|
| 26 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 27 |
+
formula: "TN / (TN + FP)"
|
| 28 |
+
},
|
| 29 |
+
'F1-Score': {
|
| 30 |
+
description: "The harmonic mean of Precision and Recall. It provides a single score that balances both concerns, useful for imbalanced classes.",
|
| 31 |
+
range: "Ranges from 0 (worst) to 1 (best).",
|
| 32 |
+
formula: "2 * (Precision * Recall) / (Precision + Recall)"
|
| 33 |
+
}
|
| 34 |
+
};
|
| 35 |
let lockState = { tp: false, fp: false, tn: false, fn: false };
|
| 36 |
let currentState = { tp: 70, fp: 20, tn: 80, fn: 30 };
|
| 37 |
const TOTAL_SAMPLES = 200;
|
|
|
|
| 119 |
ctx.fillStyle = '#333'; ctx.font = 'bold 14px Segoe UI';
|
| 120 |
ctx.fillText('Negative', margin + cellW / 2, gridH + 20);
|
| 121 |
ctx.fillText('Positive', margin + cellW + cellW / 2, gridH + 20);
|
| 122 |
+
ctx.save();
|
| 123 |
+
ctx.translate(20, gridH / 2);
|
| 124 |
+
ctx.rotate(-Math.PI / 2);
|
| 125 |
+
ctx.textAlign = 'center';
|
| 126 |
+
ctx.textBaseline = 'middle';
|
| 127 |
+
ctx.fillText('Positive', -cellH / 2, 0);
|
| 128 |
+
ctx.fillText('Negative', cellH / 2, 0);
|
| 129 |
ctx.restore();
|
| 130 |
}
|
| 131 |
|
|
|
|
| 215 |
type: 'bar',
|
| 216 |
data: { labels: ['AUC', 'Accuracy', 'Precision', 'Recall', 'Specificity', 'F1-Score'], datasets: [{ data: [], backgroundColor: ['#673AB7', '#009688', '#1E88E5', '#388E3C', '#FB8C00', '#9C27B0'] }] },
|
| 217 |
plugins: [customDatalabelsPlugin],
|
| 218 |
+
options: {
|
| 219 |
+
responsive: true,
|
| 220 |
+
maintainAspectRatio: false,
|
| 221 |
+
indexAxis: 'x',
|
| 222 |
+
animation: { duration: 0 },
|
| 223 |
+
plugins: {
|
| 224 |
+
legend: { display: false },
|
| 225 |
+
tooltip: {
|
| 226 |
+
enabled: true,
|
| 227 |
+
backgroundColor: 'rgba(255, 255, 255, 0.95)',
|
| 228 |
+
titleColor: '#000',
|
| 229 |
+
bodyColor: '#000',
|
| 230 |
+
borderColor: '#555',
|
| 231 |
+
borderWidth: 1,
|
| 232 |
+
padding: 15,
|
| 233 |
+
displayColors: false,
|
| 234 |
+
callbacks: {
|
| 235 |
+
label: function (context) {
|
| 236 |
+
const label = context.chart.data.labels[context.dataIndex];
|
| 237 |
+
const value = context.raw.toFixed(3);
|
| 238 |
+
const explanation = metricExplanations[label];
|
| 239 |
+
let tooltipText = [`${label}: ${value}`];
|
| 240 |
+
if (explanation) {
|
| 241 |
+
tooltipText.push('');
|
| 242 |
+
const roleLines = `Role: ${explanation.description}`.match(/.{1,50}(\s|$)/g) || [];
|
| 243 |
+
roleLines.forEach(line => tooltipText.push(line.trim()));
|
| 244 |
+
tooltipText.push(`Range: ${explanation.range}`);
|
| 245 |
+
tooltipText.push(`Formula: ${explanation.formula}`);
|
| 246 |
+
}
|
| 247 |
+
return tooltipText;
|
| 248 |
+
}
|
| 249 |
+
}
|
| 250 |
+
}
|
| 251 |
+
},
|
| 252 |
+
scales: { y: { beginAtZero: true, max: 1 } }
|
| 253 |
+
}
|
| 254 |
});
|
| 255 |
}
|
| 256 |
|