React Windrose Plot | React Polar Stacked Radial Column Chart

Creates a React Windrose Column Chart using SciChart.js, via PolarStackedColumnRenderableSeries and a custom axis LabelProvider for cardinal directions.

This plot type is Known As: Wind Rose Chart and Wind Direction Chart or Wind Speed Chart.

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    PolarStackedColumnCollection,
12    PolarStackedColumnRenderableSeries,
13    TFormatLabelFn,
14    NumericLabelProvider,
15    EDataPointWidthMode,
16    WaveAnimation
17} from "scichart";
18import { appTheme } from "../../../theme";
19
20function getBiasedRandomWalkInBounds(min: number, max: number, count: number) {
21    // Generate the base random walk
22    const baseValues = [min];
23    for (let i = 1; i < count; i++) {
24        const next = baseValues[i - 1] + Math.random() - 0.5;
25        baseValues.push(Math.min(max, Math.max(min, next)));
26    }
27
28    // Apply an angular bias so that the random walk values become
29    return baseValues.map((val, i) => {
30        const angle = (i * 360) / count;
31        const angleRad = (angle * Math.PI) / 180;
32        // bias ranges from 0.5 to 1.5: peaks at 0°/180°, dips at 90°/270°
33        const bias = 1 + 0.3 * Math.sin(2 * angleRad);
34        return val * bias;
35    });
36}
37
38/**
39 * Custom label provider that displays compass directions at 45 degree intervals,  
40 * if any label value is NOT from `[0, 45, 90, 135, 180, 225, 270, 315]` it will be a decimal.
41 */
42class CustomNESWLabelProvider extends NumericLabelProvider {
43    public LABELS = ["N", "NE", "E", "SE", "S", "SW", "W", "NW"];
44
45    public get formatLabel(): TFormatLabelFn {
46        return (dataValue: number) => {
47            if (dataValue % 45 === 0) {
48                return this.LABELS[dataValue / 45];
49            }
50            return dataValue.toFixed(0) + "°";
51        };
52    }
53}
54
55const COLUMN_COUNT = 24;
56
57export const drawExample = async (rootElement: string | HTMLDivElement) => {
58    const { sciChartSurface, wasmContext } = await SciChartPolarSurface.create(rootElement, {
59        theme: appTheme.SciChartJsTheme,
60    });
61
62    const radialYAxis = new PolarNumericAxis(wasmContext, {
63        axisAlignment: EAxisAlignment.Right,
64        polarAxisMode: EPolarAxisMode.Radial,
65        drawMinorGridLines: false,
66        drawMajorTickLines: false,
67        drawMinorTickLines: false,
68        majorGridLineStyle: {
69            color: appTheme.DarkIndigo,
70            strokeThickness: 1
71        },
72        labelStyle: {
73            color: "white"
74        },
75        startAngle: Math.PI / 2, // draw labels at 12 o'clock
76        autoTicks: false,
77        majorDelta: 1,
78        labelPrecision: 0,
79        innerRadius: 0.05 // center hole
80    });
81    sciChartSurface.yAxes.add(radialYAxis);
82
83    const polarXAxis = new PolarNumericAxis(wasmContext, {
84        polarAxisMode: EPolarAxisMode.Angular,
85        visibleRange: new NumberRange(0, 360),
86        flippedCoordinates: true, // go clockwise
87        startAngle: Math.PI / 2, // start at 12 o'clock
88        axisAlignment: EAxisAlignment.Top,
89        useNativeText: true,
90        labelProvider: new CustomNESWLabelProvider(),
91        autoTicks: false,
92        majorDelta: 15,
93        drawMinorGridLines: false,
94        zoomExtentsToInitialRange: true
95    });
96    sciChartSurface.xAxes.add(polarXAxis);
97
98    const xValues = Array.from({length: COLUMN_COUNT}, (_, i) => i * 360 / COLUMN_COUNT); // [0, 10, ..., 350],
99    const yValues = [
100        getBiasedRandomWalkInBounds(1, 2, COLUMN_COUNT),
101        getBiasedRandomWalkInBounds(0.3, 1, COLUMN_COUNT),
102        getBiasedRandomWalkInBounds(0.3, 1, COLUMN_COUNT),
103        getBiasedRandomWalkInBounds(0.5, 2, COLUMN_COUNT),
104        getBiasedRandomWalkInBounds(0.2, 0.4, COLUMN_COUNT),
105    ];
106
107    const COLORS = [
108        appTheme.DarkIndigo,
109        appTheme.Indigo,
110        appTheme.VividGreen,
111        appTheme.VividOrange,
112        appTheme.VividPink,
113    ]
114
115    const collection = new PolarStackedColumnCollection(wasmContext, {
116        isOneHundredPercent: false,
117    });
118    collection.animation = new WaveAnimation({ duration: 1000, fadeEffect: true });
119    
120    for(let i = 0; i < yValues.length; i++) {
121        const dataSeries = new XyDataSeries(wasmContext, { xValues, yValues: yValues[i] });
122        const polarColumn = new PolarStackedColumnRenderableSeries(wasmContext, {
123            dataSeries,
124            fill: COLORS[i],
125            stroke: appTheme.DarkIndigo,
126            strokeThickness: 2,
127            dataPointWidthMode: EDataPointWidthMode.Range,
128        });
129        collection.add(polarColumn);
130    }
131    sciChartSurface.renderableSeries.add(collection);
132
133    sciChartSurface.chartModifiers.add(
134        new PolarPanModifier(),
135        new PolarZoomExtentsModifier(),
136        new PolarMouseWheelZoomModifier()
137    );
138
139    return { sciChartSurface, wasmContext };
140};

Polar Windrose Column Chart - React

Overview

This React example showcases a Polar Windrose Column Chart using SciChart.js, wrapped in a reusable component. The chart displays directional data with stacked columns in a polar layout.

Technical Implementation

The implementation uses SciChart React component with an initChart prop pointing to the drawExample function. The polar surface configuration matches the JavaScript version, using EPolarAxisMode for axis setup.

Features and Capabilities

The chart features compass-direction labels via custom label provider and stacked columns with distinct colors. The PolarMouseWheelZoomModifier enables intuitive zooming.

Integration and Best Practices

The example demonstrates React best practices by encapsulating chart logic in a separate function and using CSS modules for styling. For performance, consider memoizing the initChart callback in production apps.

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 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 Scatter Chart | React Charts | SciChart.js Demo

React Polar Scatter Chart

Build a React Polar Scatter Chart with this example to render multiple scatter series on radial and angular axes. Try the flexible SciChart demo today.

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.