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

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

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.