Vertically-Stacked Axis in SciChart.js allows several traces with independent Y-axis to be placed on the same chart, stacking the Y-Axis and enabling an ECG/EEG-style trace. Great for neurological apps, medical apps, earthquake monitoring.
drawExample.ts
index.html
vanilla.ts
theme.ts
1import { appTheme } from "../../../theme";
2
3import { EWrapTo, NativeTextAnnotation, TSciChart } from "scichart";
4
5import {
6 EAxisAlignment,
7 ECoordinateMode,
8 EExecuteOn,
9 EHorizontalAnchorPoint,
10 EXyDirection,
11 FastLineRenderableSeries,
12 LeftAlignedOuterVerticallyStackedAxisLayoutStrategy,
13 MouseWheelZoomModifier,
14 NumberRange,
15 NumericAxis,
16 RubberBandXyZoomModifier,
17 SciChartSurface,
18 TextAnnotation,
19 XAxisDragModifier,
20 XyDataSeries,
21 YAxisDragModifier,
22 ZoomExtentsModifier,
23} from "scichart";
24
25export const drawExample = async (rootElement: string | HTMLDivElement) => {
26 const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
27 theme: appTheme.SciChartJsTheme,
28 });
29
30 sciChartSurface.layoutManager.leftOuterAxesLayoutStrategy =
31 new LeftAlignedOuterVerticallyStackedAxisLayoutStrategy();
32
33 sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { axisTitle: "X Axis" }));
34
35 // Add title annotation
36 sciChartSurface.annotations.add(
37 new NativeTextAnnotation({
38 text: "Vertically Stacked Axis: Custom layout of axis to allow traces to overlap. Useful for ECG charts",
39 fontSize: 16,
40 textColor: appTheme.ForegroundColor,
41 x1: 0.5,
42 y1: 0,
43 opacity: 0.77,
44 horizontalAnchorPoint: EHorizontalAnchorPoint.Center,
45 xCoordinateMode: ECoordinateMode.Relative,
46 yCoordinateMode: ECoordinateMode.Relative,
47 wrapTo: EWrapTo.ViewRect,
48 })
49 );
50
51 const seriesCount: number = 10;
52 for (let i = 0; i < seriesCount; i++) {
53 const range = 10 / seriesCount;
54 const yAxis = new NumericAxis(wasmContext, {
55 id: "Y" + i,
56 visibleRange: new NumberRange(-range, range),
57 axisAlignment: EAxisAlignment.Left,
58 zoomExtentsToInitialRange: true,
59 maxAutoTicks: 5,
60 drawMinorGridLines: false,
61 axisBorder: { borderTop: 5, borderBottom: 5 },
62 axisTitle: `Y ${i}`,
63 });
64 sciChartSurface.yAxes.add(yAxis);
65
66 const lineSeries = new FastLineRenderableSeries(wasmContext, {
67 yAxisId: yAxis.id,
68 stroke: "auto",
69 strokeThickness: 2,
70 });
71 lineSeries.dataSeries = getRandomSinewave(wasmContext, 0, Math.random() * 3, Math.random() * 50, 10000, 10);
72 sciChartSurface.renderableSeries.add(lineSeries);
73 }
74
75 // Optional: Add some interactivity modifiers to enable zooming and panning
76 sciChartSurface.chartModifiers.add(
77 new YAxisDragModifier(),
78 new XAxisDragModifier(),
79 new RubberBandXyZoomModifier({
80 xyDirection: EXyDirection.XDirection,
81 executeCondition: { button: EExecuteOn.MouseRightButton },
82 }),
83 new MouseWheelZoomModifier({ xyDirection: EXyDirection.YDirection }),
84 new ZoomExtentsModifier()
85 );
86
87 return { sciChartSurface, wasmContext };
88};
89
90function getRandomSinewave(
91 wasmContext: TSciChart,
92 pad: number,
93 amplitude: number,
94 phase: number,
95 pointCount: number,
96 freq: number
97) {
98 const dataSeries = new XyDataSeries(wasmContext);
99
100 for (let i = 0; i < pad; i++) {
101 const time = (10 * i) / pointCount;
102 dataSeries.append(time, 0);
103 }
104
105 for (let i = pad, j = 0; i < pointCount; i++, j++) {
106 amplitude = Math.min(3, Math.max(0.1, amplitude * (1 + (Math.random() - 0.5) / 10)));
107 freq = Math.min(50, Math.max(0.1, freq * (1 + (Math.random() - 0.5) / 50)));
108
109 const time = (10 * i) / pointCount;
110 const wn = (2 * Math.PI) / (pointCount / freq);
111
112 const d = amplitude * Math.sin(j * wn + phase);
113 dataSeries.append(time, d);
114 }
115
116 return dataSeries;
117}
118This example demonstrates how to create a high-performance chart using SciChart.js with JavaScript. It showcases a custom setup where multiple independent Y-axes are vertically stacked to allow overlapping data traces similar to ECG/EEG visualizations. The chart is initialized asynchronously and leverages native JavaScript for a straightforward integration in web applications.
The chart is created by calling SciChartSurface.create() asynchronously, ensuring that the WebAssembly context is fully loaded before rendering. A custom axis layout is implemented using the LeftAlignedOuterVerticallyStackedAxisLayoutStrategy as described in the Vertically Stacked Axis Layout documentation. Each data series is associated with its own Y-axis, configured with a specific visible range and border styling. Data for each series is generated dynamically using a sine wave algorithm via the XyDataSeries, which aligns with best practices as shown in the Tutorial on Adding Series and Data. In addition, multiple interactive modifiers such as YAxisDragModifier, XAxisDragModifier, RubberBandXyZoomModifier, and MouseWheelZoomModifier are added to enhance user interactivity.
The example emphasizes several advanced features:
FastLineRenderableSeries ensures smooth rendering of large data sets. More details can be found in the FastLineRenderableSeries API Documentation.NativeTextAnnotation to offer contextual information directly on the chart.This implementation is a prime example of integrating SciChart.js with JavaScript. Developers can follow the asynchronous initialization pattern and proper lifecycle management evidenced by the cleanup function which calls sciChartSurface.delete(). For more information on JavaScript integration, refer to the Getting Started with SciChart JS guide. Additionally, proper memory management and disposal practices are covered in the Deleting DataSeries Memory documentation. By adopting these techniques, developers can ensure optimal performance and maintainability in their web applications.

