JavaScript Windrose Plot | Polar Stacked Radial Column Chart

Creates a JavaScript 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.html

vanilla.ts

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

Overview

This example demonstrates how to create a Polar Windrose Column Chart using SciChart.js in JavaScript. The chart visualizes directional data with stacked columns in a polar coordinate system, commonly used for wind speed/direction analysis.

Technical Implementation

The chart uses SciChartPolarSurface with PolarNumericAxis for radial and angular axes. A custom CustomNESWLabelProvider displays compass directions. Data is generated via getBiasedRandomWalkInBounds function to create realistic wind patterns.

Features and Capabilities

The implementation uses PolarStackedColumnCollection with multiple PolarStackedColumnRenderableSeries for stacked visualization. Interactive features include PolarPanModifier and PolarZoomExtentsModifier.

Integration and Best Practices

The example follows async initialization pattern with proper cleanup. Developers can extend this by adding real-time data updates or customizing the WaveAnimation effects.

javascript Chart Examples & Demos

See Also: Polar Charts (21 Demos)

JavaScript Polar Line Chart | Javascript Charts | SciChart.js

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

JavaScript Polar Spline Line Chart | SciChart.js Demo

JavaScript Polar Spline Line Chart

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

JavaScript Multi-Cycle Polar Line | SciChart.js Demo

JavaScript Multi Cycle-Polar Line Example

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

JavaScript Polar Column Chart | Polar Bar Chart | SciChart

JavaScript Polar Column | Polar Bar

Try the JavaScript Polar Column or Bar Chart example to render bars in a polar layout with gradient fills and animations. Use SciChart for seamless integrations.

JavaScript Polar Column Category Chart | SciChart.js Demo

JavaScript Polar Column Category Chart

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

JavaScript Polar Range Column Chart | SciChart.js Demo

JavaScript Polar Range Column Chart

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

JavaScript Polar Sunburst Chart | Javascript Charts | SciChart.js

JavaScript Polar Sunburst Chart

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

JavaScript Polar Radial Column Chart | SciChart.js Demo

JavaScript Polar Radial Column Chart

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

JavaScript Stacked Radial Column Chart | Stacked Radial Bar Chart

JavaScript Stacked Radial Column Chart | Stacked Radial Bar Chart

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

JavaScript Polar Area Chart | Polar Mountain Chart | SciChart

JavaScript Polar Area Chart | Polar Mountain Chart

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

JavaScript Polar Stacked Radial Mountain Chart | SciChart

JavaScript Polar Stacked Radial Mountain Chart

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

JavaScript Polar Band | Polar Error Bands Chart | SciChart

JavaScript Polar Band | Polar Error Bands Chart

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

JavaScript Polar Scatter Chart | Javascript Charts | SciChart.js

JavaScript Polar Scatter Chart

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

JavaScript Polar Radar Chart | Spider Radar Chart | SciChart

JavaScript Polar Radar Chart

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

JavaScript Polar Gauge Chart | Circular Gauge Chart

JavaScript Gauge Charts

Create JavaScript Gauge Charts, including a JavaScript Circular Gauge Dashboard, with user-friendly initialization and responsive design. Give SciChart a go.

JavaScript Arc Gauge & FIFO Scrolling Charts Dashboard

JavaScript Arc Gauge & FIFO Scrolling Charts Dashboard Example

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

JavaScript Polar Uniform Heatmap Chart | SciChart.js Demo

JavaScript Polar Uniform Heatmap Chart

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

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

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

No description available for this example yet

JavaScript Polar Partial Arc | Javascript Charts | SciChart.js

JavaScript Polar Partial Arc

Create a JavaScript 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.

JavaScript Polar Axis Label Modes | SciChart.js Demo

JavaScript Polar Axis Label Modes

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

JavaScript Polar Map Example | Javascript Charts | SciChart.js

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