gpt4 book ai didi

jquery - 更多与 onRegionLabelShow 一起使用的选项 : function with jVectormap

转载 作者:行者123 更新时间:2023-12-01 04:51:03 24 4
gpt4 key购买 nike

我到处寻找这个问题的答案,但由于我对 jQuery 的了解仍然几乎不存在,我不确定我是否在寻找正确的问题。我希望这里有人能够给我一些帮助。

我正在使用 jvectormap 创建 map 并将其构建在 http://www.roosteromg.com/sandbox/map2 。我成功地根据政党为每个翻转状态创建了不同的颜色,但我需要能够根据翻转的状态向“显示”标签添加几行文本。

例如:如果您将鼠标悬停在宾夕法尼亚州,它当前会使用 onRegionLabelShow: function(event, label, code){ label.html( ''+label.html()) 显示州名称>,但我需要在州名后面添加两行纯文本。

如果像我需要的那样工作,滚动时的状态将如下所示:

宾夕法尼亚州
参议员约翰·多伊 (R) - 投赞成票
Sen Jane Doe (D) - 投了反对票

预先感谢您的帮助。

查尔斯·史密斯

最佳答案

基本上,您需要的是一个定义,其中包含以 'stateCode': 'text' 形式显示每个状态的文本。

var labels = {
'US-AL': 'Sen. John Doe (R) - Voted Yes<br/>Sen Jane Doe (D) - Voted No',
'US-AK': 'Some other text, you can make use of html tags'
};

为了能够显示附加到状态的自定义文本,您需要稍微修改 onRegionLabelShow 函数。

onRegionLabelShow: function(event, label, code){
if (!labels.hasOwnProperty(code)) {
// no text found, return standard state name
return true;
}

// construct label for state with extra text
label.html(
'<strong>' + label.html() + '</strong><br/>' + labels[code]
);
}

关于jquery - 更多与 onRegionLabelShow 一起使用的选项 : function with jVectormap,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20013134/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com