Dan
Dan

Reputation: 2344

Jvectormap 1.2.2 color issue

I am using the latest Jvectormap (1.2.2) but can't find any examples of setting all the country colors. I believe in the previous version it was simply "color:", but now this has been discontinued?

The code below works but the color part doesn't. I use a white background on my site so want all the countries to have a different color by default.

 <script>
  $(function(){
        $('#world-map').vectorMap({
    map: 'world_mill_en',
    color: '#000000',
        backgroundColor: '#ffffff',
        series: {
       regions: [{
            values: {
                IN:'#33250B',
                US:'#003366'
        }
       }]
         }
     })
  });
 </script>

Upvotes: 1

Views: 2139

Answers (3)

ShadSterling
ShadSterling

Reputation: 1820

To set the default color for all regions, set regionStyle.default.fill.

Here's your code with that change:

<script>
    $(function(){
        $('#world-map').vectorMap({
            map: 'world_mill_en',
            regionStyle: { initial: { fill: '#000000' } },  //Changed this line
            backgroundColor: '#ffffff',
            series: {
                regions: [{
                    values: {
                        IN:'#33250B',
                        US:'#003366'
                    }
                }]
            }
        })
    });
</script>

Upvotes: 0

user1278673
user1278673

Reputation:

i am not quiet sure what you mean, but to set all the countries colors you could use:

var regionStyling = {initial: {fill: '#128da7'},hover: {fill: "#A0D1DC"}};

jQuery('#world-map').vectorMap({
    map: 'world_mill_en',
    normalizeFunction: 'polynomial',
    regionStyle:regionStyling,
    backgroundColor: '#383f47',
    series: {regions: [{values: {},attribute: 'fill'}]}
});

this works for me, also if you want to specify per country you could use:

 jQuery('#world-map').vectorMap({
    map: 'world_mill_en',
    normalizeFunction: 'polynomial',
    backgroundColor: '#383f47',
    series: {regions: [{values: {"US" : "#000"},attribute: 'fill'}]}
});

Upvotes: 3

bjornd
bjornd

Reputation: 22943

In the 1.x.x branch of jVectorMap desired functionality could be achieved by using regionStyle configuration parameter. See more in the documentation here.

Upvotes: 1

Related Questions