thinkwee
commited on
Commit
·
3a90b9e
1
Parent(s):
3d06da8
exact python match
Browse files
charts.js
CHANGED
|
@@ -159,8 +159,7 @@ function updateScalingCharts(dimension) {
|
|
| 159 |
if (!data) return;
|
| 160 |
|
| 161 |
const models = Object.keys(data);
|
| 162 |
-
const
|
| 163 |
-
const newY = [];
|
| 164 |
|
| 165 |
models.forEach(model => {
|
| 166 |
const modelData = data[model];
|
|
@@ -178,69 +177,70 @@ function updateScalingCharts(dimension) {
|
|
| 178 |
break;
|
| 179 |
}
|
| 180 |
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
});
|
| 184 |
|
| 185 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
|
| 187 |
-
//
|
| 188 |
-
const
|
| 189 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 190 |
type: 'linear',
|
| 191 |
dtick: 10,
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
|
|
|
| 197 |
type: 'linear',
|
| 198 |
dtick: 10000,
|
| 199 |
tickformat: ',.0f',
|
| 200 |
-
range: [0, maxX * 1.05]
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
|
|
|
|
|
|
| 204 |
type: 'log',
|
| 205 |
-
dtick: null, // auto for log scale
|
| 206 |
tickformat: '$.3f',
|
| 207 |
-
|
| 208 |
-
|
| 209 |
-
}
|
| 210 |
-
}
|
| 211 |
-
|
| 212 |
-
const settings = xAxisSettings[dimension];
|
| 213 |
-
|
| 214 |
-
// Animate the transition
|
| 215 |
-
Plotly.animate(`scaling-${scenario}`, {
|
| 216 |
-
data: newX.map((x, i) => ({ x, y: newY[i] })),
|
| 217 |
-
traces: models.map((_, i) => i),
|
| 218 |
-
layout: {
|
| 219 |
-
xaxis: {
|
| 220 |
-
title: { text: xLabels[dimension], font: { size: 11, color: '#e2e8f0' } },
|
| 221 |
-
type: settings.type,
|
| 222 |
-
dtick: settings.dtick,
|
| 223 |
-
tickformat: settings.tickformat,
|
| 224 |
-
range: settings.range,
|
| 225 |
-
tick0: settings.tick0,
|
| 226 |
-
exponentformat: 'none'
|
| 227 |
-
}
|
| 228 |
-
}
|
| 229 |
-
}, animationSettings);
|
| 230 |
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 236 |
};
|
| 237 |
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
Plotly.restyle(`scaling-${scenario}`, {
|
| 241 |
-
hovertemplate: `<b>${model}</b><br>${hoverLabels[dimension]}: ${hoverFormat}<br>Accuracy: %{y:.2f}%<extra></extra>`
|
| 242 |
-
}, [i]);
|
| 243 |
-
});
|
| 244 |
});
|
| 245 |
}
|
| 246 |
|
|
|
|
| 159 |
if (!data) return;
|
| 160 |
|
| 161 |
const models = Object.keys(data);
|
| 162 |
+
const traces = [];
|
|
|
|
| 163 |
|
| 164 |
models.forEach(model => {
|
| 165 |
const modelData = data[model];
|
|
|
|
| 177 |
break;
|
| 178 |
}
|
| 179 |
|
| 180 |
+
const hoverLabels = { 'turn': 'Turns', 'token': 'Tokens', 'cost': 'Cost' };
|
| 181 |
+
const hoverFormat = dimension === 'token' ? '%{x:,.0f}' : (dimension === 'cost' ? '$%{x:.4f}' : '%{x}');
|
|
|
|
| 182 |
|
| 183 |
+
traces.push({
|
| 184 |
+
x: xValues,
|
| 185 |
+
y: modelData.accuracy,
|
| 186 |
+
mode: 'lines+markers',
|
| 187 |
+
name: model,
|
| 188 |
+
line: { color: DDR_DATA.modelColors[model] || '#888', width: 2 },
|
| 189 |
+
marker: { size: 6, color: DDR_DATA.modelColors[model] || '#888' },
|
| 190 |
+
hovertemplate: `<b>${model}</b><br>${hoverLabels[dimension]}: ${hoverFormat}<br>Accuracy: %{y:.2f}%<extra></extra>`
|
| 191 |
+
});
|
| 192 |
+
});
|
| 193 |
|
| 194 |
+
// Use exact Y-axis range from Python
|
| 195 |
+
const yRange = SCALING_Y_RANGES[scenario] || [0, 100];
|
| 196 |
+
const allX = traces.flatMap(t => t.x);
|
| 197 |
+
const maxX = Math.max(...allX);
|
| 198 |
+
const minX = Math.min(...allX.filter(v => v > 0));
|
| 199 |
+
|
| 200 |
+
// X-axis settings per dimension
|
| 201 |
+
let xaxis;
|
| 202 |
+
if (dimension === 'turn') {
|
| 203 |
+
xaxis = {
|
| 204 |
+
...darkLayout.xaxis,
|
| 205 |
+
title: { text: xLabels[dimension], font: { size: 11, color: '#e2e8f0' } },
|
| 206 |
type: 'linear',
|
| 207 |
dtick: 10,
|
| 208 |
+
range: [0, maxX + 5]
|
| 209 |
+
};
|
| 210 |
+
} else if (dimension === 'token') {
|
| 211 |
+
xaxis = {
|
| 212 |
+
...darkLayout.xaxis,
|
| 213 |
+
title: { text: xLabels[dimension], font: { size: 11, color: '#e2e8f0' } },
|
| 214 |
type: 'linear',
|
| 215 |
dtick: 10000,
|
| 216 |
tickformat: ',.0f',
|
| 217 |
+
range: [0, maxX * 1.05]
|
| 218 |
+
};
|
| 219 |
+
} else { // cost
|
| 220 |
+
xaxis = {
|
| 221 |
+
...darkLayout.xaxis,
|
| 222 |
+
title: { text: xLabels[dimension], font: { size: 11, color: '#e2e8f0' } },
|
| 223 |
type: 'log',
|
|
|
|
| 224 |
tickformat: '$.3f',
|
| 225 |
+
exponentformat: 'none',
|
| 226 |
+
range: [Math.log10(minX * 0.5), Math.log10(maxX * 1.5)]
|
| 227 |
+
};
|
| 228 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 229 |
|
| 230 |
+
const layout = {
|
| 231 |
+
...darkLayout,
|
| 232 |
+
xaxis: xaxis,
|
| 233 |
+
yaxis: {
|
| 234 |
+
...darkLayout.yaxis,
|
| 235 |
+
title: { text: 'Accuracy (%)', font: { size: 11, color: '#e2e8f0' } },
|
| 236 |
+
dtick: 5,
|
| 237 |
+
range: yRange
|
| 238 |
+
},
|
| 239 |
+
showlegend: true
|
| 240 |
};
|
| 241 |
|
| 242 |
+
// Use react for smooth update without animation freeze
|
| 243 |
+
Plotly.react(`scaling-${scenario}`, traces, layout, plotlyConfig);
|
|
|
|
|
|
|
|
|
|
|
|
|
| 244 |
});
|
| 245 |
}
|
| 246 |
|