Articles in this section
Category / Section

How to Bind a Complex Data Collection to React Chart?

3 mins read

This article explains how to bind a complex data collection in the React Chart.

Binding a complex data collection

You can easily bind complex data to the chart by setting the enableComplexProperty property to true for the series.

In the following code example, the group.y1 value is binding to the primary y axis.

Index.js

import { createRoot } from 'react-dom/client';
import * as React from 'react';
import { ChartComponent, SeriesCollectionDirective, SeriesDirective, Inject, Category,
ColumnSeries } from '@syncfusion/ej2-react-charts';

export let data = [
   { x: 'Jan', group: { y: 70, y1: 60 } },
   { x: 'Feb', group: { y: 75, y1: 68 } },
   { x: 'Mar', group: { y: 65, y1: 60 } },
   { x: 'Apr', group: { y: 60, y1: 45 } },
   { x: 'May', group: { y: 55, y1: 50 } }
];

const Column = () => {
return (
     <chartcomponent id="charts" primaryxaxis="{{" valuetype:="" 'category',="" interval:="" 1="" }}="" primaryyaxis="{{" minimum:="" 0,="" maximum:="" 80,="" 10="">
       <inject services="{[ColumnSeries," category]}="">
       <seriescollectiondirective>
         <seriesdirective datasource="{data}" xname="x" yname="group.y1" fill="#febe17" type="Column" enablecomplexproperty="true">
       </seriesdirective></seriescollectiondirective>
     </inject></chartcomponent>
   );
};
export default Column;

const root = createRoot(document.getElementById('sample'));
root.render(<column>);

The following screenshot portrays the results of the code snippet mentioned above.

Screenshot

React chart complex data collection

View Sample in Stackblitz

Conclusion

We hope you enjoyed learning about How to bind a complex data collection to React Chart.

You can refer to our React Chart feature tour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our React Chart example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forums, BoldDesk Support, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied