Realtime Ghosted Traces

Demonstrates real-time oscilloscope style effects with SciChart.js, High Performance JavaScript Charts

# DataPoints: 0
FPS: 00
# Series: 0 
drawExample.tsread-only
// Loading ... 

Real-Time Ghosted Traces (JavaScript)

Overview

This example demonstrates how to create a realtime oscilloscope‐style chart with ghosted traces using SciChart.js in JavaScript. The chart is built by manually configuring chart components such as axes, renderable series, and custom layout managers without relying on higher-level frameworks. The purpose of the example is to simulate continuous data updates, creating a layered “ghosting” effect by stacking multiple traces with decreasing opacity.

Technical Implementation

The core of the implementation is found in the drawExample.js file. A new chart is created via the call to SciChartSurface.create(), following the guidelines in the Getting Started with SciChart JS documentation and the Tutorial 01 - Including SciChart.js in an HTML Page using CDN documentation. Two NumericAxis objects are added, one for the x-axis and one for the y-axis, and a CentralAxesLayoutManager is used to position the axes centrally as detailed in the Central Axis Layout documentation. The example constructs ten instances of FastLineRenderableSeries with a glow effect created via GlowEffect and links them to noisy sinewave data generated using a ExampleDataProvider. To simulate realtime data, a function continuously reassigns the data series from one renderable series to the next and creates a new data series for the first trace. The process uses a recursive setTimeout (every 20ms) to update the data, a pattern that is explained in the DataSeries Realtime Updates documentation. To manage memory, the example ensures that every old data series is deleted once it has been replaced, following best practices available in the Memory Best Practices guide.

Features and Capabilities

The example showcases several advanced features of SciChart.js including:

  • Realtime Data Updates: The chart avoids redrawing by reassigning data series across layers, as demonstrated in the implementation of the realtime updating loop.
  • Ghosted Traces Effect: Multiple FastLineRenderableSeries are rendered with the same color but with decreasing opacity to produce a fading ghost effect. Additional visual polish is achieved by applying a Glow Effect to each series.
  • Data Series Management: The use of XyDataSeries to generate and update the noisy sinewave data is central to the technique, as referenced in the XyDataSeries API documentation.

Integration and Best Practices

Although this example is implemented in JavaScript, its techniques can be adapted for integration within other frameworks. The core logic of realtime updates, memory management, and visual customization is separated from any framework-specific code. This approach allows developers to integrate similar implementations into Angular, React or other environments by simply referencing the core drawing function. Additionally, the performance implications of using recursive setTimeout for realtime updates are discussed in various performance optimization guides, which can be helpful when adapting this example for high-frequency data updates.