React 3D Log-Log Scatter Chart

Demonstrates LogarithmicAxis3D on X and Y axes in a React 3D Scatter Chart using SciChart.js.

Fullscreen

Edit

 Edit

Docs

drawExample.ts

index.tsx

theme.ts

Copy to clipboard
Minimise
Fullscreen
1import { appTheme } from "../../../theme";
2import {
3    SciChart3DSurface,
4    CameraController,
5    Vector3,
6    MouseWheelZoomModifier3D,
7    OrbitModifier3D,
8    ResetCamera3DModifier,
9    NumericAxis3D,
10    LogarithmicAxis3D,
11    NumberRange,
12    ScatterRenderableSeries3D,
13    XyzDataSeries3D,
14    SpherePointMarker3D,
15} from "scichart";
16
17const SENSOR_COUNT = 8;
18const POINTS_PER_SENSOR = 200;
19
20const createSensorData = (sensor: number): { xValues: number[]; yValues: number[]; zValues: number[] } => {
21    const xValues: number[] = new Array(POINTS_PER_SENSOR);
22    const yValues: number[] = new Array(POINTS_PER_SENSOR);
23    const zValues: number[] = new Array(POINTS_PER_SENSOR);
24
25    const alpha = 0.4 + sensor * 0.18;
26    const amplitude = 5e4 / (sensor + 1);
27
28    for (let i = 0; i < POINTS_PER_SENSOR; i++) {
29        const logFreq = (i / (POINTS_PER_SENSOR - 1)) * 5 + (Math.random() - 0.5) * 0.06;
30        const freq = Math.pow(10, logFreq);
31        const noise = 0.7 + Math.random() * 0.6;
32        const psd = Math.max(amplitude * Math.pow(freq, -alpha) * noise, 1e-6);
33        xValues[i] = freq;
34        yValues[i] = psd;
35        zValues[i] = sensor;
36    }
37    return { xValues, yValues, zValues };
38};
39
40const sensorColor = (sensor: number): string => {
41    const t = sensor / (SENSOR_COUNT - 1);
42    const r = Math.round(20 + t * 230);
43    const g = Math.round(180 - t * 120);
44    const b = Math.round(255 - t * 210);
45    return `#${r.toString(16).padStart(2, "0")}${g.toString(16).padStart(2, "0")}${b.toString(16).padStart(2, "0")}`;
46};
47
48export const X_RANGE_LOG = new NumberRange(1, 1e5);
49export const X_RANGE_LINEAR = new NumberRange(0, 1e5);
50export const Y_RANGE_LOG = new NumberRange(1e-4, 1e5);
51export const Y_RANGE_LINEAR = new NumberRange(0, 1e5);
52
53export const drawExample = async (rootElement: string | HTMLDivElement) => {
54    const { sciChart3DSurface, wasmContext } = await SciChart3DSurface.create(rootElement, {
55        theme: appTheme.SciChartJsTheme,
56    });
57
58    sciChart3DSurface.camera = new CameraController(wasmContext, {
59        position: new Vector3(-300, 220, -280),
60        target: new Vector3(0, 50, 0),
61    });
62
63    sciChart3DSurface.chartModifiers.add(
64        new MouseWheelZoomModifier3D(),
65        new OrbitModifier3D(),
66        new ResetCamera3DModifier()
67    );
68
69    sciChart3DSurface.xAxis = new LogarithmicAxis3D(wasmContext, {
70        axisTitle: "Frequency (Hz)",
71        logBase: 10,
72        visibleRange: X_RANGE_LOG,
73    });
74
75    sciChart3DSurface.yAxis = new LogarithmicAxis3D(wasmContext, {
76        axisTitle: "PSD (V²/Hz)",
77        logBase: 10,
78        visibleRange: Y_RANGE_LOG,
79    });
80
81    sciChart3DSurface.zAxis = new NumericAxis3D(wasmContext, {
82        axisTitle: "Sensor",
83        visibleRange: new NumberRange(-0.5, SENSOR_COUNT - 0.5),
84    });
85
86    for (let s = 0; s < SENSOR_COUNT; s++) {
87        const { xValues, yValues, zValues } = createSensorData(s);
88        const dataSeries = new XyzDataSeries3D(wasmContext, {
89            xValues,
90            yValues,
91            zValues,
92            dataSeriesName: `Sensor ${s + 1}`,
93        });
94        const scatter = new ScatterRenderableSeries3D(wasmContext, {
95            dataSeries,
96            pointMarker: new SpherePointMarker3D(wasmContext, { size: 5, fill: sensorColor(s) }),
97            opacity: 0.85,
98        });
99        sciChart3DSurface.renderableSeries.add(scatter);
100    }
101
102    return { sciChartSurface: sciChart3DSurface, wasmContext };
103};
104

