apexcharts / react-apexcharts

📊 React Component for ApexCharts
https://apexcharts.com
MIT License
1.32k stars 159 forks source link

The prop series is marked as required in r, but its value is undefined. #576

Closed adityakoushikr11 closed 5 months ago

adityakoushikr11 commented 9 months ago

I am trying to render a bar chart but i am getting the following error "Failed prop type: The prop series is marked as required in r, but its value is undefined."

I am passing the following information to the chart. <Chart type="bar" options={{ chart: { type: "bar" }, series: [{ name: "My chart", data: [{ x: "Mo", y: 2 }, { x: "Tu", y: 3 }] }], colors: ["#EC6E00", "#FF961B", "#FDD08D", "#D4E3A8", "#99E48D", "#99E48D", "#99E48D"] }} />

React apexchart version installed is : 1.4.1 Apexchart version : 3.45.2 Node version : 18 React version : 18.2.0

junedchhipa commented 5 months ago

You are passing series prop inside options object when it should be outside of it and passed as a prop to <Chart>component.

The correct code should be

<Chart 
   series='[{ name: "My chart", data: [{ x: "Mo", y: 2 }, { x: "Tu", y: 3 }] }]'
   type="bar" 
   options={{
      colors: ["#EC6E00", "#FF961B", "#FDD08D", "#D4E3A8", "#99E48D", "#99E48D", "#99E48D"]
    }} 
/>