Our team demonstrates how to create a Angular 3D Bubble Chart using SciChart.js, capable of creating detailed 3D JavaScript Charts.
drawExample.ts
angular.ts
ExampleDataProvider.ts
theme.ts
1import { appTheme } from "../../../theme";
2
3import {
4 SciChart3DSurface,
5 CameraController,
6 Vector3,
7 MouseWheelZoomModifier3D,
8 OrbitModifier3D,
9 ResetCamera3DModifier,
10 NumericAxis3D,
11 NumberRange,
12 ScatterRenderableSeries3D,
13 XyzDataSeries3D,
14 SpherePointMarker3D,
15 TGradientStop,
16 parseColorToUIntArgb,
17 TooltipModifier3D,
18 SeriesInfo3D,
19 TooltipSvgAnnotation3D,
20 XyzSeriesInfo3D,
21 IPointMetadata3D,
22} from "scichart";
23
24import {
25 fetchPopulationDataData,
26 TMappedPopulationData,
27 TPopulationMetadata,
28} from "../../../ExampleData/ExampleDataProvider";
29
30const initializeChart = async (rootElement: string | HTMLDivElement) => {
31 const { sciChart3DSurface, wasmContext } = await SciChart3DSurface.create(rootElement, {
32 theme: appTheme.SciChartJsTheme,
33 });
34 sciChart3DSurface.camera = new CameraController(wasmContext, {
35 position: new Vector3(-141.6, 310.29, 393.32),
36 target: new Vector3(0, 50, 0),
37 });
38
39 sciChart3DSurface.chartModifiers.add(
40 new MouseWheelZoomModifier3D(),
41 new OrbitModifier3D(),
42 new ResetCamera3DModifier()
43 );
44
45 const tooltipModifier = new TooltipModifier3D({ tooltipLegendOffsetX: 10, tooltipLegendOffsetY: 10 });
46 tooltipModifier.tooltipDataTemplate = (seriesInfo: SeriesInfo3D, svgAnnotation: TooltipSvgAnnotation3D) => {
47 const valuesWithLabels: string[] = [];
48 if (seriesInfo && seriesInfo.isHit) {
49 const md = (seriesInfo as XyzSeriesInfo3D).pointMetadata as TPopulationMetadata;
50 valuesWithLabels.push(md.country);
51 valuesWithLabels.push(`Life Expectancy: ${seriesInfo.xValue}`);
52 valuesWithLabels.push(`GDP Per Capita: ${seriesInfo.yValue}`);
53 valuesWithLabels.push(`Year: ${seriesInfo.zValue}`);
54 }
55 return valuesWithLabels;
56 };
57 const defaultTemplate = tooltipModifier.tooltipSvgTemplate;
58 tooltipModifier.tooltipSvgTemplate = (seriesInfo: SeriesInfo3D, svgAnnotation: TooltipSvgAnnotation3D) => {
59 if (seriesInfo) {
60 const md = (seriesInfo as XyzSeriesInfo3D).pointMetadata as TPopulationMetadata;
61 svgAnnotation.containerBackground = md.color;
62 svgAnnotation.textStroke = "white";
63 }
64 return defaultTemplate(seriesInfo, svgAnnotation);
65 };
66 sciChart3DSurface.chartModifiers.add(tooltipModifier);
67
68 sciChart3DSurface.xAxis = new NumericAxis3D(wasmContext, {
69 axisTitle: "Life Expectancy",
70 visibleRange: new NumberRange(30, 85),
71 labelPrecision: 0,
72 });
73 sciChart3DSurface.yAxis = new NumericAxis3D(wasmContext, {
74 axisTitle: "Gdp Per Capita",
75 visibleRange: new NumberRange(0, 50000),
76 labelPrecision: 0,
77 });
78 sciChart3DSurface.zAxis = new NumericAxis3D(wasmContext, {
79 axisTitle: "Year",
80 visibleRange: new NumberRange(1950, 2010),
81 labelPrecision: 0,
82 });
83
84 const renderableSeries = new ScatterRenderableSeries3D(wasmContext, {
85 pointMarker: new SpherePointMarker3D(wasmContext, { size: 10 }),
86 opacity: 0.9,
87 dataSeries: new XyzDataSeries3D(wasmContext),
88 });
89
90 sciChart3DSurface.renderableSeries.add(renderableSeries);
91
92 const setData = (data: TMappedPopulationData) => {
93 const { lifeExpectancy, gdpPerCapita, year, metadata } = data;
94
95 (renderableSeries.dataSeries as XyzDataSeries3D).appendRange(lifeExpectancy, gdpPerCapita, year, metadata);
96 };
97
98 return { sciChartSurface: sciChart3DSurface, setData };
99};
100
101export const drawExample = async (rootElement: string | HTMLDivElement) => {
102 const [chart, data] = await Promise.all([initializeChart(rootElement), fetchPopulationDataData()]);
103 chart.setData(data);
104
105 return chart;
106};
107This example demonstrates the integration of SciChart.js within an Angular application to create an interactive 3D Bubble Chart. The chart visualizes population data with metrics such as life expectancy, GDP per capita, and year, providing users with a dynamic tool for data exploration. The integration is achieved using Angular standalone components, as detailed in the scichart-angular package and the Getting Started with SciChart JS guide.
The chart is initialized asynchronously using async/await patterns common to Angular applications. A SciChart 3D surface is created and configured with a custom camera setup via the CameraController. Interactive modifiers such as MouseWheelZoomModifier3D, OrbitModifier3D, and ResetCamera3DModifier are added to enable smooth user interactions. This implementation leverages asynchronous data fetching with Promise.all to concurrently initialize the chart and retrieve population data, ensuring responsive performance. For more details on asynchronous initialization in Angular, refer to Angular Async/Await: How To Use It.
Key features include real-time data binding through an XyzDataSeries3D and customized tooltip functionality implemented with TooltipModifier3D. The tooltips are dynamically styled using custom SVG templates and provide detailed contextual information about each data point. Additional interactive capabilities are provided by the OrbitModifier3D, which allows smooth rotation of the 3D chart, as described in the Orbit Modifier 3D documentation.
This example follows best practices for integrating external libraries with Angular. It demonstrates the use of Angular standalone components for encapsulation, proper asynchronous initialization, and effective lifecycle management. Developers interested in managing external WebGL resources in Angular can benefit from the concepts discussed in the Angular Component Lifecycle documentation. The approach aligns with the guidelines provided in Tutorial 01 - Setting up a npm Project with SciChart.js, ensuring a modular and maintainable codebase.

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.

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