gpt4 book ai didi

javascript - 有没有办法使用 "fill"和 "stroke"作为区域比例颜色的属性?

转载 作者:行者123 更新时间:2023-11-29 22:19:15 25 4
gpt4 key购买 nike

我正在使用 jVectorMap v1.1,并且我有这段相关的代码:

var america = "#d84148";
var europe = "#0060d0";
var africa = "#44984d";
var asia = "#e3a430";
var oceania = "#2ecdd0";

series: {
regions: [{
values: data['colours'],
scale: {
"America" : america,
"Europe" : europe,
"Africa" : africa,
"Asia" : asia,
"Oceania" : oceania
},
normalizeFunction: 'linear',
attribute: 'fill'
}]
}

我得到的矢量数据是来自 naturalearth.com 的 world_mill_en,它包含每个国家 1px 的分隔,作为该国的边界。我正在构建的应用程序必须显示整个大陆,因此不允许有边界。

关于 attribute我只能设置 fillstroke作为参数,我可以在使用 fill 时为边框设置纯色.

我想知道是否可以使用 fillstroke同时作为属性。或者,如果有一种方法可以将区域的笔划设置为与其各自区域具有相同的颜色。 IE。

if (stroke == "none") 
{
stroke = "that region's colour"
}

最佳答案

在搜索各种示例后,我在这个链接中找到了我的解决方案:

https://github.com/bjornd/jvectormap/blob/master/tests/markers.html

我需要做的就是:

var america = "#d84148";
var europe = "#0060d0";
var africa = "#44984d";
var asia = "#e3a430";
var oceania = "#2ecdd0";

series: {
regions: [{
values: data['colours'],
scale: {
"America" : america,
"Europe" : europe,
"Africa" : africa,
"Asia" : asia,
"Oceania" : oceania
},
normalizeFunction: 'linear',
attribute: 'fill'
}, {
values: data['colours'],
scale: {
"America" : america,
"Europe" : europe,
"Africa" : africa,
"Asia" : asia,
"Oceania" : oceania
},
normalizeFunction: 'linear',
attribute: 'stroke'
}]
}

就这样,问题解决了。复制区域数组内的整个部分,包括大括号,将填充更改为描边。

关于javascript - 有没有办法使用 "fill"和 "stroke"作为区域比例颜色的属性?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13344196/

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