jvectormap区域颜色 [英] jvectormap region colors

查看:115
本文介绍了jvectormap区域颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 jvectormap插件,我正在尝试设置地图上每个区域的颜色。但是,在应用下面的代码后,将显示地图,但不应用任何颜色。它只显示白色的地图。

Im using the jvectormap plugin, and I am trying to set the colors of each of the regions on the map. However, after applying the code below the map is displayed but with no colours applied. It just shows the map in white.

我已经阅读了有关此问题的多个示例和问题,但我似乎无法让它为我工作。

I have read multiple examples and questions on this matter, but I cant seem to get it to work for me.

示例1 ,在地图上设置随机颜色。

Example 1 of setting random colours on a map.

文档

类似的问题,但它并没有解决我的问题。

Similar question to mine, however it doesn't solve my problem.

jQuery('#mapDiv').vectorMap({
    map: 'au_merc_en',
    backgroundColor: 'none',
    colors: {
        AU-SA: '#4E7387',
        AU-WA:'#333333',
        AU-VIC:'#89AFBF',
        AU-TAS:'#817F8E',
        AU-QLD:'#344B5E',
        AU-NSW:'#344B5E',
        AU-ACT:'#344B5E',
        AU-NT:'#344B5E'

    },
    series: {
      regions: 
      [{
        attribute: 'fill'
      }]
    }
});

有人能看到问题吗?

推荐答案

以下是我认为你试图做的工作样本。

Here is a working sample of what I think you're attempting to do.

http://jsfiddle.net/3xZ28/34/

(function() {
    var myCustomColors = {
        'AU-SA': '#4E7387',
        'AU-WA': '#333333',
        'AU-VIC': '#89AFBF',
        'AU-TAS': '#817F8E',
        'AU-QLD': '#344B5E',
        'AU-NSW': '#344B5E',
        'AU-ACT': '#344B5E',
        'AU-NT': '#344B5E'
    };

    map = new jvm.WorldMap({
        map: 'au_merc_en',
        container: $('#ausie'),
        backgroundColor: '#eff7ff',
        series: {
            regions: [{
                attribute: 'fill'
            }]
        }
    });

    map.series.regions[0].setValues(myCustomColors);
})();

此示例基于jvectormap网站上的两个示例:

1。 http://jvectormap.com/maps/countries/australia/

2. http://jvectormap.com/examples/random-colors/

This example builds off of two examples on the jvectormap site:
1. http://jvectormap.com/maps/countries/australia/
2. http://jvectormap.com/examples/random-colors/

小提琴包含来自网站的jvectormap 1.1文件。另请注意,网站上的随机颜色示例使用jvm。 WorldMap

The fiddle includes the jvectormap 1.1 file from the site. Also note the Random Colors example on the site uses jvm.WorldMap.

这篇关于jvectormap区域颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