Tooltips

How to customize and use tooltips in Nuxt Charts.

Tooltip Padding Change in v0.2.0

Warning! Upgrading to v0.2.0 will cause tooltips to have double padding. To prevent this, disable global padding. Default tooltips will retain their previous padding.
assets/css/main.css
:root {
  --vis-tooltip-padding: 0 !important;
}

This gives you full control over tooltip customization.

Custom Tooltip Example

You can provide a custom tooltip by using the tooltip slot:

AreaChart.vue
<AreaChart>
  <template #tooltip="{ values }">
    <CustomTooltip :values="values" />
  </template>
</AreaChart>

Full Example

AreaChart.vue
<script setup lang="ts">
const data = [
  { month: 'Jan', value: 75 },
  { month: 'Feb', value: 120 },
  { month: 'Mar', value: 180 },
  { month: 'Apr', value: 110 },
  { month: 'May', value: 90 },
  { month: 'Jun', value: 130 },
]

const categories = {
  value: {
    name: 'Desktop',
    color: '#3b82f6',
  },
}

const xFormatter = (i: number) => data[i].month
</script>

<template>
  <AreaChart
    :data="data"
    :categories="categories"
    :height="260"
    :xFormatter="xFormatter"
    xLabel="Month"
    yLabel="Value"
  >
    <template #tooltip="{ values }">
      <CustomTooltip :values="values" />
    </template>
  </AreaChart>
</template>

Custom Tooltip Component Example

Here’s a simple custom tooltip component you can use:

Use this component in your chart’s tooltip slot as shown above.