File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -169,7 +169,7 @@ export const __query = Object.assign(
169
169
170
170
export async function loadDataSource ( source , mode , name ) {
171
171
switch ( mode ) {
172
- case "chart" :
172
+ case "chart" : return loadChartDataSource ( source ) ;
173
173
case "table" : return loadTableDataSource ( source , name ) ;
174
174
case "sql" : return loadSqlDataSource ( source , name ) ;
175
175
}
@@ -196,6 +196,18 @@ function sourceCache(loadSource) {
196
196
} ;
197
197
}
198
198
199
+ const loadChartDataSource = sourceCache ( async ( source ) => {
200
+ if ( source instanceof FileAttachment ) {
201
+ switch ( source . mimeType ) {
202
+ case "text/csv" : return source . csv ( { typed : true } ) ;
203
+ case "text/tab-separated-values" : return source . tsv ( { typed : true } ) ;
204
+ case "application/json" : return source . json ( ) ;
205
+ }
206
+ throw new Error ( `unsupported file type: ${ source . mimeType } ` ) ;
207
+ }
208
+ return source ;
209
+ } ) ;
210
+
199
211
const loadTableDataSource = sourceCache ( async ( source , name ) => {
200
212
if ( source instanceof FileAttachment ) {
201
213
switch ( source . mimeType ) {
You can’t perform that action at this time.
0 commit comments