Demonstrates a realtime Angular static axis chart - where the ticks and gridlines are fixed, but the labels change. With SciChart.js High Performance JavaScript Charts you can achieve this simply by setting isStaticAxis property to true on the X axis.
Primary Axis:
drawExample.ts
index.tsx
theme.ts
1import {
2 XyDataSeries,
3 NumericAxis,
4 FastLineRenderableSeries,
5 SciChartSurface,
6 EAutoRange,
7 HorizontalLineAnnotation,
8 NumberRange,
9 EAxisAlignment,
10} from "scichart";
11import { appTheme } from "../../../theme";
12
13export const drawExample = async (rootElement: string | HTMLDivElement) => {
14 const { sciChartSurface, wasmContext } = await SciChartSurface.create(rootElement, {
15 theme: {
16 ...appTheme.SciChartJsTheme,
17 majorGridLineBrush: "#FFFFFF22", // make gridlines more noticeable
18 },
19 });
20
21 // Create X Axis
22 const staticXAxis = new NumericAxis(wasmContext, {
23 labelPrecision: 0,
24 autoRange: EAutoRange.Always,
25 axisAlignment: EAxisAlignment.Top,
26 axisTitle: "Static Axis",
27 isStaticAxis: true, // when true, gridlines and axis labels keep their initial position on visible range change
28 // drawMajorBands: false, // avoids flickering - when values change fast and isStaticAxis is true
29 });
30
31 const xAxis = new NumericAxis(wasmContext, {
32 labelPrecision: 0,
33 autoRange: EAutoRange.Always,
34 axisAlignment: EAxisAlignment.Bottom,
35 axisTitle: "Normal Axis",
36 id: "Normal",
37 isStaticAxis: false, // when true, gridlines and axis labels keep their initial position on visible range change
38 // drawMajorBands: false, // avoids flickering - when values change fast and isStaticAxis is true
39 });
40 staticXAxis.visibleRangeChanged.subscribe((data) => (xAxis.visibleRange = data.visibleRange));
41
42 sciChartSurface.xAxes.add(staticXAxis, xAxis);
43
44 // Create Y Axis
45 const yAxis = new NumericAxis(wasmContext, {
46 visibleRange: new NumberRange(-2, 2),
47 });
48 sciChartSurface.yAxes.add(yAxis);
49
50 // build data series
51 const xValues = [];
52 const yValues = [];
53 const fifoCapacity = 1000;
54 let i = 0;
55 const makeY = (x: number) => Math.sin(x * 0.05) - 0.1 * Math.sin(x * 0.1) - Math.cos(x * 0.005);
56 for (; i < fifoCapacity; i++) {
57 xValues.push(i);
58 yValues.push(makeY(i));
59 }
60
61 // Add a line series with initial data
62 const dataSeries = new XyDataSeries(wasmContext, {
63 xValues,
64 yValues,
65 fifoCapacity,
66 });
67
68 sciChartSurface.renderableSeries.add(
69 new FastLineRenderableSeries(wasmContext, {
70 dataSeries,
71 stroke: appTheme.VividOrange,
72 strokeThickness: 4,
73 })
74 );
75
76 const updateCallback = () => {
77 const xUpdate = [];
78 const yUpdate = [];
79
80 for (let j = 0; j < 2; i++, j++) {
81 xUpdate.push(i);
82 yUpdate.push(makeY(i));
83 }
84 dataSeries.appendRange(xUpdate, yUpdate);
85 };
86
87 setInterval(updateCallback, 10);
88
89 // line annotation at x = 0
90 sciChartSurface.annotations.add(
91 new HorizontalLineAnnotation({
92 stroke: "#FFFFFF44",
93 strokeThickness: 1,
94 y1: 0,
95 })
96 );
97
98 function toggleStaticAxis() {
99 if (staticXAxis.isPrimaryAxis) {
100 xAxis.isPrimaryAxis = true;
101 } else {
102 staticXAxis.isPrimaryAxis = true;
103 }
104 }
105
106 return { sciChartSurface, wasmContext, controls: { toggleStaticAxis } };
107};
108This example demonstrates a real-time chart in an Angular application using SciChart.js. It focuses on configuring a static X axis where the gridlines and ticks remain fixed while the labels update dynamically as new data is streamed. The example provides an interactive toggle to switch between a static and a normal axis configuration.
The chart is initialized by creating a SciChartSurface and setting up two NumericAxis. One axis is designated as static by enabling the isStaticAxis property, ensuring that its gridlines and ticks retain their original positions regardless of the data updates. The synchronization between the axes is achieved by subscribing to the visibleRangeChanged event, a technique detailed in the Axis Ranging - How to Listen to VisibleRange Changes - SciChart. Real-time data updates are managed by appending new data points to the data series at regular intervals, following the practices described in the Adding Realtime Updates | JavaScript Chart Documentation - SciChart guide.
Key features of this implementation include real-time data streaming, advanced axis synchronization, and support for annotations. The static axis minimizes visual flickering during high-frequency updates while maintaining consistent gridlines. Additional customizations, such as the inclusion of a horizontal line annotation, enhance the clarity and usability of the chart. These functionalities highlight the chart’s capability to handle complex, dynamic data efficiently.
For Angular developers, integrating SciChart.js can be streamlined using ScichartAngularComponent from the scichart-angular package, which simplifies the embedding of high-performance charts into Angular applications. The example follows best practices for updating and synchronizing axes, ensuring that performance remains optimal even with realtime data streams.

Demonstrates Multiple X & Y Axis on a Angular Chart using SciChart.js. SciChart supports unlimited left, right, top, bottom X, Y axis with configurable alignment and individual zooming, panning

Demonstrates Secondary Y Axis on a Angular Chart using SciChart.js. SciChart supports unlimited, multiple left, right, top, bottom X, Y axis with configurable alignment and individual zooming, panning

Demonstrates alignment of Axis to create a vertical chart with SciChart.js - JavaScript Charts.

Demonstrates Central Axes on a Angular Chart using SciChart.js. SciChart supports unlimited left, right, top, bottom X, Y axis with configurable layout

Demonstrates Vertically Stacked Axes on a Angular Chart using SciChart.js, allowing data to overlap

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


Demonstrates BaseValue Axes on an Angular Chart using SciChart.js to create non-linear and custom-scaled axes

Demonstrates the option of the transparent Axes customization on a Angular Chart using SciChart.js.

Demonstrates how to use arbitrary text for axis labels, rather than formatted data values, using the new TextLabelProvider

Demonstrates outer, inner, central and stacked axes, and use of axis alignment to create vertical charts