score:1
I find another ways to render the map.
series: [{
data: Highcharts.geojson(Highcharts.maps['https://code.highcharts.com/mapdata/cou ... /us-all.js']),
name: 'USA',
dataLabels: {
enabled: true,
format: '{point.properties.postal-code}'
}
}]
Basically call the js source url to create the map, but I prefer use Jordan Enev's way.
After I take a look, highcharts already gave the map collection, you can install the dependency @highcharts/map-collection example
After that you can try
import React, { Component } from 'react';
import Highcharts from 'highcharts/highmaps';
import exporting from 'highcharts/modules/exporting';
...
...
exporting(Highcharts);
window.Highcharts = Highcharts;
require('@highcharts/map-collection/countries/id/id-all');
...
...
class Choroplethmap extends Component {
...
...
...
}
export default Choroplethmap;
This issue already raise on this issue
Cheers,
score:2
The maps are now available from npm. You can import them directly into your component and pass it to Highcharts through the options object.
npm i @highcharts/map-collection
import mapDataWorld from '@highcharts/map-collection/custom/world.geo.json'
series: [
{
mapData: mapDataWorld,
name: "Asia",
data: data
}
]
score:14
According the official Highcharts documentation you have to manualy include the map script:
In short, the GeoJSON version of the map is loaded in a script tag in the page. This GeoJSON object is then registered to the Highcharts.maps object, and applied to the mapData option in the chart setup.
As you can see in the fiddle you mentioned, they included the map with the script tag:
<script src="https://code.highcharts.com/mapdata/custom/world.js"></script>
Because of the above script include, the map is available in Highcharts.maps['custom/world']
.
So in the React module you have to manually add the desired maps, like in the demo you mentioned. For example, if you want to add the World map, then:
- Get it from here: https://code.highcharts.com/mapdata/custom/world.js
- Replace
Highcharts.maps["custom/world"] =
withmodule.exports =
in the above file. - Load the map in your component
const map = require('./maps/world');
- Then you can reference it in the config
mapData: map
I understand that you want to skip the above process, but currently there isn't any React module that includes the map.
Actually there is a hackish way you can do it ... In your html file, where the react scripts are included, there you can include world.js script tag, but first you have to make sure that Highcharts.maps object array exist. In that fashion you'll use the maps externally.
However this is a bad practice, because of your React's components will be dependend on that map script.
Good practice is to manage your vendor modules via package manager and reference the modules in the components. In that way the components are self-descriptive
Source: stackoverflow.com
Related Query
- World map paths data in react high charts
- change legend color high charts based on data
- Resize High Charts based on grid layout width and height using react
- Highmaps : Custom data label on world map
- Using global data in High Charts point click custom function in R Shiny
- show only one series data in High charts in start of drawing/load
- How to display total of extra data in stacked column high charts
- Highcharts fill map based on data values with React TypeScript
- How can I put custom color in High Charts PIE data | Slice and want to change slice text
- High charts (Time Series Zoomable) not working with my data
- highcharts highmaps parsing json data to display world map with rich info
- Highcharts: rapid, real-time data updates in high volume line charts using boost
- High charts update data series
- not able to show x axis data with datetimelabel format with {hh:mm} in high charts
- HTML table as data source for highstock charts using highcharts
- High charts displays data only if we press F12 (developer tool) in chrome browser
- Scraping data from high charts
- High Charts Line Chart with missing data
- Having issues to make the data value in centre in pie chat using high charts
- Highcharts Highstock How to Plot OHLC and Line Charts from One Set of Embedded CSV Data Using Series Map Tools?
- Highcharts custom data for map in React TypeScript?
- Adding custom data to High Charts data export
- High Charts - Show series data of Multiple Charts
- Old draggable elements stay on high charts after turning on and off data point
- High Charts - Populating Data From Array
- High Charts windrose from API data (JSON)
- High Charts Can't hide Pie Chart data labels
- High Charts for an area-spline chart with area fill on only one data set in series
- How to combine Bar chart and data as table in High Charts
- I want to add border radius in stack graph in high charts for some particular data
More Query from same tag
- Custom Marker (Rectangle with rounded corner) for highcharts scatter graph
- Highcharts, multiple parts chart
- How to show multiple sets in a Highcharts Venn chart?
- Highcharts / Highstock stepline with integer values drawing halfsteps?
- Use MySQL data as the chart data for the cakephp highchart plugin
- How can I get every bar in different colour using Highchart?
- Monthly data in highcharts without explicitly providing all month label
- How to do Drilldown in Piechart of Highchart?
- Storing Highcharts in array issue
- React - Highcharts Full Screen black bar
- HighCharts Organization Nodes Overlapping
- Highcharts Gauge - start/endAngle and height
- highcharts display tooltip on category label hover
- How to add box shaders to plot Highcharts
- The needle in highcharts speedometer gauge is very slow to react to changes in the speed value in an animation is there a way to make it more dynamic?
- Highcharts, mixed stacked & non-stacked columns
- Issue Dynamically Changing HighCharts Chart Title
- Complicated multidimensional array to use in highchart series
- How to position the dataLabel for highcharts on the same side of the x-axis?
- "this.point.config" is not working anymore in highcharts tooltip
- can't enter django chartit formatter field
- How can i enable bootstrap tooltip in highchart
- Highchart x-axis not printing date values
- Highchart - How do I create the attached image gauge within a semicircle pie chart
- Centering a data label in Highcharts Bar Chart
- highcharts: tooltip shows for spline but not scatter plot
- Working with Highcharts using @ViewChildren
- Getting user feedback by clicking on a data point/tooltip in Highchart JS
- Why can't I click a point in an area chart if it is covered by another series?
- Dynamically update subtitle on Highcharts chart?