Skip to content

Commit

Permalink
patch: prevent page crash (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
tinashechiraya authored Jan 27, 2025
1 parent 2bc4c48 commit 41ff7f2
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions django_project/frontend/src/components/ChartCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,15 @@ const ChartCard: React.FC<ChartCardProps> = ({ config, className }) => {
const [newHeight, setNewHeight] = useState(cardHeight);
const [chartType, setChartType] = useState('defaultChartType');
const [dashboardName, setDashboardName] = useState('defaultDashboardName');

useEffect(() => {
if (config?.config) {
setChartType(config.config.chartType);
setDashboardName(config.config.dashboardName);
}
}, [config]);

// Check if config.chartType is "chart" or "map"
const isChart = config.config.preference === "chart";
const [isChart, setIsChart] = useState(false);

useEffect(() => {
if (config?.config) {
setChartType(config.config.chartType);
setDashboardName(config.config.dashboardName);
setIsChart(config.config.preference === "chart");
}
}, [config]);


const getChartComponent = () => {
Expand All @@ -59,15 +58,6 @@ const ChartCard: React.FC<ChartCardProps> = ({ config, className }) => {
}

try {

// switch (chartType) {
// case "bar":
// return <BarChart inputData={data[0]} />;
// case "pie":
// return <PieChart inputData={data[0]} />;
// default:
// return <LineChart inputData={data[0]} />;
// }
return <RenderResult analysis={config.analysisResults[0].analysis_results as unknown as Analysis} />
} catch (error) {
console.error("Error processing data:", error);
Expand Down

0 comments on commit 41ff7f2

Please sign in to comment.