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

Function createComparisonTimeChart

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

Source from the content-addressed store, hash-verified

1156}
1157
1158function createComparisonTimeChart(data) {
1159 const chartElement = document.getElementById("alternatives-time-chart");
1160 if (!chartElement) return;
1161
1162 // Get the latest benchmark data
1163 const latest = data[0];
1164 if (!latest.alternative_tools || !latest.alternative_tools.files) {
1165 console.log("No alternative tools data available");
1166 return;
1167 }
1168
1169 const files = latest.alternative_tools.files;
1170 const categories = [];
1171 const series = {};
1172
1173 // Collect all CSS files and tools
1174 for (const [filename, fileData] of Object.entries(files)) {
1175 if (!fileData.tools) continue;
1176 if (selectedFile && filename !== selectedFile) continue;
1177
1178 categories.push(filename);
1179
1180 for (const [toolName, toolData] of Object.entries(fileData.tools)) {
1181 if (!series[toolName]) {
1182 series[toolName] = [];
1183 }
1184
1185 if (toolData.error || !toolData.results || !toolData.results[0]) {
1186 series[toolName].push(null);
1187 } else {
1188 // Convert seconds to milliseconds
1189 const timeMs = toolData.results[0].mean * 1000;
1190 series[toolName].push(timeMs);
1191 }
1192 }
1193 }
1194
1195 // Convert to ApexCharts format
1196 const chartSeries = Object.entries(series).map(([toolName, values]) => ({
1197 name: toolName,
1198 data: values,
1199 }));
1200
1201 const isDarkMode = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches;
1202
1203 const options = {
1204 series: chartSeries,
1205 chart: {
1206 type: "bar",
1207 height: 1200,
1208 toolbar: { show: true },
1209 zoom: { enabled: true },
1210 events: {
1211 dataPointSelection: function (event, chartContext, config) {
1212 if (categories[config.dataPointIndex]) {
1213 const clickedFile = categories[config.dataPointIndex];
1214 if (selectedFile === clickedFile) {
1215 // Double-click behavior: reset to show all files

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