UNPKG

pivot-chart

Version:

pivot table react component

79 lines 3.12 kB
var __values = (this && this.__values) || function(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); }; var __read = (this && this.__read) || function (o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; }; var __spread = (this && this.__spread) || function () { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; }; export function getVisualScale(facetMatrix, dimensions, measures) { var e_1, _a; var ans = { dimensions: dimensions.map(function (dim) { return ({ id: dim.id, type: 'discrete', domain: [] }); }), measures: measures.map(function (mea) { return ({ id: mea.id, type: 'continuous', domain: [0, 0] }); }) }; var cardinalityOfDimensions = dimensions.map(function () { return new Set(); }); for (var i = 0; i < facetMatrix.length; i++) { for (var j = 0; j < facetMatrix[i].length; j++) { var dataSource = facetMatrix[i][j]; var _loop_1 = function (record) { dimensions.forEach(function (dim, dIndex) { cardinalityOfDimensions[dIndex].add(record[dim.id]); }); measures.forEach(function (mea, mIndex) { ans.measures[mIndex].domain[0] = Math.min(record[mea.id], ans.measures[mIndex].domain[0]); ans.measures[mIndex].domain[1] = Math.max(record[mea.id], ans.measures[mIndex].domain[1]); }); }; try { for (var dataSource_1 = (e_1 = void 0, __values(dataSource)), dataSource_1_1 = dataSource_1.next(); !dataSource_1_1.done; dataSource_1_1 = dataSource_1.next()) { var record = dataSource_1_1.value; _loop_1(record); } } catch (e_1_1) { e_1 = { error: e_1_1 }; } finally { try { if (dataSource_1_1 && !dataSource_1_1.done && (_a = dataSource_1.return)) _a.call(dataSource_1); } finally { if (e_1) throw e_1.error; } } } } dimensions.forEach(function (dim, dIndex) { ans.dimensions[dIndex].domain = __spread(cardinalityOfDimensions[dIndex]); }); return ans; } //# sourceMappingURL=inedx.js.map