chartjs-chart-geo
chartjs-chart-geo copied to clipboard
Wrong tooltip position
When I try to load page where the map presents and try to hover some country, tooltip displays in wrong position.
To Reproduce
- Just load the page where the map is presented. Reproduces sometimes.
Expected behavior
Tooltip should be displayed near the country
Screenshots
Context
- Version: 4.3.1
- Browser: Google Chrome Version 127.0.6533.120 (Official Build) (arm64)
Additional context
List of countries from: https://unpkg.com/world-atlas/countries-50m.json
Configuretion:
<Chart
ref={chartRef}
type="choropleth"
data={{
labels: countries.map((d: any) => d.properties.name),
datasets: [
{
label: 'Countries',
data: countries.map((d) => ({ feature: d })),
backgroundColor: (context) =>
isRegionOrContryWise?.includes((context.raw as any)?.feature?.properties?.name)
? themePalette.palette.primary700
: themePalette.tokens.surfaceBadgesFillDefault,
},
],
}}
options={{
plugins: {
tooltip: {
backgroundColor: themePalette.palette.primary950_40,
displayColors: false,
filter: (context) => isRegionOrContryWise?.includes((context.raw as any)?.feature?.properties?.name),
callbacks: {
label: (context: any) => context.element.feature.properties.name,
},
},
legend: {
display: false,
},
},
scales: {
projection: {
axis: 'y',
projection: 'naturalEarth1',
},
color: {
axis: 'x',
display: false,
quantize: 5,
},
},
}}
/>