React Polar Scatter Chart

Creates a React Polar Scatter Chart using SciChart.js, with the PolarXyScatterRenderableSeries and custom legend-markers.

Fullscreen

Edit

 Edit

Docs

drawExample.ts

index.tsx

theme.ts

Copy to clipboard
Minimise
Fullscreen
1import {
2    PolarMouseWheelZoomModifier,
3    PolarZoomExtentsModifier,
4    PolarPanModifier,
5    XyDataSeries,
6    PolarNumericAxis,
7    SciChartPolarSurface,
8    EPolarAxisMode, 
9    NumberRange, 
10    EAxisAlignment, 
11    EPolarLabelMode,
12    PolarXyScatterRenderableSeries,
13    SweepAnimation,
14    PolarLegendModifier,
15    EPointMarkerType,
16    ELegendOrientation,
17    TLegendItem,
18    EActionType,
19} from "scichart";
20import { appTheme } from "../../../theme";
21
22export const drawExample = async (rootElement: string | HTMLDivElement) => {
23    const { sciChartSurface, wasmContext } = await SciChartPolarSurface.create(rootElement, {
24        theme: appTheme.SciChartJsTheme,
25    });
26
27    const radialYAxis = new PolarNumericAxis(wasmContext, {
28        polarAxisMode: EPolarAxisMode.Radial,
29        axisAlignment: EAxisAlignment.Right,
30        visibleRange: new NumberRange(0, 1400),
31        zoomExtentsToInitialRange: true,
32        
33        drawMinorTickLines: false,
34        drawMajorTickLines: false,
35        drawMinorGridLines: false,
36        
37        startAngle: Math.PI / 2,
38        majorGridLineStyle: {
39            color: appTheme.DarkIndigo,
40            strokeThickness: 1,
41        },
42        drawLabels: false, // no radial labels
43    });
44    sciChartSurface.yAxes.add(radialYAxis);
45
46    const polarXAxis = new PolarNumericAxis(wasmContext, {
47        polarAxisMode: EPolarAxisMode.Angular,
48        axisAlignment: EAxisAlignment.Top,
49        polarLabelMode: EPolarLabelMode.Parallel,
50        visibleRange: new NumberRange(0, 360),
51        startAngle: Math.PI / 2, // start at 12 o'clock
52        flippedCoordinates: true, // go clockwise
53        zoomExtentsToInitialRange: true,
54
55        autoTicks: false,
56        majorDelta: 30,
57
58        drawMinorTickLines: false,
59        drawMajorTickLines: false,
60        drawMinorGridLines: false,
61
62        useNativeText: true,
63        labelPrecision: 0,
64        labelPostfix: "°",
65        labelStyle: {
66            color: "white",
67        },
68        majorGridLineStyle: {
69            color: appTheme.DarkIndigo,
70            strokeThickness: 1,
71        },
72    });
73    sciChartSurface.xAxes.add(polarXAxis);
74
75    const xValues = Array.from({ length: 540 }, (_, i) => i);
76    const SCATTER_DATA = [
77        {
78            yVals: xValues.map((x) => 2 * x + x * Math.random() * 0.5),
79            color: appTheme.VividOrange,
80            name: "Circle Series",
81            pointMarkerType: EPointMarkerType.Ellipse
82        }, 
83        {
84            yVals: xValues.map((x) => x + x * Math.random() * 0.5),
85            color: appTheme.VividSkyBlue,
86            name: "Triangular Series",
87            pointMarkerType: EPointMarkerType.Triangle,
88        }
89    ]
90
91    SCATTER_DATA.forEach(({ yVals, color, name, pointMarkerType }) => {
92        const polarScatter = new PolarXyScatterRenderableSeries(wasmContext, {
93            dataSeries: new XyDataSeries(wasmContext, {
94                xValues: xValues,
95                yValues: yVals,
96                dataSeriesName: name,
97            }),
98            opacity: 0.7,
99            stroke: color, // set stroke color for Legend modifier markers
100
101            // @ts-ignore
102            pointMarker: {
103                type: pointMarkerType,
104                options: {
105                    width: 10,
106                    height: 10,
107                    stroke: color,
108                    strokeThickness: 1,
109                    fill: color + "88",
110                }
111            },
112            animation: new SweepAnimation({ duration: 800 }),
113        });
114        sciChartSurface.renderableSeries.add(polarScatter);
115    });
116
117    // Extra feature -> Custom legend marker with SVG shapes
118    const customMarkerLegendModifier = new PolarLegendModifier({
119        showCheckboxes: true,
120        showSeriesMarkers: true,
121        backgroundColor: "#66666633"
122    });
123    // override "getLegendItemHTML" to add custom SVG shapes
124    customMarkerLegendModifier.sciChartLegend.getLegendItemHTML = (
125        orientation: ELegendOrientation,
126        showCheckboxes: boolean,
127        showSeriesMarkers: boolean,
128        item: TLegendItem
129    ): string => {
130        const display = orientation === ELegendOrientation.Vertical ? "flex" : "inline-flex";
131        let str = `<span class="scichart__legend-item" style="display: ${display}; align-items: center; margin-right: 4px; padding: 0 4px 0 5px; white-space: nowrap; gap: 5px">`;
132        
133        if (showCheckboxes) {
134            const checked = item.checked ? "checked" : "";
135            str += `<input ${checked} type="checkbox" id="${item.id}">`;
136        }
137        
138        if (showSeriesMarkers) {
139            str += `<svg 
140                xmlns="http://www.w3.org/2000/svg"
141                for="${item.id}" 
142                style="width: 15px; height: 15px;" 
143                viewBox="0 0 24 24"
144                stroke-width="2"
145            >
146                ${(() => {
147                    switch (item.name) {
148                        case SCATTER_DATA[0].name: // Circle
149                            return `<circle cx="12" cy="12" r="9" fill="${item.color + "88"}" stroke="${item.color}"/>`;
150
151                        case SCATTER_DATA[1].name: // Triangle 
152                            return `<polygon points="12,2 22,22 2,22" fill="${item.color + "88"}" stroke="${item.color}"/>`;
153
154                        default: // Others 
155                            return `<rect x="2" y="2" width="20" height="20" fill="${item.color + "88"}" stroke="${item.color}"/>`;
156                    }
157                })()}
158            </svg>`
159        }
160        str += `<label for="${item.id}">${item.name}</label>`;
161        str += `</span>`;
162        return str;
163    };
164
165    sciChartSurface.chartModifiers.add(
166        customMarkerLegendModifier,
167        new PolarPanModifier(),
168        new PolarZoomExtentsModifier(),
169        new PolarMouseWheelZoomModifier({
170            defaultActionType: EActionType.Zoom
171        }),
172    );
173
174    return { sciChartSurface, wasmContext };
175};

