Angular Polar Map Example

Demonstrates how to create a Polar Map Example using our PolarTriangleRenderableSeries class, along with a triangulation alorithm.

Fullscreen

Edit

 Edit

Docs

drawExample.ts

angular.ts

theme.ts

constrainedDelaunayTriangulation.ts

Copy to clipboard
Minimise
Fullscreen
1import {
2    NumberRange,
3    XyDataSeries,
4    ETriangleSeriesDrawMode,
5    PolarPanModifier,
6    PolarZoomExtentsModifier,
7    PolarMouseWheelZoomModifier,
8    PolarTriangleRenderableSeries,
9    PolarNumericAxis,
10    EPolarAxisMode,
11    EAxisAlignment,
12    SciChartPolarSurface,
13} from "scichart";
14
15import constrainedDelaunayTriangulation from "./constrainedDelaunayTriangulation";
16import { appTheme } from "../../../theme";
17
18export const drawExample = async (rootElement: string | HTMLDivElement) => {
19    // Create a SciChartSurface
20    const { wasmContext, sciChartSurface } = await SciChartPolarSurface.create(rootElement);
21
22    sciChartSurface.debugRendering = false;
23
24    let showFromSouthPole = false;
25
26    const setView = (positionFromSPole: boolean) => {
27        showFromSouthPole = positionFromSPole;
28
29        sciChartSurface.xAxes.clear();
30        sciChartSurface.yAxes.clear();
31        sciChartSurface.renderableSeries.clear(true);
32
33        const xAxis = new PolarNumericAxis(wasmContext, {
34            polarAxisMode: EPolarAxisMode.Angular,
35            visibleRange: new NumberRange(-180, 180), // longitude
36            flippedCoordinates: showFromSouthPole ? true : false,
37            axisAlignment: EAxisAlignment.Bottom,
38            useNativeText: true,
39            drawMajorBands: false,
40            drawMajorGridLines: false,
41            drawMajorTickLines: false,
42            drawMinorGridLines: false,
43            drawMinorTickLines: false,
44            labelPrecision: 0,
45        });
46        sciChartSurface.xAxes.add(xAxis);
47
48        const yAxis = new PolarNumericAxis(wasmContext, {
49            polarAxisMode: EPolarAxisMode.Radial,
50            visibleRange: new NumberRange(-90, 90), // latitude
51            axisAlignment: EAxisAlignment.Left,
52            flippedCoordinates: showFromSouthPole ? false : true,
53            useNativeText: true,
54            drawMajorBands: false,
55            drawMajorGridLines: false,
56            drawMajorTickLines: false,
57            drawMinorGridLines: false,
58            drawMinorTickLines: false,
59            labelPrecision: 0,
60        });
61        sciChartSurface.yAxes.add(yAxis);
62    };
63
64    setView(true);
65
66    const [min, max] = [140, 1379302771]; // population min max
67
68    function interpolateColor(min: number, max: number, value: number) {
69        // Clamp value between min and max
70        value = Math.max(min, Math.min(max, value));
71        // Normalize to [0,1]
72        let t = (value - min) / (max - min);
73
74        // Parse hex colors to RGB
75        function hexToRgb(hex: string) {
76            hex = hex.replace(/^#/, "");
77            if (hex.length === 3)
78                hex = hex
79                    .split("")
80                    .map((x) => x + x)
81                    .join("");
82            const num = parseInt(hex, 16);
83            return [num >> 16, (num >> 8) & 255, num & 255];
84        }
85
86        // Interpolate between two RGB colors
87        function lerp(a: number, b: number, t: number) {
88            return Math.round(a + (b - a) * t);
89        }
90
91        // The low end of the scale has to contrast with the chart background. White reads well on the
92        // dark themes but vanishes into the light one, so start from a pale blue there instead.
93        const colorA = hexToRgb(appTheme.isDark ? "#ffffff" : "#c3cfe8");
94        const colorB = hexToRgb("#1e3489");
95        const r = lerp(colorA[0], colorB[0], t);
96        const g = lerp(colorA[1], colorB[1], t);
97        const b = lerp(colorA[2], colorB[2], t);
98
99        // Convert back to hex
100        return "#" + [r, g, b].map((x) => x.toString(16).padStart(2, "0")).join("");
101    }
102
103    let dataArray: { name: string; gdp: number; population: number; areaData: number[][] }[] = [];
104
105    const setMapJson = (mapData: { features: any[] }) => {
106        dataArray = [];
107
108        mapData?.features.forEach((state, i) => {
109            if (state.geometry.type === "Polygon") {
110                let area = state.geometry.coordinates[0];
111                area.pop();
112                let areaData = [].concat(...constrainedDelaunayTriangulation(area));
113
114                dataArray.push({
115                    name: state.properties.NAME,
116                    gdp: +state.properties.GDP_MD_EST,
117                    population: +state.properties.POP_EST,
118                    areaData,
119                });
120            } else {
121                let polyArea = state.geometry.coordinates;
122
123                if (state.properties.SOVEREIGNT === "Antarctica" && showFromSouthPole === false) {
124                    return;
125                }
126
127                polyArea.forEach((a: any[]) => {
128                    let area = a[0];
129
130                    area.pop();
131                    let areaData = [].concat(...constrainedDelaunayTriangulation(area));
132
133                    dataArray.push({
134                        name: state.properties.NAME,
135                        gdp: +state.properties.GDP_MD_EST,
136                        population: +state.properties.POP_EST,
137                        areaData,
138                    });
139                });
140            }
141        });
142    };
143
144    const setMap = () => {
145        sciChartSurface.renderableSeries.clear(true);
146
147        const series = dataArray.map((d, i) => {
148            const dataSeries = new XyDataSeries(wasmContext, {
149                xValues: d.areaData.map((p) => p[0]),
150                yValues: d.areaData.map((p) => p[1]),
151            });
152
153            const triangleSeries = new PolarTriangleRenderableSeries(wasmContext, {
154                dataSeries: dataSeries,
155                drawMode: ETriangleSeriesDrawMode.List,
156                fill: interpolateColor(min, max, d.population),
157                opacity: 0.9,
158            });
159
160            return triangleSeries;
161        });
162
163        sciChartSurface.renderableSeries.add(...series);
164    };
165
166    sciChartSurface.chartModifiers.add(new PolarPanModifier());
167    sciChartSurface.chartModifiers.add(new PolarZoomExtentsModifier());
168    sciChartSurface.chartModifiers.add(new PolarMouseWheelZoomModifier());
169    return { sciChartSurface, wasmContext, setMapJson, setMap, setView };
170};
171

Polar Map Example - Angular

Overview

This Angular implementation demonstrates a polar map visualization using the SciChart Angular wrapper. The standalone component displays geographic data as triangles on polar coordinates with dynamic view switching.

Technical Implementation

The chart is initialized through the [initChart] input binding, which creates a SciChartPolarSurface with configured axes. Geographic data is loaded via HTTP client and processed into triangles using the constrained Delaunay algorithm.

Features and Capabilities

The component maintains the same core functionality as other frameworks, including population-based coloring and polar coordinate transformations. Angular's change detection ensures proper updates when switching between North/South pole views.

Integration and Best Practices

The example follows Angular best practices for standalone components and async data loading. The SciChart Angular wrapper simplifies integration while maintaining full access to SciChart's API.

angular Chart Examples & Demos

See Also: Polar Charts (21 Demos)

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

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

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

Angular Polar Spline Line Chart

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

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

Angular Multi Cycle-Polar Line Example

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

Angular Polar Column Chart | Polar Bar Chart | SciChart

Angular Polar Column Chart | Angular Polar Bar

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

Angular Polar Column Category Chart | SciChart.js Demo

Angular Polar Column Category Chart

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

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

Angular Polar Range Column Chart

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

Angular Windrose Plot | Angular Polar Stacked Radial Column Chart

Angular Windrose Plot | Angular Polar Stacked Radial Column Chart

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

Angular Polar Sunburst Chart | Angular Charts | SciChart.js

Angular Polar Sunburst Chart

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

Angular Polar Radial Column Chart | SciChart.js Demo

Angular Polar Radial Column Chart

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

Angular Stacked Radial Column Chart | Stacked Radial Bar Chart

Angular Stacked Radial Column Chart | Stacked Radial Bar Chart

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

Angular Polar Area Chart | Polar Mountain Chart | SciChart

Angular Polar Area Chart | Polar Mountain Chart

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

Angular Polar Stacked Radial Mountain Chart | SciChart.js

Angular Polar Stacked Radial Mountain Chart

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

Angular Polar Band | Polar Error Bands Chart | SciChart

Angular Polar Band | Polar Error Bands Chart

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

Angular Polar Scatter Chart | Angular Charts | SciChart.js

Angular Polar Scatter Chart

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

Angular Polar Radar Chart | Spider Radar Chart | SciChart

Angular Polar Radar Chart

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

Angular Polar Gauge Chart | Angular Circular Gauge | SciChart

Angular Gauge Charts

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

Angular Arc Gauge & FIFO Scrolling Charts Dashboard

Angular Arc Gauge & FIFO Scrolling Charts Dashboard Example

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

Angular Polar Uniform Heatmap Chart | SciChart.js Demo

Angular Polar Uniform Heatmap Chart

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

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

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

No description available for this example yet

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

Angular Polar Partial Arc

Create an Angular 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.

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

Angular Polar Axis Label Modes

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

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