()
| 142 | }; |
| 143 | |
| 144 | async function main(): Promise<void> { |
| 145 | const container = document.getElementById('chart'); |
| 146 | if (!(container instanceof HTMLElement)) { |
| 147 | throw new Error('Chart container not found'); |
| 148 | } |
| 149 | |
| 150 | const header = document.querySelector('header'); |
| 151 | const modeToggle = createModeToggle(); |
| 152 | if (header) header.appendChild(modeToggle.host); |
| 153 | |
| 154 | const data = createTimeSeries(900); |
| 155 | const { maxIndex, maxY, minIndex, minY } = findExtrema(data); |
| 156 | |
| 157 | const maxP = data[maxIndex]!; |
| 158 | const maxX = isTuplePoint(maxP) ? maxP[0] : maxP.x; |
| 159 | |
| 160 | const minP = data[minIndex]!; |
| 161 | const minX = isTuplePoint(minP) ? minP[0] : minP.x; |
| 162 | |
| 163 | const vLineIndex = Math.floor(data.length * 0.6); |
| 164 | const vLinePoint = data[vLineIndex]!; |
| 165 | const vLineX = isTuplePoint(vLinePoint) ? vLinePoint[0] : vLinePoint.x; |
| 166 | |
| 167 | const referenceY = Math.round((maxY * 0.35 + minY * 0.65) * 1000) / 1000; |
| 168 | |
| 169 | const options: ChartGPUOptions = { |
| 170 | grid: { left: 70, right: 24, top: 24, bottom: 44 }, |
| 171 | xAxis: { type: 'time', name: 'Time (ms)' }, |
| 172 | yAxis: { type: 'value', name: 'Value' }, |
| 173 | tooltip: { trigger: 'axis' }, |
| 174 | dataZoom: [{ type: 'inside' }], |
| 175 | palette: ['#4a9eff'], |
| 176 | animation: false, |
| 177 | series: [ |
| 178 | { |
| 179 | type: 'line', |
| 180 | name: 'synthetic', |
| 181 | data, |
| 182 | color: '#4a9eff', |
| 183 | lineStyle: { width: 2, opacity: 1 }, |
| 184 | }, |
| 185 | ], |
| 186 | annotations: [ |
| 187 | // Horizontal reference line (type: 'lineY') with dashed style + template label + decimals. |
| 188 | { |
| 189 | id: 'ref-y', |
| 190 | type: 'lineY', |
| 191 | y: referenceY, |
| 192 | layer: 'belowSeries', |
| 193 | style: { color: '#ffd166', lineWidth: 2, lineDash: [8, 6], opacity: 0.95 }, |
| 194 | label: { |
| 195 | template: 'ref y={y}', |
| 196 | decimals: 3, |
| 197 | offset: [8, -8], |
| 198 | anchor: 'start', |
| 199 | background: { color: '#000000', opacity: 0.55, padding: [2, 6, 2, 6], borderRadius: 6 }, |
| 200 | }, |
| 201 | }, |
no test coverage detected