Gráficos e métricas
VBarChart
Gráfico de barras verticais leve (sem dependências) para tendências curtas — barras em cápsula com destaque na barra ativa, como no hero do Clawback.
<script setup lang="ts">
import { VBarChart } from 'vueui-nova-kit'
</script>Uso
<VBarChart :data="months" v-model:active="month" interactive />Playground
Os controles abaixo são gerados a partir das props declaradas em VBarChart.types.ts; o código acompanha cada mudança.
Exemplos
Variantes, tamanhos e estados, extraídos das stories da biblioteca.
Default
Variação Padrão. Destaca a última barra.
Ver código
<script setup lang="ts">
import { VBarChart } from 'vueui-nova-kit'
const data = [
{ label: 'Jan', value: 22, display: '$22K' },
{ label: 'Feb', value: 26, display: '$26K' },
{ label: 'Mar', value: 24, display: '$24K' },
{ label: 'Apr', value: 31, display: '$31K' },
{ label: 'May', value: 35, display: '$35K' },
{ label: 'Jun', value: 40, display: '$40K' },
{ label: 'Jul', value: 46, display: '$46K' },
{ label: 'Aug', value: 58, display: '$58K' },
{ label: 'Sep', value: 84.6, display: '$84.6K' },
]
</script>
<template>
<VBarChart :data="data" />
</template>Interactive
Variação Interativa com v-model:active: clique/foque uma barra.
Ver código
<script setup lang="ts">
import { ref } from 'vue'
import { VBarChart } from 'vueui-nova-kit'
const args = {
data: [
{
label: 'Jan',
value: 22,
display: '$22K'
},
{
label: 'Feb',
value: 26,
display: '$26K'
},
{
label: 'Mar',
value: 24,
display: '$24K'
},
{
label: 'Apr',
value: 31,
display: '$31K'
},
{
label: 'May',
value: 35,
display: '$35K'
},
{
label: 'Jun',
value: 40,
display: '$40K'
},
{
label: 'Jul',
value: 46,
display: '$46K'
},
{
label: 'Aug',
value: 58,
display: '$58K'
},
{
label: 'Sep',
value: 84.6,
display: '$84.6K'
}
],
height: 120,
variant: 'pill',
tone: 'primary',
showValue: 'active',
showLabels: true,
interactive: false
}
const active = ref(8)
</script>
<template>
<div>
<VBarChart v-bind="args" v-model:active="active" interactive />
<p style="margin-top:12px;font:12px var(--v-font-family-sans);color:var(--v-color-text-muted)">Ativo: {{ args.data[active]?.label }}</p>
</div>
</template>Inverse On Gradient
Variação Inverse sobre gradiente (hero do Clawback/Carrier).
Ver código
<script setup lang="ts">
import { VBarChart } from 'vueui-nova-kit'
const args = {
data: [
{
label: 'Jan',
value: 22,
display: '$22K'
},
{
label: 'Feb',
value: 26,
display: '$26K'
},
{
label: 'Mar',
value: 24,
display: '$24K'
},
{
label: 'Apr',
value: 31,
display: '$31K'
},
{
label: 'May',
value: 35,
display: '$35K'
},
{
label: 'Jun',
value: 40,
display: '$40K'
},
{
label: 'Jul',
value: 46,
display: '$46K'
},
{
label: 'Aug',
value: 58,
display: '$58K'
},
{
label: 'Sep',
value: 84.6,
display: '$84.6K'
}
],
height: 120,
variant: 'pill',
tone: 'inverse',
showValue: 'active',
showLabels: true,
interactive: false
}
</script>
<template>
<div style="padding:24px;border-radius:20px;background:linear-gradient(135deg,#c7d7fe,#7aa2f7);">
<VBarChart v-bind="args" />
</div>
</template>Solid Neutral
Variação Sólida neutra com todos os valores.
Ver código
<script setup lang="ts">
import { VBarChart } from 'vueui-nova-kit'
const data = [
{ label: 'Apr', value: 31, display: '$31K' },
{ label: 'May', value: 35, display: '$35K' },
{ label: 'Jun', value: 40, display: '$40K' },
{ label: 'Jul', value: 46, display: '$46K' },
{ label: 'Aug', value: 58, display: '$58K' },
{ label: 'Sep', value: 84.6, display: '$84.6K' },
]
</script>
<template>
<VBarChart
:data="data"
:height="100"
variant="solid"
tone="neutral"
show-value="all" />
</template>Props
| Prop | Tipo | Default | Descrição |
|---|---|---|---|
data | VBarChartDatum[] | — | — |
active | number | undefined | Index of the emphasized bar (`v-model:active`). Defaults to the last bar; `-1` emphasizes none. |
height | number | 120 | Plot height in px (labels excluded). |
variant | VBarChartVariant | "pill" | — |
tone | VBarChartTone | "primary" | — |
showValue | VBarChartValueMode | "active" | Which bars show their value above them. |
showLabels | boolean | true | — |
interactive | boolean | false | Bars become buttons that set `active` on click/focus. |
max | number | — | — |
ariaLabel | string | — | — |
dataTestId | string | — | — |
Events
| Evento | Payload | Descrição |
|---|---|---|
@update:active | index: number | — |
@select | datum: VBarChartDatum, index: number | — |
Slots
Sem slots.
Fonte: src/components/data/VBarChart/VBarChart.vue · tipos: src/components/data/VBarChart/VBarChart.types.ts