(data, type)
| 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 |
| 16059 | data.forEach((row)=>{ |
| 16060 | for(let column in row)if (row[column] === "") row[column] = null; |
| 16061 | }); |
| 16062 | const columns = (0, _sanddanceReact.SandDance).util.getColumnsFromData((0, _sanddanceReact.SandDance).VegaDeckGl.base.vega.inferTypes, data).filter((c)=>c.name && c.name.trim()).sort((a, b)=>a.name.localeCompare(b.name)); |
| 16063 | if (parse) { |
| 16064 | const booleanColumns = columns.filter((c)=>c.type === "boolean"); |
| 16065 | const dateColumns = columns.filter((c)=>c.type === "date"); |
| 16066 | const numericColumns = columns.filter((c)=>c.type === "integer" || c.type === "number"); |
| 16067 | data.forEach((obj)=>{ |
| 16068 | booleanColumns.forEach((c)=>{ |
| 16069 | obj[c.name] = ("" + obj[c.name]).toLowerCase() === "true"; |
| 16070 | }); |
| 16071 | dateColumns.forEach((c)=>{ |
| 16072 | const input = obj[c.name]; |
| 16073 | if (input !== null) { |
| 16074 | const d = new Date(input); |
| 16075 | d.input = input; |
| 16076 | obj[c.name] = d; |
| 16077 | } |
| 16078 | }); |
| 16079 | numericColumns.forEach((c)=>{ |
| 16080 | const n = parseFloat(obj[c.name]); |
| 16081 | obj[c.name] = isNaN(n) ? null : n; |
| 16082 | }); |
| 16083 | }); |
| 16084 | } |
| 16085 | resolve({ |
| 16086 | data, |
| 16087 | columns |
| 16088 | }); |
| 16089 | }); |
| 16090 | |
| 16091 | },{"@msrvida/sanddance-react":"4uo3s","@parcel/transformer-js/src/esmodule-helpers.js":"jA2du"}],"ed5cu":[function(require,module,exports) { |
| 16092 | var parcelHelpers = require("@parcel/transformer-js/src/esmodule-helpers.js"); |
no test coverage detected