自定义工具提示JQVMap [英] Custom Tooltips JQVMap

查看:72
本文介绍了自定义工具提示JQVMap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个JQVMap,当前正在可视化一些数据.地图上的每个国家/地区都是特定的颜色,并且具有从0-10的特定数字.

I have a JQVMap that is currenting visualizing some data. Each country on the map is a specific color and has a specific number from 0-10.

我知道如何显示默认工具提示,只需将showTooltip切换为true,它就会显示国家/地区名称onmouseover.如何在这些工具提示上显示与每个国家/地区相对应的数字?

I know how to show default tooltips, you simply switch the showTooltip to true, and it shows the country names onmouseover. How can I also show the number corresponding to each country on these tooltips?

谢谢.

推荐答案

onLabelShow有一个事件.从文档中...

there is an event for onLabelShow. From the documentation...

onLabelShow 函数(事件,标签,代码)

onLabelShow function(event, label, code)

将在显示标签之前调用的回调函数.标签 DOM对象和国家/地区代码将作为 争论.

Callback function which will be called before label is shown. Label DOM object and country code will be passed to the callback as arguments.

也许这样对您有用?

$(document).ready(function () {
            jQuery('#vmap').vectorMap({
                map: 'usa_en',
                selectedRegion: 'co',
                backgroundColor: '#ffffff',
                color: '#E6E7E9',
                hoverColor: '#03235E',
                enableZoom: false,
                showTooltip: true,
                onLabelShow: function(event, label, code) {
                    if (states.toLowerCase().indexOf(code) <= -1) {
                        event.preventDefault();
                    } else if (label[0].innerHTML == "Colorado") {
                        label[0].innerHTML = label[0].innerHTML + " - The state where I live!!";
                    }
                },                
            });
        });

这篇关于自定义工具提示JQVMap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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