Skip to content
Source
Sign inSign up
TanStack/react-charts

Data is not correctly displayed when stacked #333

Opencedricdelpoux(GitHub profile, opens in a new tab) opened this issue 1 comment
Screenshot 2022-12-17 at 06 18 17
const data = [
    {
      label: "Data 1",
      data: [
        {
          date: "01",
          kilometers: 10,
        },
        {
          date: "03",
          kilometers: 9,
        },
      ],
    },
    {
      label: "Data 2",
      data: [
        {
          date: "01",
          kilometers: 70,
        },
        {
          date: "02",
          kilometers: 50,
        },
        {
          date: "04",
          kilometers: 100,
        },
      ],
    },
  ]
  
  const primaryAxis = React.useMemo(
    () => ({
      getValue: (datum) => datum.date,
    }),
    []
  )

  const secondaryAxes = React.useMemo(
    () => [
      {
        getValue: (datum) => datum.kilometers,
        elementType: "bar",
        stacked: true,
      },
    ],
    []
  )
  
<Chart
  options={{
    data,
    primaryAxis,
    secondaryAxes,
/>
  1. Tushar2098(GitHub profile, opens in a new tab)commented

    I'm too facing same issue..it would be good if someone can look into it


    image

Sign in to join this conversation.