Spaces:
Running
Running
Update index.html
Browse files- index.html +39 -38
index.html
CHANGED
@@ -77,15 +77,7 @@
|
|
77 |
<div class="table-container">
|
78 |
<table id="csvTable">
|
79 |
<thead>
|
80 |
-
|
81 |
-
<th>Metric Type</th>
|
82 |
-
<th>Benchmark</th>
|
83 |
-
<th>Output Type</th>
|
84 |
-
<th>Details</th>
|
85 |
-
<th>Metric Example</th>
|
86 |
-
<th>Question + Context Example</th>
|
87 |
-
<th>Answer Example</th>
|
88 |
-
</tr>
|
89 |
</thead>
|
90 |
<tbody>
|
91 |
<!-- Rows will be dynamically added here -->
|
@@ -98,14 +90,10 @@
|
|
98 |
function parseCSV(content) {
|
99 |
const rows = content.split("\n").filter(row => row.trim() !== "");
|
100 |
const headers = rows.shift().split(",");
|
101 |
-
return
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
obj[header.trim()] = values[index]?.trim() || "";
|
106 |
-
});
|
107 |
-
return obj;
|
108 |
-
});
|
109 |
}
|
110 |
|
111 |
// Load CSV file
|
@@ -117,10 +105,12 @@
|
|
117 |
|
118 |
// Populate filter options
|
119 |
const metricFilter = document.getElementById('metricFilter');
|
120 |
-
const
|
|
|
|
|
121 |
|
122 |
-
function populateFilterOptions(data) {
|
123 |
-
const uniqueMetricTypes = [...new Set(data.map(row => row[
|
124 |
uniqueMetricTypes.forEach(type => {
|
125 |
const option = document.createElement('option');
|
126 |
option.value = type;
|
@@ -130,39 +120,50 @@
|
|
130 |
}
|
131 |
|
132 |
// Populate table
|
133 |
-
function populateTable(
|
|
|
134 |
tableBody.innerHTML = '';
|
135 |
-
filteredData.forEach(row => {
|
136 |
-
const tr = document.createElement('tr');
|
137 |
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
td.classList.add('expandable');
|
143 |
td.title = 'Click to expand';
|
144 |
td.addEventListener('click', () => {
|
145 |
td.classList.toggle('expanded');
|
146 |
});
|
147 |
-
|
148 |
-
|
|
|
|
|
149 |
});
|
150 |
-
tableBody.appendChild(tr);
|
151 |
-
});
|
152 |
}
|
153 |
|
154 |
metricFilter.addEventListener('change', () => {
|
155 |
const filterValue = metricFilter.value;
|
156 |
-
|
157 |
-
populateTable(filteredData);
|
158 |
});
|
159 |
|
160 |
// Initial load
|
161 |
-
let
|
162 |
-
loadCSV('benchmark_overview_data.csv').then(
|
163 |
-
|
164 |
-
populateFilterOptions(
|
165 |
-
populateTable(
|
166 |
});
|
167 |
</script>
|
168 |
</body>
|
|
|
77 |
<div class="table-container">
|
78 |
<table id="csvTable">
|
79 |
<thead>
|
80 |
+
<!-- Headers will be dynamically added -->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
</thead>
|
82 |
<tbody>
|
83 |
<!-- Rows will be dynamically added here -->
|
|
|
90 |
function parseCSV(content) {
|
91 |
const rows = content.split("\n").filter(row => row.trim() !== "");
|
92 |
const headers = rows.shift().split(",");
|
93 |
+
return {
|
94 |
+
headers,
|
95 |
+
rows: rows.map(row => row.split(","))
|
96 |
+
};
|
|
|
|
|
|
|
|
|
97 |
}
|
98 |
|
99 |
// Load CSV file
|
|
|
105 |
|
106 |
// Populate filter options
|
107 |
const metricFilter = document.getElementById('metricFilter');
|
108 |
+
const table = document.getElementById('csvTable');
|
109 |
+
const tableHead = table.querySelector('thead');
|
110 |
+
const tableBody = table.querySelector('tbody');
|
111 |
|
112 |
+
function populateFilterOptions(data, headerIndex) {
|
113 |
+
const uniqueMetricTypes = [...new Set(data.map(row => row[headerIndex]))];
|
114 |
uniqueMetricTypes.forEach(type => {
|
115 |
const option = document.createElement('option');
|
116 |
option.value = type;
|
|
|
120 |
}
|
121 |
|
122 |
// Populate table
|
123 |
+
function populateTable(headers, rows, filterValue, headerIndex) {
|
124 |
+
tableHead.innerHTML = '';
|
125 |
tableBody.innerHTML = '';
|
|
|
|
|
126 |
|
127 |
+
// Add headers dynamically
|
128 |
+
const headerRow = document.createElement('tr');
|
129 |
+
headers.forEach(header => {
|
130 |
+
const th = document.createElement('th');
|
131 |
+
th.textContent = header;
|
132 |
+
headerRow.appendChild(th);
|
133 |
+
});
|
134 |
+
tableHead.appendChild(headerRow);
|
135 |
+
|
136 |
+
// Add rows dynamically
|
137 |
+
rows.filter(row => !filterValue || row[headerIndex] === filterValue)
|
138 |
+
.forEach(row => {
|
139 |
+
const tr = document.createElement('tr');
|
140 |
+
|
141 |
+
row.forEach((value, index) => {
|
142 |
+
const td = document.createElement('td');
|
143 |
+
td.textContent = value;
|
144 |
td.classList.add('expandable');
|
145 |
td.title = 'Click to expand';
|
146 |
td.addEventListener('click', () => {
|
147 |
td.classList.toggle('expanded');
|
148 |
});
|
149 |
+
tr.appendChild(td);
|
150 |
+
});
|
151 |
+
|
152 |
+
tableBody.appendChild(tr);
|
153 |
});
|
|
|
|
|
154 |
}
|
155 |
|
156 |
metricFilter.addEventListener('change', () => {
|
157 |
const filterValue = metricFilter.value;
|
158 |
+
populateTable(parsedCSV.headers, parsedCSV.rows, filterValue, 0); // Assuming Metric Type is the first column
|
|
|
159 |
});
|
160 |
|
161 |
// Initial load
|
162 |
+
let parsedCSV;
|
163 |
+
loadCSV('benchmark_overview_data.csv').then(({ headers, rows }) => {
|
164 |
+
parsedCSV = { headers, rows };
|
165 |
+
populateFilterOptions(rows, 0); // Assuming Metric Type is the first column
|
166 |
+
populateTable(headers, rows, '', 0);
|
167 |
});
|
168 |
</script>
|
169 |
</body>
|