fix: protect ECharts setOption from invalid data + add import debug logs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
hailin 2026-04-05 02:24:25 -07:00
parent 9b218a487a
commit b7edc7f86e
2 changed files with 9 additions and 4 deletions

View File

@ -53,8 +53,12 @@ export const EChartsBase: React.FC<EChartsBaseProps> = ({
// Update option // Update option
useEffect(() => { useEffect(() => {
if (!chartRef.current) return; if (!chartRef.current || !option) return;
try {
chartRef.current.setOption(option, { notMerge: true }); chartRef.current.setOption(option, { notMerge: true });
} catch (e) {
console.warn('ECharts setOption error:', e);
}
}, [option]); }, [option]);
// Handle loading state // Handle loading state

View File

@ -60,8 +60,9 @@ export function useImportData() {
try { try {
const rowsResp = await dataServiceClient.getRows(dataSetId, 10000); const rowsResp = await dataServiceClient.getRows(dataSetId, 10000);
rows = rowsResp.rows ?? rowsResp ?? []; rows = rowsResp.rows ?? rowsResp ?? [];
} catch { console.log(`[DataViz] Fetched ${rows.length} rows for dataset ${dataSetId}`);
// rows fetch failed, continue without } catch (e) {
console.error('[DataViz] Failed to fetch rows:', e);
} }
const dataSet = mapBackendDataSet(rawDataSet, rows); const dataSet = mapBackendDataSet(rawDataSet, rows);