Skip to content

Commit 2e7d9be

Browse files
committed
fix: load sample data by default
1 parent 050d1f5 commit 2e7d9be

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

classes/Visualizer/ChartBuilder/src/AIBuilder/DataSource.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,17 @@ export default function DataSource( { chartId, uploadNonce, onDataReady, dataLoa
109109
const [ loading, setLoading ] = useState( false );
110110
const [ error, setError ] = useState( null );
111111

112-
// Manual
113-
const [ csvText, setCsvText ] = useState( '' );
114-
const [ sheetRows, setSheetRows ] = useState( [] );
112+
// Manual — pre-load sample data for new charts (no initialCsvText means no existing data).
113+
const [ csvText, setCsvText ] = useState( initialCsvText ? '' : SAMPLE_CSV );
114+
const [ sheetRows, setSheetRows ] = useState( initialCsvText ? [] : csvToGrid( SAMPLE_CSV ) );
115115
const sheetEditRef = useRef( false );
116116
const sheetHotRef = useRef( null );
117117

118118
// File
119119
const [ file, setFile ] = useState( null );
120120
const fileInputRef = useRef( null );
121-
const skipUploadRef = useRef( false );
121+
// Skip the initial auto-upload when pre-loading sample data for a new chart.
122+
const skipUploadRef = useRef( ! initialCsvText );
122123

123124
// URL
124125
const [ fileUrl, setFileUrl ] = useState( '' );

0 commit comments

Comments
 (0)