kadoshms / react-jvectormap

A react wrapper for jvectormap maps
MIT License
98 stars 70 forks source link

Set hover color only to countries where data is available #62

Closed Gunner17 closed 2 years ago

Gunner17 commented 4 years ago

I want to add a fill color on hover of only those countries, which are being filled with yellow on the map (since those are the only countries whose data have been passed to the map). But if I add fill inside hover, like below:

regionStyle={{
    ...
    hover: {
        ...
        fill: '#DA7135', // applies to all regions
    },
}}

the fill color applies to all the regions on hover and not specifically to the yellow ones. How can I achieve applying selective hover color in this setup?

TLDR: Hover color should show only on the yellow-ish regions, not on the grey ones.

Screen Shot 2020-04-29 at 4 32 55 PM
kadoshms commented 2 years ago

Hey! this is a great suggestion and it will be part of 1.0.0. Please see commits: https://github.com/kadoshms/react-jvectormap/commit/23a3135a1e65ded1c187d27471cbc1ce4715d078

kadoshms commented 2 years ago

Long story short, version 1.0.0 will allow passing regionStyle as a function:

  regionStyle: (code) => ({
    initial: {
      fill: initial[code],
    },
    hover: {
      fill: hover[code],
    },
  })