Demonstrates real-time oscilloscope style effects with SciChart.js, High Performance JavaScript Charts
drawExample.ts
ExampleDataProvider.ts
angular.ts
theme.ts
1import {
2 CentralAxesLayoutManager,
3 EAxisAlignment,
4 EInnerAxisPlacementCoordinateMode,
5 FastLineRenderableSeries,
6 GlowEffect,
7 ICentralAxesLayoutManagerOptions,
8 NumberRange,
9 NumericAxis,
10 SciChartSurface,
11 XyDataSeries,
12} from "scichart";
13import { ExampleDataProvider } from "../../../ExampleData/ExampleDataProvider";
14import { appTheme } from "../../../theme";
15// import { PerformanceMeasurementModifier } from "scichart-addons/PerformanceMeasurementModifier";
16
17const AMPLITUDE = 200;
18
19export const drawExample = async (rootElement: string | HTMLDivElement) => {
20 const { wasmContext, sciChartSurface } = await SciChartSurface.create(rootElement, {
21 theme: appTheme.SciChartJsTheme,
22 });
23
24 // Optional parameters to control exact placement of the axis
25 // Below: These are defaults, but we specify them for completeness of the example
26 // Relative coordinate mode and 0.5 means 'place half way'
27 const options: ICentralAxesLayoutManagerOptions = {
28 horizontalAxisPositionCoordinateMode: EInnerAxisPlacementCoordinateMode.Relative,
29 verticalAxisPositionCoordinateMode: EInnerAxisPlacementCoordinateMode.Relative,
30 horizontalAxisPosition: 0.5,
31 verticalAxisPosition: 0.5,
32 };
33
34 // Configure x,y axis with central layout - oscilloscope style
35 sciChartSurface.xAxes.add(
36 new NumericAxis(wasmContext, {
37 visibleRange: new NumberRange(0, 900),
38 isInnerAxis: true,
39 axisAlignment: EAxisAlignment.Top,
40 axisBorder: {
41 borderTop: 1,
42 },
43 })
44 );
45
46 sciChartSurface.yAxes.add(
47 new NumericAxis(wasmContext, {
48 visibleRange: new NumberRange(-300, 300),
49 isInnerAxis: true,
50 axisAlignment: EAxisAlignment.Left,
51 axisBorder: {
52 borderLeft: 1,
53 },
54 })
55 );
56
57 // Control the placement of the axis by specifying CentralAxesLayoutManager
58 // and isInnerAxis property
59 sciChartSurface.layoutManager = new CentralAxesLayoutManager(options);
60
61 // sciChartSurface.chartModifiers.add(new PerformanceMeasurementModifier({ verbose: true }));
62
63 const addSeries = (stroke: string, opacity: number) => {
64 const amplitude = Math.random() * AMPLITUDE;
65 const effect = new GlowEffect(wasmContext, {
66 range: 0,
67 intensity: 0.5,
68 });
69 const { xValues, yValues } = ExampleDataProvider.getNoisySinewave(500, 900, 7, amplitude, 30);
70 const lineSeries = new FastLineRenderableSeries(wasmContext, {
71 dataSeries: new XyDataSeries(wasmContext, { xValues, yValues }),
72 stroke,
73 effect,
74 strokeThickness: 3,
75 opacity
76 });
77 sciChartSurface.renderableSeries.add(lineSeries);
78 return lineSeries;
79 };
80
81 const seriesColor = appTheme.VividTeal;
82 const series1 = addSeries(seriesColor, 1);
83 const series2 = addSeries(seriesColor, 0.9);
84 const series3 = addSeries(seriesColor, 0.8);
85 const series4 = addSeries(seriesColor, 0.7);
86 const series5 = addSeries(seriesColor, 0.6);
87 const series6 = addSeries(seriesColor, 0.5);
88 const series7 = addSeries(seriesColor, 0.4);
89 const series8 = addSeries(seriesColor, 0.3);
90 const series9 = addSeries(seriesColor, 0.2);
91 const series10 = addSeries(seriesColor, 0.1);
92
93 let timerId: NodeJS.Timeout;
94
95 const reassignRenderableSeries = () => {
96 const oldSeries = series10.dataSeries;
97 series10.dataSeries = series9.dataSeries;
98 series9.dataSeries = series8.dataSeries;
99 series8.dataSeries = series7.dataSeries;
100 series7.dataSeries = series6.dataSeries;
101 series6.dataSeries = series5.dataSeries;
102 series5.dataSeries = series4.dataSeries;
103 series4.dataSeries = series3.dataSeries;
104 series3.dataSeries = series2.dataSeries;
105 series2.dataSeries = series1.dataSeries;
106
107 const amplitude = Math.random() * AMPLITUDE;
108 const dataSeries = new XyDataSeries(wasmContext);
109 ExampleDataProvider.fillNoisySinewave(500, 900, 7, amplitude, 30, dataSeries);
110 series1.dataSeries = dataSeries;
111 // To prevent memory leak we should delete
112 oldSeries.delete();
113
114 timerId = setTimeout(reassignRenderableSeries, 20);
115 };
116
117 const stopUpdate = () => {
118 clearTimeout(timerId);
119 timerId = undefined;
120 };
121
122 // Buttons for chart
123 const startUpdate = () => {
124 if (timerId) {
125 stopUpdate();
126 }
127 reassignRenderableSeries();
128 };
129
130 return { wasmContext, sciChartSurface, controls: { startUpdate, stopUpdate } };
131};
132This example demonstrates how to integrate SciChart.js into an Angular application to achieve high-performance, real-time data visualizations with advanced ghosted trace effects. The implementation showcases the dynamic updating of multiple line series while maintaining visual historical context with fading traces.
The chart is initialized within an Angular standalone component using the ScichartAngularComponent within the scichart-angular library. The core chart is set up in a function that creates axes with a central layout using SciChart.js’s Central Axis Layout and applies a GlowEffect to each series. Real-time updates are simulated by reassigning data series between multiple FastLineRenderableSeries, ensuring older traces gradually fade, which is a key aspect of ghosted trace effects. These updates are managed through a timer-based mechanism that ensures smooth transitions and efficient memory management by deleting unused data series. For detailed guidance on setting up real-time chart updates, refer to the Adding Realtime Updates | JavaScript Chart Documentation.
XyDataSeries, creating a visually engaging oscilloscope style effect.CentralAxesLayoutManager that repositions the axes in the center of the chart to create an oscilloscope-like view, which is configurable via JSON-like structure and block options.This Angular example follows best practices by leveraging Angular’s component lifecycle and dependency injection for managing the SciChart.js instance. Developers can learn more about the underlying mechanisms of Angular dependency injection in the Angular Dependency Injection Guide. In addition, the efficient handling of real-time updates and performance optimization, as detailed in the Performance Tips & Tricks | JavaScript Chart Documentation, ensures that the chart remains responsive even with high data throughput. The component structure separates the chart logic from the UI controls, allowing for seamless integration with Angular’s change detection mechanism and ensuring modular code that is easier to maintain.

This demo showcases the incredible realtime performance of our Angular charts by updating the series with millions of data-points!

This demo showcases the incredible performance of our Angular Chart by loading 500 series with 500 points (250k points) instantly!

This demo showcases the incredible performance of our JavaScript Chart by loading a million points instantly.

See the frequency of recordings with the Angular audio spectrum analyzer example from SciChart. This real-time audio visualizer demo uses a Fourier Transform.

Demonstrates how to create Oil and Gas Dashboard

This demo showcases the incredible realtime performance of our JavaScript charts by updating the series with millions of data-points!

This dashboard demo showcases the incredible realtime performance of our Angular charts by updating the series with millions of data-points!

This demo showcases the incredible realtime performance of our Angular charts by updating the series with millions of data-points!

Demonstrates a custom modifier which can convert from single chart to grid layout and back.

Demonstrates how to repurpose a Candlestick Series into dragabble, labled, event markers

Population Pyramid of Europe and Africa

Demonstrates how to use the SVG render layer in SciChart.js to maintain smooth cursor interaction on heavy charts with millions of points.