MCPcopy Create free account
hub / github.com/csskit/csskit / createComparisonSizeChart

Function createComparisonSizeChart

website/script/benchmarks.js:1305–1448  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

1303}
1304
1305function createComparisonSizeChart(data) {
1306 const chartElement = document.getElementById("alternatives-size-chart");
1307 if (!chartElement) return;
1308
1309 // Get the latest benchmark data
1310 const latest = data[0];
1311 if (!latest.alternative_tools || !latest.alternative_tools.files) {
1312 console.log("No alternative tools data available");
1313 return;
1314 }
1315
1316 const files = latest.alternative_tools.files;
1317 const categories = [];
1318 const series = {};
1319
1320 // Collect all CSS files and tools
1321 for (const [filename, fileData] of Object.entries(files)) {
1322 if (!fileData.tools) continue;
1323 if (selectedFile && filename !== selectedFile) continue;
1324
1325 categories.push(filename);
1326
1327 for (const [toolName, toolData] of Object.entries(fileData.tools)) {
1328 if (!series[toolName]) {
1329 series[toolName] = [];
1330 }
1331
1332 if (toolData.error || !toolData.output_size || toolData.output_size === 0) {
1333 series[toolName].push(null);
1334 } else {
1335 // Convert bytes to KB
1336 const sizeKB = toolData.output_size / 1024;
1337 series[toolName].push(sizeKB);
1338 }
1339 }
1340 }
1341
1342 // Convert to ApexCharts format
1343 const chartSeries = Object.entries(series).map(([toolName, values]) => ({
1344 name: toolName,
1345 data: values,
1346 }));
1347
1348 const options = {
1349 series: chartSeries,
1350 chart: {
1351 type: "bar",
1352 height: 1200,
1353 toolbar: { show: true },
1354 zoom: { enabled: true },
1355 events: {
1356 dataPointSelection: function (event, chartContext, config) {
1357 if (categories[config.dataPointIndex]) {
1358 const clickedFile = categories[config.dataPointIndex];
1359 if (selectedFile === clickedFile) {
1360 // Double-click behavior: reset to show all files
1361 selectedFile = null;
1362 } else {

Callers 1

initializeChartsFunction · 0.85

Calls 5

refreshChartsFunction · 0.85
getChartOptionsFunction · 0.85
getGridBorderColorFunction · 0.85
getChartThemeFunction · 0.85
renderMethod · 0.80

Tested by

no test coverage detected