In this example we are simulating four channels of data showing that SciChart.js can be used to draw real-time ECG/EKG charts and graphs to monitor heart reate, body temperature, blood pressure, pulse rate, SPO2 blood oxygen, volumetric flow and more.

Demonstrates Logarithmic Axis on a JavaScript Chart using SciChart.js. SciChart supports logarithmic axis with scientific or engineering notation and positive and negative values

Demonstrating the capability of SciChart.js to create JavaScript 3D Point Cloud charts and visualize LiDAR data from the UK Defra Survey.

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

Demonstrating the capability of SciChart.js to create a JavaScript Audio Analyzer Bars and visualize the Fourier-Transform of an audio waveform in realtime.

Demonstrates how to create a Waterfall chart in SciChart.js, showing chromotragraphy data with interactive selection of points.

See the JavaScript Phasor Diagram example to combine a Cartesian surface with a Polar subsurface. Get seamless JS integration with SciChart. View demo now.

Create JavaScript Correlation Plot with high performance SciChart.js. Easily render pre-defined point types. Supports custom shapes. Get your free trial now.
JavaScript **Semiconductors Dashboard** using SciChart.js, by leveraging the **FastRectangleRenderableSeries**, and its `customTextureOptions` property to have a custom tiling texture fill.

JavaScript **Wafer Analysis Chart** using SciChart.js, by leveraging the **FastRectangleRenderableSeries**, and crossfilter to enable live filtering.