···3535 const atprotoBorderColor = 'rgba(0, 51, 102, 1)';
36363737 useEffect(() => {
3838- // Only generate chart data if we have records and we're not loading
3939- if (records && records.length > 0 && !loading) {
3838+ // Generate chart data whenever records change or time period changes
3939+ // Don't wait for loading to be false - this ensures we regenerate as soon as we get new data
4040+ if (records && records.length > 0) {
4041 console.log(`Generating chart data for ${records.length} records with period ${timePeriod}`);
4142 generateChartData(records, timePeriod);
4343+ } else if (!loading) {
4444+ // If we have no records and we're not loading, reset chart data
4545+ setChartData({
4646+ labels: [],
4747+ datasets: []
4848+ });
4249 }
4343- }, [records, timePeriod, loading]);
5050+ }, [records, timePeriod]);
44514552 // Function to generate data for the chart based on selected time period
4653 const generateChartData = (allRecords, period) => {