Skip to content

Highcharts Maps #411

@bigalnz

Description

@bigalnz

I am trying to display a map in highcharts in Angular 20. I have read the docs for angular-highcharts for maps, and it linked to a stackblitz which was using Angular 10, so I assume this is very old - and maybe not a good example to follow.

My non-working attempt so far is:

map-tile.ts
`
import { Component, OnInit } from '@angular/core';
import { CommonModule } from '@angular/common';
import * as Highcharts from 'highcharts';
import { HighchartsChartComponent } from 'highcharts-angular';
import mapModule from 'highcharts/modules/map';
import type { Options } from 'highcharts';

// Register the map module
mapModule(Highcharts);

// Import the actual map
import * as worldMap from '@highcharts/map-collection/custom/world.geo.json';

@component({
selector: 'app-map-tile',
standalone: true,
imports: [CommonModule, HighchartsChartComponent],
templateUrl: './map-test.html',
styleUrl: './map-test.scss'
})
export class MapTestTileComponent implements OnInit {
Highcharts: typeof Highcharts = Highcharts;
chartOptions!: Options; // Declare but initialize later

ngOnInit(): void {
this.chartOptions = {
chart: {
map: worldMap as any,
height: 500,
},
title: {
text: 'World Map',
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 0
},
series: [
{
type: 'map',
name: 'Random data',
mapData: worldMap as any,
data: worldMap.features.map((f, i) => [f.properties['hc-key'], Math.random() * 100]),
}
],
credits: { enabled: false }
};
}
}
`

and html:

`
<highcharts-chart
[options]="chartOptions"
style="width: 100%; height: 100%; display: block;"

`

Any help on this would be appreciated. Thank you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions