On this page

Chart

Install, props and the parts Chart is built from.

Install

Run this in the app, after shadcn-vue init and the Beehexa theme (Button › Code):

npx shadcn-vue@latest add https://beehexa.design/r/chart.json

Use

Put the plot and the legend inside ChartContainer. Series colours are available inside as var(--color-<key>). Mark your own plot element with data-chart-plot to give it the chart height.

<script setup lang="ts">
import type { ChartConfig } from '@/components/ui/chart'
import { ChartContainer, ChartLegendContent } from '@/components/ui/chart'

const config = {
  completed: { label: 'Completed', color: 'var(--bh-visualization-metric-completed)' },
} satisfies ChartConfig
</script>

<template>
  <ChartContainer :config="config">
    <div data-chart-plot>
      <!-- your SVG: stroke var(--color-completed), stroke-width var(--bh-visualization-line-width) -->
    </div>
    <ChartLegendContent />
  </ChartContainer>
</template>

With Unovis, place VisXYContainer inside the container and import VisCrosshair and VisTooltip from @unovis/vue. Pass componentToString(config, ChartTooltipContent) as the tooltip template.

Props

Part Prop Values Notes
ChartContainer config ChartConfig One entry per series: label, icon, and color or theme ({ light, dark })
ChartContainer cursor boolean Shows the Unovis crosshair line at visualization.grid-width
ChartContainer id string Names the data-chart scope; generated when left out
ChartLegendContent verticalAlign bottom (default), top Space goes on the side next to the plot
ChartLegendContent nameKey string Key to read the names from
ChartTooltipContent payload, config object The values at one point and the chart config
ChartTooltipContent indicator dot (default), line, dashed The mark beside each value
ChartTooltipContent hideLabel, hideIndicator boolean
ChartTooltipContent labelKey, labelFormatter, x The heading of the tooltip

Built on

The shadcn-vue Chart. Beehexa changes the styles, writes the dark theme values for data-theme="dark" and for the system dark mode, and shows a value of 0 in the tooltip (shadcn hid it). The --vis-* variables give Beehexa roles to an Unovis chart.

Limitations

  • ChartCrosshair and ChartTooltip are not re-exported: import them from @unovis/vue, which this site does not install.
  • There is no general categorical colour set yet; only the visualization.* roles.