React 3D Log-Log Scatter Chart

Overview

This example demonstrates how to use LogarithmicAxis3D in a React 3D scatter chart powered by SciChart.js. The <SciChartReact/> component handles the chart lifecycle, while the drawExample function configures logarithmic scaling on both X and Y axes to visualize power spectral density data across 8 sensors.

Technical Implementation

The SciChartReact component from scichart-react accepts the drawExample function as the initChart prop, managing WebAssembly initialization and cleanup automatically. LogarithmicAxis3D with logBase: 10 is applied to the frequency (X) and PSD (Y) axes. Each sensor series uses XyzDataSeries3D populated with log-uniformly distributed frequency points and corresponding power-law PSD values.

Features and Capabilities

Full 3D navigation is enabled via MouseWheelZoomModifier3D, OrbitModifier3D, and ResetCamera3DModifier. Eight ScatterRenderableSeries3D instances with colored SpherePointMarker3D markers represent distinct sensor channels with steepening power-law slopes.

Integration and Best Practices

The SciChartReact component handles resource disposal automatically. See React Charts with SciChart.js for details on lifecycle management. The logarithmic visible range must contain only positive values — avoid ranges that include zero or negative numbers.

react Chart Examples & Demos

See Also: JavaScript 3D Chart Types (11 Demos)

React 3D Bubble Chart | 3D JavaScript Charts | View Now

React 3D Bubble Chart

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

React 3D Surface Mesh Chart | View 3D JavaScript Charts

React Surface Mesh 3D Chart

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

React 3D Point Line Chart | View 3D JavaScript Charts

React Point Line 3D Chart

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

LiDAR 3D Point Cloud of Geospatial Data | SciChart.js

LiDAR 3D Point Cloud of Geospatial Data

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

Tenor Curves Demo | React Charts | SciChart.js Demo

Tenor Curves Demo

Demonstrating the capability of SciChart.js to create a composite 2D &amp; 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.

React Realtime 3D Surface Mesh Chart | View 3D JavaScript Charts

React Realtime Surface Mesh 3D Chart

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

React 3D Column Chart | View 3D JavaScript Charts | SciChart

React Column 3D Chart

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

React 3D Styling Demo | Advanced 3D Chart Styling | SciChart

React 3D Styling Demo

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

React Interactive 3D Waterfall Spectral Chart | View 3D JavaScript Charts

React Interactive 3D Waterfall Spectral Chart

Build an interactive React 3D waterfall spectral chart with synchronized 2D cross-section charts using SciChart.js and SciChartReact.

NEW!
React Immediate Mesh 3D Chart | View 3D JavaScript Charts

React Immediate Mesh 3D Chart

Draw custom lit 3D geometry in React with SciChart.js using ImmediateLitMeshContext. Emit per-vertex positions, normals, texture coordinates and colours from a custom 3D scene entity.

NEW!
React 3D Model Example | View 3D JavaScript Charts | SciChart

React 3D Model Example

Load a 3D model in React with SciChart.js. Add the model to a SciChart3DSurface as a 3D scene entity, frame it with the camera, then orbit and zoom it. Any 3D model can be loaded.

SciChart Ltd, 16 Beaufort Court, Admirals Way, Docklands, London, E14 9XL.