|
| 1 | +<!DOCTYPE html> |
| 2 | +<html lang="en"> |
| 3 | +<head> |
| 4 | + <meta charset="UTF-8"/> |
| 5 | + <title>Diff — {{TITLE}}</title> |
| 6 | + <link rel="stylesheet" href="../../assets/dygraph.min.css"/> |
| 7 | + <script src="../../assets/dygraph.min.js"></script> |
| 8 | + <style> |
| 9 | + body { font-family: sans-serif; margin: 2em; font-size: 14px; } |
| 10 | + h1 { font-size: 1.3em; } |
| 11 | + h3 { font-size: 1.1em; margin-top: 2.5em; border-bottom: 1px solid #ddd; |
| 12 | + padding-bottom: 4px; } |
| 13 | + .graph { width: 100%; height: 320px; margin-bottom: 0.5em; } |
| 14 | + .meta { color: #555; font-size: 12px; margin: 0.4em 0 2em; } |
| 15 | + a { color: #0366d6; text-decoration: none; } |
| 16 | + a:hover { text-decoration: underline; } |
| 17 | + .dygraph-legend { font-size: 12px !important; } |
| 18 | + </style> |
| 19 | +</head> |
| 20 | +<body> |
| 21 | +<h1>Diff — {{MODEL}}</h1> |
| 22 | +<p class="meta"> |
| 23 | + {{N_FAIL}} signal(s) outside tolerance |
| 24 | + (rel ≤ {{REL_TOL_PCT}}%, abs ≤ {{ABS_TOL}}) |
| 25 | + · |
| 26 | + <a href="{{CSV_NAME}}">Download CSV</a> |
| 27 | +</p> |
| 28 | +<div id="charts"></div> |
| 29 | +<script> |
| 30 | +var csvRaw = `{{CSV_DATA}}`; |
| 31 | + |
| 32 | +(function () { |
| 33 | + var lines = csvRaw.trim().split('\n'); |
| 34 | + var headers = lines[0].split(',').map(function (s) { return s.trim(); }); |
| 35 | + var rows = lines.slice(1).filter(function (l) { return l.trim() !== ''; }) |
| 36 | + .map(function (l) { return l.split(',').map(Number); }); |
| 37 | + |
| 38 | + // Collect unique signal names from columns ending with "_ref" |
| 39 | + var sigs = [], seen = {}; |
| 40 | + headers.forEach(function (h) { |
| 41 | + if (h.slice(-4) === '_ref') { |
| 42 | + var sig = h.slice(0, h.length - 4); |
| 43 | + if (!seen[sig]) { sigs.push(sig); seen[sig] = true; } |
| 44 | + } |
| 45 | + }); |
| 46 | + |
| 47 | + var container = document.getElementById('charts'); |
| 48 | + |
| 49 | + sigs.forEach(function (sig, si) { |
| 50 | + var refIdx = headers.indexOf(sig + '_ref'); |
| 51 | + var simIdx = headers.indexOf(sig + '_sim'); |
| 52 | + var errIdx = headers.indexOf(sig + '_relerr'); |
| 53 | + |
| 54 | + var data = rows.map(function (r) { |
| 55 | + return [r[0], r[refIdx], r[simIdx], r[errIdx]]; |
| 56 | + }); |
| 57 | + |
| 58 | + var h3 = document.createElement('h3'); |
| 59 | + h3.textContent = sig; |
| 60 | + var div = document.createElement('div'); |
| 61 | + div.id = 'g' + si; |
| 62 | + div.className = 'graph'; |
| 63 | + container.appendChild(h3); |
| 64 | + container.appendChild(div); |
| 65 | + |
| 66 | + new Dygraph(div, data, { |
| 67 | + labels: ['time', sig + ' (ref)', sig + ' (sim)', 'rel. err'], |
| 68 | + colors: ['#1a73e8', '#e8700a', '#b0b0b0'], |
| 69 | + series: { |
| 70 | + 'rel. err': { axis: 'y2', strokeWidth: 1 } |
| 71 | + }, |
| 72 | + axes: { |
| 73 | + y: { axisLabelWidth: 70 }, |
| 74 | + y2: { |
| 75 | + independentTicks: true, |
| 76 | + axisLabelFormatter: function (v) { |
| 77 | + return (v * 100).toPrecision(3) + '%'; |
| 78 | + }, |
| 79 | + valueFormatter: function (v) { |
| 80 | + return (v * 100).toPrecision(4) + '%'; |
| 81 | + } |
| 82 | + } |
| 83 | + }, |
| 84 | + y2label: 'Relative Error', |
| 85 | + xlabel: 'time', |
| 86 | + legend: 'always', |
| 87 | + showRangeSelector: true, |
| 88 | + highlightCircleSize: 3, |
| 89 | + strokeWidth: 2 |
| 90 | + }); |
| 91 | + }); |
| 92 | +}()); |
| 93 | +</script> |
| 94 | +</body> |
| 95 | +</html> |
0 commit comments