Demonstrates how to zoom and pan with an Overview Chart using SciChart.js, High Performance JavaScript Charts
drawExample.ts
index.tsx
RandomWalkGenerator.ts
theme.ts
1import {
2 EAutoRange,
3 ECoordinateMode,
4 EExecuteOn,
5 EHorizontalAnchorPoint,
6 EllipsePointMarker,
7 EMultiLineAlignment,
8 EVerticalAnchorPoint,
9 EWrapTo,
10 FastLineRenderableSeries,
11 MouseWheelZoomModifier,
12 NativeTextAnnotation,
13 NumberRange,
14 NumericAxis,
15 RubberBandXyZoomModifier,
16 SciChartOverview,
17 SciChartSurface,
18 TextAnnotation,
19 XyDataSeries,
20 XyScatterRenderableSeries,
21 ZoomExtentsModifier,
22 ZoomPanModifier,
23} from "scichart";
24import { appTheme } from "../../../theme";
25import { RandomWalkGenerator } from "../../../ExampleData/RandomWalkGenerator";
26
27export const overviewOptions = {
28 theme: appTheme.SciChartJsTheme,
29};
30
31export const drawExample = async (rootElement: string | HTMLDivElement) => {
32 const { wasmContext, sciChartSurface } = await SciChartSurface.create(rootElement, {
33 theme: appTheme.SciChartJsTheme,
34 });
35
36 // Create and add an XAxis and YAxis
37 sciChartSurface.xAxes.add(new NumericAxis(wasmContext, { visibleRange: new NumberRange(500, 600) }));
38 sciChartSurface.yAxes.add(
39 new NumericAxis(wasmContext, {
40 autoRange: EAutoRange.Always,
41 growBy: new NumberRange(0.1, 0.1),
42 })
43 );
44
45 const POINTS = 1000;
46
47 const data0 = new RandomWalkGenerator().Seed(1337).getRandomWalkSeries(POINTS);
48
49 // Add a line series to the chart
50 sciChartSurface.renderableSeries.add(
51 new FastLineRenderableSeries(wasmContext, {
52 dataSeries: new XyDataSeries(wasmContext, { xValues: data0.xValues, yValues: data0.yValues }),
53 strokeThickness: 3,
54 stroke: appTheme.VividSkyBlue,
55 })
56 );
57
58 const data1 = new RandomWalkGenerator().Seed(42069).getRandomWalkSeries(POINTS);
59
60 // Add a scatter series to the chart
61 sciChartSurface.renderableSeries.add(
62 new XyScatterRenderableSeries(wasmContext, {
63 dataSeries: new XyDataSeries(wasmContext, { xValues: data1.xValues, yValues: data1.yValues }),
64 pointMarker: new EllipsePointMarker(wasmContext, { fill: appTheme.VividPink, strokeThickness: 0 }),
65 strokeThickness: 3,
66 })
67 );
68
69 // Add an annotation with instructions over the chart
70 sciChartSurface.annotations.add(
71 new NativeTextAnnotation({
72 x1: 0.02,
73 y1: 0.02,
74 xCoordinateMode: ECoordinateMode.Relative,
75 yCoordinateMode: ECoordinateMode.Relative,
76 horizontalAnchorPoint: EHorizontalAnchorPoint.Left,
77 verticalAnchorPoint: EVerticalAnchorPoint.Top,
78 fontSize: 18,
79 opacity: 0.55,
80 textColor: appTheme.ForegroundColor,
81 text: "SciChart.js supports an Overview scrollbar. Zoom the main chart or drag the overview to see it update",
82 wrapTo: EWrapTo.ViewRect,
83 multiLineAlignment: EMultiLineAlignment.Left,
84 })
85 );
86
87 // This is the primary approach o. This will automatically bind to the parent surface
88 // displaying its series. Zooming the chart will zoom the overview and vice versa
89 // const overview = await SciChartOverview.create(sciChartSurface, divOverviewId, {
90 // theme: appTheme.SciChartJsTheme,
91 // });
92
93 // Optional: add some zoom pan interaction
94 sciChartSurface.chartModifiers.add(new ZoomPanModifier({ enableZoom: true }));
95 sciChartSurface.chartModifiers.add(
96 new RubberBandXyZoomModifier({ executeCondition: { button: EExecuteOn.MouseRightButton } })
97 );
98 sciChartSurface.chartModifiers.add(new ZoomExtentsModifier());
99 sciChartSurface.chartModifiers.add(new MouseWheelZoomModifier());
100
101 return { sciChartSurface };
102};
103
104export const drawOverview = async (sciChartSurface: SciChartSurface, divOverviewId: string | HTMLDivElement) => {
105 const overview = await SciChartOverview.create(sciChartSurface, divOverviewId, overviewOptions);
106
107 return {sciChartSurface: overview.overviewSciChartSurface};
108};
109This example demonstrates how to integrate SciChart.js into an Angular application to create high-performance, interactive 2D charts with a synchronized SciChartOverview scrollbar. The chart offers advanced zooming and panning capabilities, enabling users to interact with large datasets in real time. For an introductory guide, see Getting Started with SciChart JS.
The chart is initialized by creating a SciChartSurface with a WebAssembly context and configuring numeric axes for dynamic scaling. Two renderable series are added: a FastLineRenderableSeries and an XyScatterRenderableSeries, each leveraging random walk data to simulate dynamic input. Interactive modifiers such as ZoomPanModifier, RubberBandXyZoomModifier, ZoomExtentsModifier, and MouseWheelZoomModifier are incorporated to enable seamless zooming and panning, as detailed in Tutorial 03 - Adding Zooming, Panning Behavior.
The example showcases real-time update capabilities, with the main chart and its overview scrollbar created via SciChartOverview.create() remaining synchronized during user interactions. Additional features include embedded annotations for enhanced user guidance and multiple renderable series for diverse data visualization. The built-in overview chart allows users to maintain a global perspective of chart data, an approach aligned with the practices described in the SciChartOverview documentation.
Integrating SciChart.js within an Angular project requires careful management of component lifecycles and dependency injection to optimize the WebAssembly context. Developers are encouraged to employ Angular lifecycle hooks and modular configuration from the scichart-angular package for maintaining chart performance and scalability.

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 how to Zoom, Scale or Pan individual Axis on a Angular Chart with SciChart.js AxisDragModifiers

Demonstrates how to zoom and pan a realtime Angular Chart while it is updating, with SciChart.js ZoomState API

Demonstrates how to use multiple Zoom and Pan Modifiers on a Angular Chart with SciChart.js

shows how to load data on zoom/pan and how to create an overview chart for this case.

Explore SciChart's Polar Interactivity Modifiers including zooming, panning, and cursor tracking. Try the demo to trial the Polar Chart Behavior Modifiers.

Demonstrates 64-bit precision Date Axis in SciChart.js handling Nanoseconds to Billions of Years

Demonstrates how to build synchronized multi-panel charts with an overview range selector using SciChart.js in Angular