@vizabi/core
Advanced tools
Comparing version 1.21.0 to 1.21.1
@@ -1,2 +0,2 @@ | ||
// http://vizabi.org v1.21.0 Copyright 2021 Jasper Heeffer and others at Gapminder Foundation | ||
// http://vizabi.org v1.21.1 Copyright 2021 Jasper Heeffer and others at Gapminder Foundation | ||
(function (global, factory) { | ||
@@ -6,3 +6,3 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mobx')) : | ||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.Dataframe = {}, global.mobx)); | ||
}(this, (function (exports, mobx) { 'use strict'; | ||
})(this, (function (exports, mobx) { 'use strict'; | ||
@@ -354,2 +354,6 @@ const directions = { | ||
}; | ||
//case for quarter | ||
if (intervalSize === "quarter") return d3.utcMonth.every(3); | ||
//special case to make weeks start from monday as per ISO 8601, not sunday | ||
if (intervalSize === "week") intervalSize = "monday"; | ||
return d3['utc' + ucFirst(intervalSize)] || nonTimeInterval; | ||
@@ -1553,3 +1557,3 @@ } | ||
}))); | ||
})); | ||
//# sourceMappingURL=Dataframe.js.map |
{ | ||
"name": "@vizabi/core", | ||
"version": "1.21.0", | ||
"version": "1.21.1", | ||
"description": "Vizabi core (data layer)", | ||
@@ -58,7 +58,8 @@ "main": "dist/Vizabi.js", | ||
"peerDependencies": { | ||
"mobx": "^5.15.7", | ||
"d3": "^6.7.0" | ||
"d3": "^6.7.0", | ||
"mobx": "^5.15.7" | ||
}, | ||
"devDependencies": { | ||
"@rollup/plugin-node-resolve": "^13.0.4", | ||
"@vizabi/reader-ddfcsv": "^4.0.1", | ||
"install-peers": "^1.0.3", | ||
@@ -74,4 +75,3 @@ "jest": "^27.1.0", | ||
"rollup-plugin-serve": "^1.1.0", | ||
"rollup-plugin-visualizer": "^5.5.2", | ||
"@vizabi/reader-ddfcsv": "^4.0.1" | ||
"rollup-plugin-visualizer": "^5.5.2" | ||
}, | ||
@@ -81,3 +81,6 @@ "serve": { | ||
"hot": false | ||
}, | ||
"dependencies": { | ||
"user": "^0.0.0" | ||
} | ||
} |
@@ -45,3 +45,3 @@ import { fromPromise } from 'mobx-utils' | ||
else if (this.path) | ||
return csvReader({ path: this.path, sheet: this.sheet, keyConcepts: this.keyConcepts, dtypes: this.dtypes }); | ||
return csvReader(this.config); | ||
console.warn("No inline values or csv path found. Please set `values` or `path` property on dataSource.", this) | ||
@@ -215,3 +215,8 @@ }, | ||
return { | ||
raw: response, | ||
//Sometimes the raw response is a dataframe (such as from CSV/inline reader) | ||
//And sometimes it's a plain array (such as from ws-service reader) | ||
//Some downstream code however expects "raw" to be a plain array, | ||
//for example, the for loop in entityPropertyDataConfig.js: lookups() | ||
//hence, this converts response back to plain array | ||
raw: isDataFrame(response) ? [...response.values()] : response, | ||
forKey, | ||
@@ -218,0 +223,0 @@ forQueryKey |
@@ -351,2 +351,6 @@ import { fromPromise } from "mobx-utils"; | ||
}; | ||
//case for quarter | ||
if (intervalSize === "quarter") return d3.utcMonth.every(3); | ||
//special case to make weeks start from monday as per ISO 8601, not sunday | ||
if (intervalSize === "week") intervalSize = "monday"; | ||
return d3['utc' + ucFirst(intervalSize)] || nonTimeInterval; | ||
@@ -353,0 +357,0 @@ } |
@@ -8,3 +8,2 @@ import { inlineReader } from "./../inline/inline"; | ||
const GOOGLE_DOC_PREFIX = 'https://docs.google.com/spreadsheets/'; | ||
const MISSED_INDICATOR_NAME = 'indicator'; | ||
const ERRORS = { | ||
@@ -102,4 +101,9 @@ WRONG_TIME_COLUMN_OR_UNITS: 'reader/error/wrongTimeUnitsOrColumn', | ||
if (isTimeInColumns) | ||
return timeInColumns({rows, columns}); | ||
if (isTimeInColumns) { | ||
try { | ||
return timeInColumns({rows, columns}, ERRORS); | ||
} catch (error) { | ||
throw makeError(error); | ||
} | ||
} | ||
@@ -106,0 +110,0 @@ return {rows, columns}; |
@@ -1,4 +0,6 @@ | ||
export function timeInColumns({columns, rows}, parsers) { | ||
const keySize = this.keySize; | ||
import { ucFirst } from "../../core/utils"; | ||
const MISSED_INDICATOR_NAME = 'indicator'; | ||
export function timeInColumns({columns, rows, hasNameColumn, timeKey = "time", keySize = 1}, ERRORS, parsers) { | ||
let nameConcept = null; | ||
@@ -9,17 +11,17 @@ | ||
// name column is not at its original index because it was moved by csv reader "load" method | ||
if (this.hasNameColumn) { | ||
if (hasNameColumn) { | ||
nameConcept = columns.splice(keySize + 1, 1)[0] || 'name'; | ||
} | ||
const missedIndicator = parsers && parsers[this.timeKey] && !!parsers[this.timeKey](columns[keySize]); | ||
const missedIndicator = parsers && parsers[timeKey] && !!parsers[timeKey](columns[keySize]); | ||
if (missedIndicator) { | ||
Vizabi.utils.warn('Indicator column is missed.'); | ||
console.warn('Indicator column is missed.'); | ||
} | ||
const indicatorKey = missedIndicator ? this.MISSED_INDICATOR_NAME : columns[keySize]; | ||
const indicatorKey = missedIndicator ? MISSED_INDICATOR_NAME : columns[keySize]; | ||
const concepts = columns.slice(0, keySize) | ||
.concat(this.timeKey) | ||
.concat(timeKey) | ||
.concat(nameConcept || []) | ||
.concat(missedIndicator ? Vizabi.utils.capitalize(this.MISSED_INDICATOR_NAME) : rows.reduce((result, row) => { | ||
.concat(missedIndicator ? ucFirst(MISSED_INDICATOR_NAME) : rows.reduce((result, row) => { | ||
const concept = row[indicatorKey]; | ||
@@ -43,10 +45,10 @@ if (!result.includes(concept) && concept) { | ||
if (resultRows[0][row[indicatorKey]] !== null) { | ||
throw this.error(ERRORS.REPEATED_KEYS, null, { | ||
indicator: row[indicatorKey], | ||
key: row[entityDomain] | ||
}); | ||
throw { | ||
name: ERRORS.REPEATED_KEYS, | ||
message: `indicator: ${row[indicatorKey]}, key: ${row[entityDomain]}` | ||
} | ||
} | ||
resultRows.forEach(resultRow => { | ||
resultRow[row[indicatorKey]] = row[resultRow[this.timeKey]]; | ||
resultRow[row[indicatorKey]] = row[resultRow[timeKey]]; | ||
}); | ||
@@ -58,3 +60,3 @@ } else { | ||
[entityDomain]: row[entityDomain], | ||
[this.timeKey]: key | ||
[timeKey]: key | ||
}; | ||
@@ -61,0 +63,0 @@ const optionalNameColumn = !nameConcept ? {} : { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1213714
66
12722
3
4
+ Addeduser@^0.0.0
+ Addeduser@0.0.0(transitive)