<template>
<h3>Default</h3>
<b-bar-chart :chart-data="chartData" :chart-options="defaultChartOptions" />
<h3 class="mt-4">Horizontal</h3>
<b-bar-chart
:chart-data="chartData"
:chart-options="chartHorizontalOptions"
/>
<h3 class="mt-4">Stacked</h3>
<b-bar-chart :chart-data="chartData" :chart-options="chartStackedOptions" />
<h3 class="mt-4">Horizontal Stacked</h3>
<b-bar-chart :chart-data="chartData" :chart-options="chartHStackedOptions" />
<h3 class="mt-4">Gradient</h3>
<b-bar-chart :chart-data="chartData" :chart-options="chartGradientOptions" />
<h3 class="mt-4">Gradient Stacked</h3>
<b-bar-chart
:chart-data="chartData"
:chart-options="chartGradientStackedOptions"
/>
</template>
<script lang="ts" setup>
import { ref } from 'vue'
import { ChartUtils } from 'bigin-ui'
import type { ChartOptions } from 'chart.js'
const chartData = ref({
labels: ['Spring', 'Summer', 'Fall', 'Winter'],
datasets: [
{
label: 'Dog',
data: [40, 20, 12, 25],
},
{
label: 'Cat',
data: [12, 39, 10, 40],
},
{
label: 'Others',
data: [22, 12, 30, 8],
},
],
})
const defaultChartOptions: ChartOptions = {}
const chartHorizontalOptions = {
indexAxis: 'y',
}
const chartStackedOptions = {
barPercentage: 0.5,
elements: {
bar: {
borderSkipped: 'middle',
},
},
scales: {
x: {
stacked: true,
},
y: {
stacked: true,
},
},
}
const chartHStackedOptions = {
indexAxis: 'y',
barPercentage: 0.5,
scales: {
x: {
stacked: true,
},
y: {
stacked: true,
},
},
}
const chartGradientOptions = {
elements: {
bar: {
backgroundColor: ChartUtils.gradientColors,
},
},
}
const chartGradientStackedOptions = {
barPercentage: 0.3,
elements: {
bar: {
backgroundColor: ChartUtils.gradientColors,
},
},
scales: {
x: {
stacked: true,
},
y: {
stacked: true,
},
},
}
</script>