Polar Scatter Chart - React

Overview

This example integrates a Polar Scatter Chart into a React application using scichart-react. It asynchronously initializes the chart via drawExample, rendering multiple scatter series on radial and angular axes.

Technical Implementation

Within the <SciChartReact> component, drawExample calls SciChartPolarSurface.create to set up the chart surface and WebAssembly context. Axes are configured with PolarNumericAxis, specifying EPolarAxisMode.Radial and EPolarAxisMode.Angular, start angles, ranges, and styling. Scatter series are added using PolarXyScatterRenderableSeries and animated via SweepAnimation.

Features and Capabilities

React integration includes:

  • Customizable legend with PolarLegendModifier overriding getLegendItemHTML to render SVG markers
  • Interactive chart modifiers: PolarPanModifier, PolarZoomExtentsModifier, PolarMouseWheelZoomModifier
  • High-performance rendering through WebGL and WebAssembly

Integration and Best Practices

Use scichart-react to manage the chart lifecycle. Provide cleanup by returning a destructor that calls sciChartSurface.delete(). Follow best practices for async initialization in React components and leverage documented hooks in scichart-react GitHub.

react Chart Examples & Demos

See Also: Polar Charts (21 Demos)

React Polar Line Chart | React Charts | SciChart.js Demo

React Polar Line Chart

Explore the React Polar Line Chart example to create data labels, line interpolation, gradient palette stroke and startup animations. Try the SciChart Demo.

React Polar Spline Line Chart | React Charts | SciChart.js

React Polar Spline Line Chart

Try the React Polar Spline Line Chart example to see SciChart's GPU-accelerated rendering in action. Choose a cubic spline or polar interpolation. View demo.

React Multi-Cycle Polar Line | React Charts | SciChart.js

React Multi Cycle-Polar Line Example

