Skip to content

Commit

Permalink
refactor(viz): update stackedIntervals()
Browse files Browse the repository at this point in the history
- use mapcatIndexed() to simplify composed xform
  • Loading branch information
postspectacular committed Sep 18, 2020
1 parent be79f2e commit 19396cf
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions packages/viz/src/plot/stacked-intervals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ import type { Fn, Fn2 } from "@thi.ng/api";
import {
comp,
filter,
indexed,
iterator,
map,
mapcat,
mapcatIndexed,
push,
some,
transduce,
Expand Down Expand Up @@ -38,10 +37,10 @@ const rowStacking = <T>(data: [number[], T][], pad = 0) =>
}
}, <Row<T>[]>[]);

const processRow = <T>(mapper: Fn<number[], number[]>, [d1, d2]: Domain) => ([
i,
row,
]: [number, Row<T>]) =>
const processRow = <T>(mapper: Fn<number[], number[]>, [d1, d2]: Domain) => (
i: number,
row: Row<T>
) =>
map(
([[a, b], item]) =>
<[number[], number[], T, number]>[
Expand All @@ -64,8 +63,7 @@ export const stackedIntervals = <T>(
opts.attribs,
...iterator(
comp(
indexed(),
mapcat(processRow<T>(mapper, domain)),
mapcatIndexed(processRow<T>(mapper, domain)),
map((x) => opts.shape(x, mapper))
),
rowStacking(
Expand Down

0 comments on commit 19396cf

Please sign in to comment.