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 labelStyle: {
41 color: appTheme.PaleSkyBlue,
42 },
43 axisBorder: {
44 borderTop: 1,
45 color: appTheme.VividSkyBlue,
46 },
47 })
48 );
49
50 sciChartSurface.yAxes.add(
51 new NumericAxis(wasmContext, {
52 visibleRange: new NumberRange(-300, 300),
53 isInnerAxis: true,
54 axisAlignment: EAxisAlignment.Left,
55 labelStyle: {
56 color: appTheme.PaleSkyBlue,
57 },
58 axisBorder: {
59 borderLeft: 1,
60 color: appTheme.VividSkyBlue,
61 },
62 })
63 );
64
65 // Control the placement of the axis by specifying CentralAxesLayoutManager
66 // and isInnerAxis property
67 sciChartSurface.layoutManager = new CentralAxesLayoutManager(options);
68
69 // sciChartSurface.chartModifiers.add(new PerformanceMeasurementModifier({ verbose: true }));
70
71 const addSeries = (stroke: string, opacity: number) => {
72 const amplitude = Math.random() * AMPLITUDE;
73 const effect = new GlowEffect(wasmContext, {
74 range: 0,
75 intensity: 0.5,
76 });
77 const lineSeries = new FastLineRenderableSeries(wasmContext, { stroke, effect });
78 lineSeries.strokeThickness = 3;
79 lineSeries.opacity = opacity;
80 sciChartSurface.renderableSeries.add(lineSeries);
81 const { xValues, yValues } = ExampleDataProvider.getNoisySinewave(500, 900, 7, amplitude, 30);
82 lineSeries.dataSeries = new XyDataSeries(wasmContext, { xValues, yValues });
83 return lineSeries;
84 };
85
86 const seriesColor = appTheme.VividTeal;
87 const series1 = addSeries(seriesColor, 1);
88 const series2 = addSeries(seriesColor, 0.9);
89 const series3 = addSeries(seriesColor, 0.8);
90 const series4 = addSeries(seriesColor, 0.7);
91 const series5 = addSeries(seriesColor, 0.6);
92 const series6 = addSeries(seriesColor, 0.5);
93 const series7 = addSeries(seriesColor, 0.4);
94 const series8 = addSeries(seriesColor, 0.3);
95 const series9 = addSeries(seriesColor, 0.2);
96 const series10 = addSeries(seriesColor, 0.1);
97
98 let timerId: NodeJS.Timeout;
99
100 const reassignRenderableSeries = () => {
101 const oldSeries = series10.dataSeries;
102 series10.dataSeries = series9.dataSeries;
103 series9.dataSeries = series8.dataSeries;
104 series8.dataSeries = series7.dataSeries;
105 series7.dataSeries = series6.dataSeries;
106 series6.dataSeries = series5.dataSeries;
107 series5.dataSeries = series4.dataSeries;
108 series4.dataSeries = series3.dataSeries;
109 series3.dataSeries = series2.dataSeries;
110 series2.dataSeries = series1.dataSeries;
111
112 const amplitude = Math.random() * AMPLITUDE;
113 const dataSeries = new XyDataSeries(wasmContext);
114 ExampleDataProvider.fillNoisySinewave(500, 900, 7, amplitude, 30, dataSeries);
115 series1.dataSeries = dataSeries;
116 // To prevent memory leak we should delete
117 oldSeries.delete();
118
119 timerId = setTimeout(reassignRenderableSeries, 20);
120 };
121
122 const stopUpdate = () => {
123 clearTimeout(timerId);
124 timerId = undefined;
125 };
126
127 // Buttons for chart
128 const startUpdate = () => {
129 if (timerId) {
130 stopUpdate();
131 }
132 reassignRenderableSeries();
133 };
134
135 return { wasmContext, sciChartSurface, controls: { startUpdate, stopUpdate } };
136};
137This 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.