Create a React Multi-Cycle Polar Chart to plot data over multiple cycles and visualize patterns over time. This example shows surface temperature by month.

React Polar Column Chart | React Polar Bar Chart | SciChart

React Polar Column | React Polar Bar

Try the React Polar Bar Chart example to render bars in a polar layout with gradient fills and animations. Use SciChart for seamless integration with React.

React Polar Column Category Chart | SciChart.js Demo

React Polar Column Category Chart

Create a React Polar Colum Category chart visualizing UK consumer price changes. Try the demo with a custom positive/negative threshold fill and stroke.

React Polar Range Column Chart | React Charts | SciChart.js

React Polar Range Column Chart

Create a React Polar Range Column Chart with SciChart. This example displays monthly minimum and maximum temperatures within a Polar layout. Try the demo.

React Windrose Plot | React Polar Stacked Radial Column Chart

React Windrose Plot | React Polar Stacked Radial Column Chart

View the React Windrose Chart example to display directional data with stacked columns in a polar layout. Try the polar chart demo with customizable labels.

React Polar Sunburst Chart | React Charts | SciChart.js

React Polar Sunburst Chart

See the React Sunburst Chart example with multiple levels, smooth animation transitions and dynamically updating segment colors. Try the SciChart demo.

React Polar Radial Column Chart | React Charts | SciChart.js

React Polar Radial Column Chart

View the React Radial Column Chart example to see the difference that SciChart has to offer. Switch radial and angular axes and add interactive modifiers.

React Stacked Radial Column Chart | Stacked Radial Bar Chart

React Stacked Radial Column Chart | Stacked Radial Bar Chart

This React Stacked Radial Bar Chart example shows Olympic medal data by country. Try the demo for yourself with async initialization and theme application.

React Polar Area Chart | Polar Mountain Chart | SciChart

React Polar Area Chart | Polar Mountain Chart

The React Polar Area Chart example, also known as Nightingale Rose Chart, renders an area series with polar coordinates with interactive legend controls.

React Polar Stacked Radial Mountain Chart | SciChart.js

React Polar Stacked Radial Mountain Chart

Try the React Stacked Radial Mountain Chart example to show multiple datasets on a polar layout with a stacked mountain series and animated transitions.

React Polar Band | Polar Error Bands Chart | SciChart.js

React Polar Band | Polar Error Bands Chart

Create a React Polar Chart with regular and interpolated error bands. Enhance a standard chart with shaded areas to show upper and lower data boundaries.

React Polar Radar Chart | Spider Radar Chart | SciChart

React Polar Radar Chart

View the React Polar Radar Chart example. Also known as the Spider Radar Chart, view the scalability and stability that SciChart has to offer. Try demo.

React Polar Gauge Chart | React Circular Gauge | SciChart

React Gauge Charts

Create React Gauge Charts, including a React Circular Gauge Dashboard, with React-friendly initialization and responsive design. Give the SciChart demo a go.

React Arc Gauge & FIFO Scrolling Charts Dashboard | SciChart

React Arc Gauge & FIFO Scrolling Charts Dashboard Example

View React Arc Gauge Charts alongside FIFO Scrolling Charts, all on the same dashboard with real-time, high-performance data rendering. Try the demo.

React Polar Uniform Heatmap Chart | SciChart.js Demo

React Polar Uniform Heatmap Chart

Try SciChart's React Polar Heatmap example to combine a polar heatmap with a legend component. Supports responsive design and chart and legend separation.

React Polar Heatmap | B-Mode Image Ultrasound | Medical Heatmap

React Polar Heatmap | B-Mode Image Ultrasound | Medical Heatmap

No description available for this example yet

React Polar Partial Arc | React Charts | SciChart.js Demo

React Polar Partial Arc

Create a React Polar Partial Arc that bends from a full Polar Circle to a Cartesian-like arc. Try the demo to display an arc segment with Polar coordinates.

React Polar Axis Label Modes | React Charts | SciChart.js

React Polar Axis Label Modes

Create a React Polar Axis Label with SciChart. This demo shows the various label modes for Polar Axes – all optimised for pan, zoom, and mouse wheel.

React Polar Map Example | React Charts | SciChart.js Demo

React Polar Map Example

View the React Polar Map Example using the SciChartReact component. Display geographic data as color-coded triangles on a polar coordinate system. Try demo.

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