@actinc/dls
Version:
Design Language System (DLS) for ACT & Encoura front-end projects.
122 lines • 3.74 kB
JavaScript
/**
* 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 = [
{
CONVERSION_QUANTITY: 547,
COUNTY_NAME: 'Nassau',
FIPS: '36059',
QUANTITY: 883,
STATE_CODE: 'NY',
},
{
CONVERSION_QUANTITY: 457,
COUNTY_NAME: 'Suffolk',
FIPS: '36103',
QUANTITY: 761,
STATE_CODE: 'NY',
},
{
CONVERSION_QUANTITY: 301,
COUNTY_NAME: 'Westchester',
FIPS: '36119',
QUANTITY: 689,
STATE_CODE: 'NY',
},
{
CONVERSION_QUANTITY: 316,
COUNTY_NAME: 'Bergen',
FIPS: '34003',
QUANTITY: 567,
STATE_CODE: 'NJ',
},
{
CONVERSION_QUANTITY: 281,
COUNTY_NAME: 'Capitol',
FIPS: '09110',
QUANTITY: 538,
STATE_CODE: 'CT',
},
{
CONVERSION_QUANTITY: 27,
COUNTY_NAME: 'Bronx',
FIPS: '36005',
QUANTITY: 400,
STATE_CODE: 'NY',
},
{
CONVERSION_QUANTITY: 72,
COUNTY_NAME: 'Queens',
FIPS: '36081',
QUANTITY: 276,
STATE_CODE: 'NY',
},
{
CONVERSION_QUANTITY: 112,
COUNTY_NAME: 'Dutchess',
FIPS: '36027',
QUANTITY: 260,
STATE_CODE: 'NY',
},
{
CONVERSION_QUANTITY: 156,
COUNTY_NAME: 'Monmouth',
FIPS: '34025',
QUANTITY: 258,
STATE_CODE: 'NJ',
},
{
CONVERSION_QUANTITY: 48,
COUNTY_NAME: 'Kings',
FIPS: '36047',
QUANTITY: 254,
STATE_CODE: 'NY',
},
];
export var defaultProcessDataFn = function (featureCollection, data) {
var features = featureCollection.features;
var scale = scaleQuantile()
.domain(data.map(function (item) { return item.QUANTITY; }))
.range(range(10));
var mappedFeatures = data.reduce(function (acc, _a) {
var COUNTY_NAME = _a.COUNTY_NAME, QUANTITY = _a.QUANTITY, STATE_CODE = _a.STATE_CODE;
acc[COUNTY_NAME] = {
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.NAME) && mappedFeatures[f.properties.NAME]) {
var quantity = ((_b = f.properties) === null || _b === void 0 ? void 0 : _b.NAME) && mappedFeatures[f.properties.NAME]
? scale(mappedFeatures[f.properties.NAME].quantity)
: 0;
var properties = __assign(__assign({}, f.properties), { quantity: quantity, stateCode: mappedFeatures[f.properties.NAME].stateCode, value: ((_c = f.properties) === null || _c === void 0 ? void 0 : _c.NAME) && mappedFeatures[f.properties.NAME]
? mappedFeatures[f.properties.NAME].quantity
: 0 });
return __assign(__assign({}, f), { properties: properties });
}
return __assign({}, f);
}),
type: 'FeatureCollection',
};
};
//# sourceMappingURL=mocks.js.map