Custom Tooltips JQVMap

廉价感情. 提交于 2019-12-06 06:54:48

问题


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.

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?

Thanks.


回答1:


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

onLabelShow function(event, label, code)

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

Maybe something like this could work for you?

$(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!!";
                    }
                },                
            });
        });


来源:https://stackoverflow.com/questions/15723444/custom-tooltips-jqvmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!