Learn how to create a realtime updating Angular 3D Surface Mesh Chart using SciChart.js, and our High Performance JavaScript 3D Chart Library
drawExample.ts
angular.ts
theme.ts
1import {
2 CameraController,
3 EDrawMeshAs,
4 GradientColorPalette,
5 MouseWheelZoomModifier3D,
6 NumberRange,
7 NumericAxis3D,
8 OrbitModifier3D,
9 ResetCamera3DModifier,
10 SciChart3DSurface,
11 SurfaceMeshRenderableSeries3D,
12 UniformGridDataSeries3D,
13 Vector3,
14 zeroArray2D,
15} from "scichart";
16import { appTheme } from "../../../theme";
17
18// SCICHART CODE
19export const drawExample = async (rootElement: string | HTMLDivElement) => {
20 // Create a SciChart3DSurface
21 const { sciChart3DSurface, wasmContext } = await SciChart3DSurface.create(rootElement, {
22 theme: appTheme.SciChartJsTheme,
23 });
24
25 // Create and position the camera in the 3D world
26 sciChart3DSurface.camera = new CameraController(wasmContext, {
27 position: new Vector3(-150, 200, 150),
28 target: new Vector3(0, 50, 0),
29 });
30 // Set the worlddimensions, which defines the Axis cube size
31 sciChart3DSurface.worldDimensions = new Vector3(200, 100, 200);
32
33 // Add an X,Y and Z Axis
34 sciChart3DSurface.xAxis = new NumericAxis3D(wasmContext, { axisTitle: "X Axis" });
35 sciChart3DSurface.yAxis = new NumericAxis3D(wasmContext, {
36 axisTitle: "Y Axis",
37 visibleRange: new NumberRange(-0.3, 0.3),
38 });
39 sciChart3DSurface.zAxis = new NumericAxis3D(wasmContext, { axisTitle: "Z Axis" });
40
41 // Create a 2D array using the helper function zeroArray2D
42 // and fill this with data
43 const zSize = 50;
44 const xSize = 50;
45 const heightmapArray = zeroArray2D([zSize, xSize]);
46
47 // Create a UniformGridDataSeries3D
48 const dataSeries = new UniformGridDataSeries3D(wasmContext, {
49 yValues: heightmapArray,
50 xStep: 1,
51 zStep: 1,
52 dataSeriesName: "Uniform Surface Mesh",
53 });
54
55 const setData = (i: number) => {
56 const f = i / 10;
57 for (let z = 0; z < zSize; z++) {
58 let zVal = z - zSize / 2;
59 for (let x = 0; x < xSize; x++) {
60 let xVal = x - xSize / 2;
61 const y = (Math.cos(xVal * 0.2 + f) + Math.cos(zVal * 0.2 + f)) / 5;
62 heightmapArray[z][x] = y;
63 }
64 }
65 dataSeries.setYValues(heightmapArray);
66 };
67
68 // Create the color map
69 const colorMap = new GradientColorPalette(wasmContext, {
70 gradientStops: [
71 { offset: 1, color: appTheme.VividPink },
72 { offset: 0.9, color: appTheme.VividOrange },
73 { offset: 0.7, color: appTheme.MutedRed },
74 { offset: 0.5, color: appTheme.VividGreen },
75 { offset: 0.3, color: appTheme.VividSkyBlue },
76 { offset: 0.15, color: appTheme.Indigo },
77 { offset: 0, color: appTheme.DarkIndigo },
78 ],
79 });
80
81 // Finally, create a SurfaceMeshRenderableSeries3D and add to the chart
82 const series = new SurfaceMeshRenderableSeries3D(wasmContext, {
83 dataSeries,
84 minimum: -0.3,
85 maximum: 0.5,
86 opacity: 0.9,
87 cellHardnessFactor: 1.0,
88 shininess: 0,
89 lightingFactor: 0.0,
90 highlight: 1.0,
91 stroke: appTheme.VividBlue,
92 strokeThickness: 2.0,
93 contourStroke: appTheme.VividBlue,
94 contourInterval: 2,
95 contourOffset: 0,
96 contourStrokeThickness: 2,
97 drawSkirt: false,
98 drawMeshAs: EDrawMeshAs.SOLID_WITH_CONTOURS,
99 meshColorPalette: colorMap,
100 isVisible: true,
101 });
102
103 sciChart3DSurface.renderableSeries.add(series);
104
105 // Optional: Add some interactivity modifiers
106 sciChart3DSurface.chartModifiers.add(new MouseWheelZoomModifier3D());
107 sciChart3DSurface.chartModifiers.add(new OrbitModifier3D());
108 sciChart3DSurface.chartModifiers.add(new ResetCamera3DModifier());
109
110 let frame = 0;
111 let timer: NodeJS.Timeout;
112 const updateFunc = () => {
113 setData(frame);
114 frame++;
115 };
116 updateFunc();
117 const startUpdate = () => {
118 frame = 0;
119 timer = setInterval(updateFunc, 20);
120 };
121 const stopUpdate = () => {
122 clearInterval(timer);
123 };
124
125 return { sciChartSurface: sciChart3DSurface, wasmContext, controls: { startUpdate, stopUpdate } };
126};
127This example demonstrates a realtime updating 3D surface mesh chart implemented in an Angular application using SciChart.js. The chart renders a dynamic 3D surface mesh where the data is continuously updated using an interval-based mechanism. The example showcases how to integrate SciChart.js into Angular as a standalone component, leveraging Angular best practices for initialization, configuration, and cleanup.
The core logic is encapsulated in a function that creates a SciChart 3D surface, configures a camera using the CameraController, and sets up three numeric axes. Data for the surface mesh is generated using a 2D array fed into a UniformGridDataSeries3D. The realtime updates are implemented with a simple setInterval loop that periodically recalculates the surface values. This implementation follows the guidelines from the Adding Realtime Updates documentation for efficient dynamic updates. The code does not use a builder API or hooks, but instead relies on direct imperative calls within the Angular component.
The example features realtime data streaming where the mesh surface dynamically oscillates based on a trigonometric function. Advanced customization is achieved using a GradientColorPalette to provide a visually appealing color map that enhances the mesh visualization. Interactive functionalities such as mouse wheel zoom, orbit control, and camera reset are added through modifiers like MouseWheelZoomModifier3D, OrbitModifier3D, and ResetCamera3DModifier. Developers can explore detailed settings by referring to the SciChart.js 3D Surface Mesh Documentation.
Integration is streamlined using a standalone Angular component that imports the ScichartAngularComponent. This approach aligns with the standalone components paradigm in Angular. The separation of chart initialization logic and realtime update control ensures that resource management and cleanup (using techniques similar to those discussed in Angular component cleanup) are handled effectively.
Developers should consider performance optimization techniques when dealing with high-frequency updates on WebGL powered charts. Best practices for this can be found in the Performance Tips & Tricks documentation, which advise on memory management and efficient rendering strategies for 3D charts.
Furthermore, the example demonstrates a robust integration strategy by cleanly separating the chart configuration from the realtime update logic, ensuring that Angular’s lifecycle hooks can be leveraged for initialization and disposal, thus maintaining optimal performance and resource usage.
This Angular integration pattern, combined with advanced customization features, makes it a comprehensive reference for building high-performance realtime 3D charts using SciChart.js.

Create detailed Angular 3D Bubble Chart using SciChart's 5-star rated JavaScript chart library. Supports large datasets. Get your free demo now.

Design a Angular 3D Surface Mesh Chart with SciChart.js - feature-rich JavaScript chart library. Represent 2D data in a 3D map. Get your free demo.

Create detailed Angular 3D Line Chart using SciChart's 5-star rated JavaScript chart library. Supports large datasets. Get your free demo now.

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

Demonstrating the capability of SciChart.js to create a composite 2D & 3D Chart application. An example like this could be used to visualize Tenor curves in a financial setting, or other 2D/3D data combined on a single screen.

Create detailed Angular 3D Column Chart using SciChart's 5-star rated JavaScript chart library. Supports large datasets

Create advanced Angular 3D Styling Demo using SciChart's 5-star rated JavaScript chart library. Explore axis styling, plane visibility and multiple point markers.