chartjs-chart-geo icon indicating copy to clipboard operation
chartjs-chart-geo copied to clipboard

Wrong tooltip position

Open evgenoid opened this issue 6 months ago • 3 comments

When I try to load page where the map presents and try to hover some country, tooltip displays in wrong position.

To Reproduce

  1. Just load the page where the map is presented. Reproduces sometimes.

Expected behavior

Tooltip should be displayed near the country

Screenshots

Screenshot 2024-08-30 at 10 05 52 Screenshot 2024-08-30 at 10 06 11

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,
          },
        },
      }}
    />

evgenoid avatar Aug 30 '24 07:08 evgenoid