iantukic
Posts: 16
Joined: Thu Oct 08, 2020 11:17 am

Re: Changing colors of counties programmatically in US map

Hello,

yes, that seems ok. Thank you.

I have a couple of more questions:
1. How to delete/hide counties borders? I have tried to do that by changing the color of borders to map color, but the borders are still visible slightly (see this image: https://imgur.com/DUn5vrH)

2. How to add map point to middle of the county? I was able to add map point to county by using county paths, but only to the border of the county (see this image: https://imgur.com/2CeEI5e).
iantukic
Posts: 16
Joined: Thu Oct 08, 2020 11:17 am

Re: Changing colors of counties programmatically in US map

One more question. How can I set map labels so that they span across multiple states or counties (see this example: https://imgur.com/F1lJYP0) ?

Please note that labels need to be dynamic.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Changing colors of counties programmatically in US map

Hi again!

1. In this screenshot counties' colors do not look like the map color. Maybe you did something wrong. We can set the border color to be the same as the map, or set it to transparent. We can also set borderWidth to 0.

API references:
https://api.highcharts.com/highmaps/plo ... orderColor
https://api.highcharts.com/highmaps/plo ... orderWidth
https://api.highcharts.com/highmaps/plo ... .map.color

2. The easiest way to add a point to the map is to create a new series and set its type to mappoint. There you can set coordinates of your points (using x and y properties). You only need to know what is the coordinate of a middle point of the county.

Demo:
https://jsfiddle.net/BlackLabel/pdejwx0b/

Best regards!
Dominik Chudy
Highcharts Developer
iantukic
Posts: 16
Joined: Thu Oct 08, 2020 11:17 am

Re: Changing colors of counties programmatically in US map

Hello,

1. In your demo you have set the border color to transparent and border width to 0, but state borders are still visible on the map. Is there a way to hide the borders completely?

2. How can I know the middle point of every county? Should I get that information manually for every county? If yes, that would be a problem because USA has more than 3000 counties.

Thanks.
iantukic
Posts: 16
Joined: Thu Oct 08, 2020 11:17 am

Re: Changing colors of counties programmatically in US map

Hello,

any info regarding my previous questions?


Thanks.
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Changing colors of counties programmatically in US map

Hello!

1. Sure, we can do it by setting the borderColor and color of the map to the same value, and enable borderWidth naturally.

2. I've printed the data we got from the map, and in the USA counties map there might be no coordinates of the middle point of every county.

Demo: https://jsfiddle.net/BlackLabel/y8ajts63/

Best regards!
Dominik Chudy
Highcharts Developer
iantukic
Posts: 16
Joined: Thu Oct 08, 2020 11:17 am

Re: Changing colors of counties programmatically in US map

Hello,

thank you for your answers.

Can you also answer my question about map labels (few posts above) ?
dominik.c
Posts: 2081
Joined: Fri Aug 07, 2020 7:07 am

Re: Changing colors of counties programmatically in US map

Oh, sure. Sorry I missed that one.
We can do this effect using formatter function in series.dataLabels. We only need to return the code value of a single point.

Demo: https://jsfiddle.net/BlackLabel/dp6zh7Lj/

Best regards!
Dominik Chudy
Highcharts Developer

Return to “Highcharts Maps”