Demonstrates a custom modifier which can convert from single chart to grid layout and back using SciChart.js, High Performance JavaScript Charts
drawExample.ts
index.tsx
RandomWalkGenerator.ts
theme.ts
GridLayoutModifier.ts
1import {
2 SciChartSurface,
3 NumericAxis,
4 EAxisAlignment,
5 NumberRange,
6 FastLineRenderableSeries,
7 XyDataSeries,
8 AUTO_COLOR,
9 SweepAnimation,
10 ZoomExtentsModifier,
11 MouseWheelZoomModifier,
12 ZoomPanModifier,
13 RolloverModifier,
14} from "scichart";
15import { RandomWalkGenerator } from "../../../ExampleData/RandomWalkGenerator";
16import { GridLayoutModifier } from "./GridLayoutModifier";
17
18export const drawExample = async (rootElement: string | HTMLDivElement) => {
19 // Create a SciChartSurface
20 const { wasmContext, sciChartSurface } = await SciChartSurface.create(rootElement);
21
22 // Create an XAxis and YAxis
23 sciChartSurface.xAxes.add(new NumericAxis(wasmContext));
24 sciChartSurface.yAxes.add(
25 new NumericAxis(wasmContext, {
26 axisAlignment: EAxisAlignment.Left,
27 growBy: new NumberRange(0.05, 0.05),
28 })
29 );
30
31 const POINTS = 1000;
32 for (let i = 0; i < 10; i++) {
33 // Create arrays of x, y values (just arrays of numbers)
34 const { xValues, yValues } = new RandomWalkGenerator().getRandomWalkSeries(POINTS);
35
36 // Create a Series and add to the chart
37 sciChartSurface.renderableSeries.add(
38 new FastLineRenderableSeries(wasmContext, {
39 dataSeries: new XyDataSeries(wasmContext, { xValues, yValues, dataSeriesName: `Series ${i + 1}` }),
40 stroke: AUTO_COLOR,
41 strokeThickness: 3,
42 animation: new SweepAnimation({ duration: 500, fadeEffect: true }),
43 })
44 );
45 }
46
47 // Optional: Add some interactivity to the chart
48 sciChartSurface.chartModifiers.add(
49 new ZoomExtentsModifier({ modifierGroup: "chart" }),
50 new MouseWheelZoomModifier({ modifierGroup: "chart" }),
51 new ZoomPanModifier({ modifierGroup: "chart" }),
52 new RolloverModifier({ modifierGroup: "chart" })
53 );
54
55 const glm = new GridLayoutModifier();
56 sciChartSurface.chartModifiers.add(glm);
57
58 sciChartSurface.zoomExtents();
59
60 const setIsGridLayoutMode = (value: boolean) => {
61 glm.isGrid = value;
62 };
63
64 return { wasmContext, sciChartSurface, setIsGridLayoutMode };
65};
66This example demonstrates a dynamic chart layout that converts a single chart into a grid layout and back. It leverages a custom chart modifier, the GridLayoutModifier, to animate transitions and reconfigure sub-charts for rich and interactive visualizations using SciChart.js in an Angular context.
The implementation uses the GridLayoutModifier to split the parent chart into multiple sub-charts based on the number of data series. Calculations determine the appropriate number of rows and columns, and each sub-chart is configured dynamically using a JSON representation of the chart (via sciChartSurface.toJSON(true)). This approach facilitates integration into Angular services for state management and dependency injection. Smooth animated transitions are implemented using GenericAnimation, while customization of the modifier follows the guidelines outlined in the Custom Chart Modifier API.
The example provides real-time dynamic layout switching between a single chart and a grid layout where each data series is displayed in its own animated sub-chart. The animations interpolate properties such as position, opacity, and borders to create a fluid user experience. Performance is optimized by disabling unnecessary grid lines and reusing data series across sub-charts, aligning with techniques described in the Performance Tips & Tricks documentation.
For Angular applications, encapsulating chart initialization and state management within Angular components and services is essential. This approach leverages Angular's dependency injection system to share the SciChart surface state efficiently. Additionally, design patterns demonstrated in the Worked Example: Re-usable Chart Groups with SubCharts documentation can be adapted to Angular to ensure responsive chart configurations and optimal rendering performance. For further insights into implementing animated transitions in an Angular context, developers are encouraged to review the techniques in the Angular Style Animation demo.

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.

This demo showcases the realtime performance of our Angular Chart by animating several series with thousands of data-points at 60 FPS

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 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.