()
| 612 | } |
| 613 | |
| 614 | async function handleStartStreaming(): Promise<void> { |
| 615 | if (state.streaming) { |
| 616 | showStatus('Already streaming', 'warning'); |
| 617 | return; |
| 618 | } |
| 619 | |
| 620 | const streamRate = parseInt((document.getElementById('streamRate') as HTMLInputElement).value); |
| 621 | const streamDuration = parseInt((document.getElementById('streamDuration') as HTMLInputElement).value); |
| 622 | const dataType = (document.getElementById('dataType') as HTMLSelectElement).value as DataType; |
| 623 | const renderMode = (document.getElementById('renderMode') as HTMLSelectElement).value as RenderMode; |
| 624 | |
| 625 | if (!state.chart) { |
| 626 | showStatus('Generate data first', 'warning'); |
| 627 | return; |
| 628 | } |
| 629 | |
| 630 | state.streaming = true; |
| 631 | let frameCount = 0; |
| 632 | let nextX = state.totalPointsGenerated; |
| 633 | |
| 634 | const streamFrame = (): void => { |
| 635 | if (!state.streaming || !state.chart || frameCount >= streamDuration) { |
| 636 | stopStreaming(); |
| 637 | showStatus('Streaming complete', 'success'); |
| 638 | return; |
| 639 | } |
| 640 | |
| 641 | frameCount++; |
| 642 | |
| 643 | // Generate batch |
| 644 | const batch = generateChunk(nextX, streamRate, dataType); |
| 645 | nextX += streamRate; |
| 646 | |
| 647 | // Append to chart |
| 648 | state.chart.appendData(0, batch); |
| 649 | |
| 650 | state.totalPointsGenerated += streamRate; |
| 651 | |
| 652 | // Update live point count display (throttled) |
| 653 | updateTotalPointsDisplay(state.totalPointsGenerated); |
| 654 | |
| 655 | showStatus( |
| 656 | `Streaming... ${frameCount}/${streamDuration} frames (${formatNumber(state.totalPointsGenerated)} points total)`, |
| 657 | 'warning' |
| 658 | ); |
| 659 | }; |
| 660 | |
| 661 | // Start streaming at ~60fps |
| 662 | state.streamingIntervalId = window.setInterval(streamFrame, 16); |
| 663 | showStatus('Streaming started', 'success'); |
| 664 | } |
| 665 | |
| 666 | function stopStreaming(): void { |
| 667 | state.streaming = false; |
nothing calls this directly
no test coverage detected