AG Charts pie chart is not shown correctly #841
-
ProblemAG Charts pie chart is not shown correctly in localhost environment, but not in Vercel deployment. Screenshots: Localhost: Vercel: Code for filter function and Chartfilter: function getCategoryTotalAmount(category) { const data = filter.categories.map((category) => ({ Chart: import { AgChartsReact } from "ag-charts-react"; export function PieChart({ chartData }) { return ( Link to repoFor a better overview see our budget-app repo here (branch redesign-report-page): https://github.com/benediktbrenk/budget-app/tree/redesign-report-page |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I am not sure what the answer is. But there a couple of things that might be worth trying. There is currently a warning in the console. AG Charts - unable to set [label] in dJ - property is unknown It might be worth looking closer at options object, and comparing that to what the documentation expects. Also, I don't think we need to have a import { AgChartsReact } from "ag-charts-react";
import * as Styled from "./PieChart.styled";
export function PieChart({ chartData }) {
// We directly derive chartOptions from chartData without using useState.
const chartOptions = {
legend: { enabled: false },
series: [
{
type: "pie",
angleKey: "amount",
calloutLabelKey: "category",
calloutLabel: { enabled: true },
label: {
fontSize: 8,
},
calloutLine: {
colors: chartData.map((category) => category.color),
},
fills: chartData.map((category) => category.color),
},
],
data: chartData,
};
return (
<Styled.PieContainer>
<AgChartsReact options={chartOptions} />
</Styled.PieContainer>
);
} |
Beta Was this translation helpful? Give feedback.
I am not sure what the answer is. But there a couple of things that might be worth trying.
There is currently a warning in the console.
It might be worth looking closer at options object, and comparing that to what the documentation expects.
Also, I don't think we need to have a
useEffect
here. Instead we could use derived state.