ghalex / vue3-charts

Vue3-Charts is an SVG-based charting library that is very easy to use and highly customizable
https://vue3charts.org
MIT License
142 stars 23 forks source link

Stacked Bar chart #20

Closed PMLS3 closed 2 years ago

PMLS3 commented 2 years ago

Is there an example of a stacked bar chart somewhere? Thanks in advance

ghalex commented 2 years ago

Hi @PMLS3,

You need to use <Group /> component:

<Chart
  <Chart
  :size="{ width, height: 400 }"
  :data="data"
  :axis="axis"
  :margin="margin"
  :direction="direction"
>
  <template #layers>
    <Grid strokeDasharray="2,2" :center="false" />
    <Group :stacked="true">
      <Bar :dataKeys="['name', 'pl']" :barStyle="{ fill: 'red' }" />
      <Bar :dataKeys="['name', 'avg']" :barStyle="{ fill: 'blue' }" />
    </Group>
  </template>
  <template #widgets>
    <Tooltip
      hideLine
      :config="{
        name: { hide: true },
        inc: { hide: true },
        pl: { color: '#0077b6' },
        avg: { label: 'averange', color: '#0096c7' }
      }"
    />
  </template>
</Chart>
PMLS3 commented 2 years ago

Appreciate

mberneis commented 1 year ago

Bars disappear for me when I use the Group component (Yes, I imported it and added it to the components definition)

rbrugo commented 6 months ago

Same here, any solution?