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(
169169
170170export async function loadDataSource ( source , mode , name ) {
171171 switch ( mode ) {
172- case "chart" :
172+ case "chart" : return loadChartDataSource ( source ) ;
173173 case "table" : return loadTableDataSource ( source , name ) ;
174174 case "sql" : return loadSqlDataSource ( source , name ) ;
175175 }
@@ -196,6 +196,18 @@ function sourceCache(loadSource) {
196196 } ;
197197}
198198
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+
199211const loadTableDataSource = sourceCache ( async ( source , name ) => {
200212 if ( source instanceof FileAttachment ) {
201213 switch ( source . mimeType ) {
You can’t perform that action at this time.
0 commit comments