У меня есть карта мира на Vega 2.6.5 со следующей конфигурацией, основанная на примере демонстрации airports и примера карты со следующей конфигурацией:
{
width: 900,
height: 560,
padding: {top: 0, left: 100, right: 100, bottom: 0},
data: [
{
name: 'world',
url: 'app/common/libs/charts/chartsData/world-110m.json',
format: { type: 'topojson', feature: 'countries' },
transform: [
{
type: 'geopath',
projection: 'mercator',
scale: 140,
translate: [450,280]
}
]
},
{
name: 'countriesLocation',
url: 'app/common/libs/charts/chartsData/countries.csv',
format: { type: 'csv', parse: 'auto' },
transform: [
{
type: 'geo',
projection: 'mercator',
scale: 140,
translate: [450,280],
lon: 'longitude',
lat: 'latitude'
},
{
type: 'filter',
test: 'datum.layout_x != null && datum.layout_y != null'
}
]
}
],
scales: [],
signals: [
{
name: 'hover',
init: null,
streams: [
{ type: 'symbol:mouseover', expr: 'datum' },
{ type: 'symbol:mouseout', expr: 'null' }
]
},
{
name: 'title',
init: 'Our partners around the world',
streams: [
{
type: 'hover',
expr: 'hover ? hover.name + " ("+ hover.country +")" : "Our partners around the world"'
}
]
}
],
marks: [
{
type: 'path',
from: { data: 'world' },
properties: {
enter: {
path: { field: 'layout_path' },
fill: { value: '#dedede' },
stroke: { value: '#ffffff' }
},
update: { fill: { value: '#dedede' } },
hover: { fill: { value: '#37A3DC' } }
}
},
{
type: 'symbol',
from: { data: 'countriesLocation' },
properties: {
enter: {
x: { field: 'layout_x' },
y: { field: 'layout_y' },
size: { value: 16 },
fill: { value: 'steelblue' },
fillOpacity: { value: 0.8 },
stroke: { value: '#ffffff' },
strokeWidth: { value: 0.5 }
}
}
},
{
type: 'text',
interactive: false,
properties: {
enter: {
x: { value: 500 },
y: { value: 500 },
fill: { value: '#000000' },
fontSize: { value: 20 },
align: { value: 'right' }
},
update: {
text: { signal: 'title' }
}
}
}
]
}
И я получаю следующий результат:
![World map with symbols for each country](https://i.stack.imgur.com/LDhKG.png)
Поведение до сих пор такое, когда я наводю страну на заполнениеменяет цвет, но не отображает название страны, и когда я наведите курсор на символ (синяя точка на каждой стране), заливка будет потеряна, но отобразится название страны.
Как можноЯ отображаю название страны, не теряя заполнения, когда я наведите курсор на каждую страну?