UNPKG

@rcsb/rcsb-charts

Version:
44 lines 2.02 kB
export class ChartTools { static getConfig(key, chartDisplayConfig) { return ((chartDisplayConfig && (typeof chartDisplayConfig[key] === "string" || typeof chartDisplayConfig[key] === "number")) ? chartDisplayConfig[key] : this[key]); } static labelsAsNumber(data) { return data.map(d => d.map(e => (Object.assign(Object.assign({}, e), { label: parseFloat(e.label.toString()) })))); } static labelsAsString(data) { return data.map(d => d.map(e => (Object.assign(Object.assign({}, e), { label: e.label.toString() })))); } static normalizeData(chartData) { const dataMap = new Map(); chartData.flat().forEach(d => { dataMap.set(d.label, { x: d.label, y: [] }); }); chartData.forEach(dataGroup => { Array.from(dataMap.keys()).forEach(key => { var _a, _b, _c, _d; const d = dataGroup.find(d => d.label == key); (_a = dataMap.get(key)) === null || _a === void 0 ? void 0 : _a.y.push({ value: (_b = d === null || d === void 0 ? void 0 : d.population) !== null && _b !== void 0 ? _b : 0, color: (_c = d === null || d === void 0 ? void 0 : d.objectConfig) === null || _c === void 0 ? void 0 : _c.color, id: (_d = d === null || d === void 0 ? void 0 : d.objectConfig) === null || _d === void 0 ? void 0 : _d.objectId }); }); }); return Array.from(dataMap.values()); } static digitGrouping(x) { return parseFloat(x).toLocaleString('en-US'); } } ChartTools.paddingLeft = 150; ChartTools.paddingTopLarge = 50; ChartTools.paddingTop = 10; ChartTools.paddingRight = 15; ChartTools.constWidth = 350; ChartTools.constHeight = 225; ChartTools.xIncrement = 22; ChartTools.xDomainPadding = 10; ChartTools.barWidth = 10; ChartTools.fontFamily = "\"Helvetica Neue\",Helvetica,Arial,sans-serif"; ChartTools.fontSize = 12; ChartTools.minBarLength = 5; //# sourceMappingURL=ChartTools.js.map