UNPKG

@actinc/dls

Version:

Design Language System (DLS) for ACT & Encoura front-end projects.

91 lines 2.98 kB
/** * Copyright (c) ACT, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; import { range } from 'd3-array'; import { scaleQuantile } from 'd3-scale'; export var defaultData = [ { QUANTITY: 80, SCF_CODE: 148, SCF_NAME: 'NY - 148', STATE_CODE: 'NY', }, { QUANTITY: 130, SCF_CODE: 157, SCF_NAME: 'PA - 157', STATE_CODE: 'PA', }, { QUANTITY: 185, SCF_CODE: 287, SCF_NAME: 'NC - 287', STATE_CODE: 'NC', }, { QUANTITY: 200, SCF_CODE: 286, SCF_NAME: 'NC - 286', STATE_CODE: 'NC', }, { QUANTITY: 30, SCF_CODE: 295, SCF_NAME: 'SC - 295', STATE_CODE: 'SC', }, { QUANTITY: 800, SCF_CODE: 96, SCF_NAME: 'AE - 096', STATE_CODE: 'AE', }, { QUANTITY: 500, SCF_CODE: 148, SCF_NAME: 'NY - 148', STATE_CODE: 'NY', }, ]; export var defaultProcessDataFn = function (featureCollection) { var features = featureCollection.features; var scale = scaleQuantile() .domain(defaultData.map(function (item) { return item.QUANTITY; })) .range(range(10)); var mappedFeatures = defaultData.reduce(function (acc, _a) { var QUANTITY = _a.QUANTITY, SCF_CODE = _a.SCF_CODE, STATE_CODE = _a.STATE_CODE; acc[SCF_CODE] = { quantity: QUANTITY, stateCode: STATE_CODE }; return acc; }, {}); return { features: features.map(function (f) { var _a, _b, _c; if (((_a = f.properties) === null || _a === void 0 ? void 0 : _a.id) && mappedFeatures[f.properties.id]) { var quantity = ((_b = f.properties) === null || _b === void 0 ? void 0 : _b.id) && mappedFeatures[f.properties.id] ? scale(mappedFeatures[f.properties.id].quantity) : 0; var properties = __assign(__assign({}, f.properties), { quantity: quantity, stateCode: mappedFeatures[f.properties.id].stateCode, value: ((_c = f.properties) === null || _c === void 0 ? void 0 : _c.id) && mappedFeatures[f.properties.id] ? mappedFeatures[f.properties.id].quantity : 0 }); return __assign(__assign({}, f), { properties: properties }); } return __assign({}, f); }), type: 'FeatureCollection', }; }; //# sourceMappingURL=mocks.js.map