(dataFile)
| 16026 | parcelHelpers.export(exports, "loadDataArray", ()=>loadDataArray); |
| 16027 | var _sanddanceReact = require("@msrvida/sanddance-react"); |
| 16028 | const loadDataFile = (dataFile)=>new Promise((resolve, reject)=>{ |
| 16029 | const vega = (0, _sanddanceReact.SandDance).VegaDeckGl.base.vega; |
| 16030 | const loader = vega.loader(); |
| 16031 | function handleRawText(text) { |
| 16032 | let data; |
| 16033 | try { |
| 16034 | data = vega.read(text, { |
| 16035 | type: dataFile.type, |
| 16036 | parse: {} |
| 16037 | }); |
| 16038 | } catch (e) { |
| 16039 | reject(e); |
| 16040 | } |
| 16041 | if (data) loadDataArray(data, dataFile.type).then((dc)=>{ |
| 16042 | if (dataFile.snapshotsUrl) fetch(dataFile.snapshotsUrl).then((response)=>response.json()).then((snapshots)=>{ |
| 16043 | dc.snapshots = snapshots; |
| 16044 | resolve(dc); |
| 16045 | }).catch(reject); |
| 16046 | else if (dataFile.snapshots) { |
| 16047 | dc.snapshots = dataFile.snapshots; |
| 16048 | resolve(dc); |
| 16049 | } else resolve(dc); |
| 16050 | }).catch(reject); |
| 16051 | } |
| 16052 | if (dataFile.dataUrl) loader.load(dataFile.dataUrl).then(handleRawText).catch(reject); |
| 16053 | else if (dataFile.rawText) handleRawText(dataFile.rawText); |
| 16054 | else reject("dataFile object must have either dataUrl or rawText property set."); |
| 16055 | }); |
| 16056 | const loadDataArray = (data, type)=>new Promise((resolve, reject)=>{ |
| 16057 | const parse = type === "csv" || type === "tsv"; |
| 16058 | if (parse) //convert empty strings to null so that vega.inferType will get dates |
nothing calls this directly
no test coverage detected