(label, leftRun, rightRun, key, formatter)
| 1011 | } |
| 1012 | |
| 1013 | function compareBarChart(label, leftRun, rightRun, key, formatter) { |
| 1014 | const tone = buildCompareTone(leftRun.overview?.[key], rightRun.overview?.[key], formatter); |
| 1015 | const values = [ |
| 1016 | { label: "A", name: leftRun.name, value: leftRun.overview?.[key] ?? null, color: "#0979c6", toneClass: tone.leftClass }, |
| 1017 | { label: "B", name: rightRun.name, value: rightRun.overview?.[key] ?? null, color: "#8b9bb1", toneClass: tone.rightClass }, |
| 1018 | ]; |
| 1019 | const actual = values.filter((item) => item.value !== null && item.value !== undefined); |
| 1020 | if (!actual.length) { |
| 1021 | return emptyBlock(`Neither report exported ${label.toLowerCase()}.`); |
| 1022 | } |
| 1023 | |
| 1024 | const maxValue = Math.max(...actual.map((item) => item.value), 1); |
| 1025 | return ` |
| 1026 | <div class="bar-chart"> |
| 1027 | ${values |
| 1028 | .map( |
| 1029 | (item) => ` |
| 1030 | <div class="bar-chart-row ${item.toneClass}"> |
| 1031 | <div class="compare-bar-label"> |
| 1032 | <strong>${escapeHtml(item.label)}</strong> |
| 1033 | <span>${escapeHtml(item.name)}</span> |
| 1034 | </div> |
| 1035 | <div class="bar-chart-track"><div class="bar-chart-fill" style="width:${item.value ? (item.value / maxValue) * 100 : 0}%; background:${item.color}"></div></div> |
| 1036 | <strong>${escapeHtml(formatter(item.value))}</strong> |
| 1037 | </div> |
| 1038 | ` |
| 1039 | ) |
| 1040 | .join("")} |
| 1041 | </div> |
| 1042 | <div class="compare-legend"> |
| 1043 | ${values |
| 1044 | .map( |
| 1045 | (item) => ` |
| 1046 | <span class="compare-legend-item"> |
| 1047 | <span class="compare-legend-swatch" style="background:${item.color}"></span> |
| 1048 | ${escapeHtml(item.label)}: ${escapeHtml(item.name)} |
| 1049 | </span> |
| 1050 | ` |
| 1051 | ) |
| 1052 | .join("")} |
| 1053 | </div> |
| 1054 | `; |
| 1055 | } |
| 1056 | |
| 1057 | function buildRunMeta(run, points) { |
| 1058 | const parts = []; |
no test coverage detected