Skip to content

Conversation

@jacobp100
Copy link
Contributor

React API experiment

Implements both the API and example generation to do this:-

 const ChartExample = () => {
   const [options, setOptions] = useState({
     // Data: Data to be displayed in the chart
     data: [
       { month: "Jan", avgTemp: 2.3, iceCreamSales: 162000 },
       { month: "Mar", avgTemp: 6.3, iceCreamSales: 302000 },
       { month: "May", avgTemp: 16.2, iceCreamSales: 800000 },
       { month: "Jul", avgTemp: 22.8, iceCreamSales: 1254000 },
       { month: "Sep", avgTemp: 14.5, iceCreamSales: 950000 },
       { month: "Nov", avgTemp: 8.9, iceCreamSales: 200000 },
     ],
     // Series: Defines which chart type and data to use
     series: [{ type: "bar", xKey: "month", yKey: "iceCreamSales" }],
   });
 
-  return <AgCharts options={options} />;
+  return <AgCharts data={options.data} series={options.series} />;
 };

A more idiomatic usage would be this

https://plnkr.co/edit/EVxOsM4IFk8R8mSC?open=index.jsx

This is backwards compatible - you can still pass options if you wish

Longer term we may wish to consider an additional single series API

<AgBarChart
  data={data}
  xKey="month"
  yKey="iceCreamSales"
/>

However, we need to ensure top-level options never conflict with series options - e.g. title exists both on the pie series options and top-level options

@jacobp100 jacobp100 requested a review from a team as a code owner August 7, 2025 14:32
@jacobp100 jacobp100 marked this pull request as draft August 7, 2025 14:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants