@frontify/fondue-charts
Version:
Frontify's data viz library
39 lines (38 loc) • 1.28 kB
JavaScript
const c = (n) => n.value !== null && !Number.isNaN(n.value), o = (n) => n.map((a) => {
var i, l;
const t = (i = a.at(-1)) == null ? void 0 : i.value, s = ((l = a[0]) == null ? void 0 : l.value) ?? t, e = t - s;
return a.map((u, f) => {
const h = s + e * (f / (a.length - 1));
return { ...u, value: h };
});
}), D = (n) => {
const a = [];
return n.dataPoints.reduce((t, s, e) => {
var i;
if (!c(s)) {
const l = e > 0 && c(n.dataPoints[e - 1]), u = (
// @ts-expect-error Wrong typing in the original code
e < n.dataPoints.length - 1 && c(n.dataPoints[e + 1])
), f = e === n.dataPoints.length - 1 && !c(s);
l && t.push(n.dataPoints[e - 1]), t.push(s), u && (t.push(n.dataPoints[e + 1]), a.push([...t]), t.splice(0, t.length)), f && (t[0] && c(t[0]) && t.push({ ...s, value: (i = t[0]) == null ? void 0 : i.value }), a.push([...t]), t.splice(0, t.length));
}
return t;
}, []), a;
}, d = (n) => n.reduce((a, t) => {
const s = D(t);
if (s) {
const e = o(s);
return [
...a,
...e.map((i, l) => ({
name: `${t.name}-${l}`,
dataPoints: i
}))
];
} else
return a;
}, []);
export {
d as createBackfilledSeries
};
//# sourceMappingURL=createBackfilledSeries.es.js.map