@@ -2,46 +2,47 @@ import {InternMap, cumsum, group, groupSort, greatest, max, min, rollup, sum} fr
2
2
import { ascendingDefined } from "../defined.js" ;
3
3
import { field , column , maybeColumn , maybeZ , mid , range , valueof , maybeZero , one } from "../options.js" ;
4
4
import { basic } from "./basic.js" ;
5
+ import { maybeApplyInterval } from "../options.js" ;
5
6
6
- export function stackX ( stack = { } , options = { } ) {
7
- if ( arguments . length === 1 ) [ stack , options ] = mergeOptions ( stack ) ;
7
+ export function stackX ( stackOptions = { } , options = { } ) {
8
+ if ( arguments . length === 1 ) [ stackOptions , options ] = mergeOptions ( stackOptions ) ;
8
9
const { y1, y = y1 , x, ...rest } = options ; // note: consumes x!
9
- const [ transform , Y , x1 , x2 ] = stackAlias ( y , x , "x" , stack , rest ) ;
10
+ const [ transform , Y , x1 , x2 ] = stack ( y , x , "y" , " x", stackOptions , rest ) ;
10
11
return { ...transform , y1, y : Y , x1, x2, x : mid ( x1 , x2 ) } ;
11
12
}
12
13
13
- export function stackX1 ( stack = { } , options = { } ) {
14
- if ( arguments . length === 1 ) [ stack , options ] = mergeOptions ( stack ) ;
14
+ export function stackX1 ( stackOptions = { } , options = { } ) {
15
+ if ( arguments . length === 1 ) [ stackOptions , options ] = mergeOptions ( stackOptions ) ;
15
16
const { y1, y = y1 , x} = options ;
16
- const [ transform , Y , X ] = stackAlias ( y , x , "x" , stack , options ) ;
17
+ const [ transform , Y , X ] = stack ( y , x , "x" , "y" , stackOptions , options ) ;
17
18
return { ...transform , y1, y : Y , x : X } ;
18
19
}
19
20
20
- export function stackX2 ( stack = { } , options = { } ) {
21
- if ( arguments . length === 1 ) [ stack , options ] = mergeOptions ( stack ) ;
21
+ export function stackX2 ( stackOptions = { } , options = { } ) {
22
+ if ( arguments . length === 1 ) [ stackOptions , options ] = mergeOptions ( stackOptions ) ;
22
23
const { y1, y = y1 , x} = options ;
23
- const [ transform , Y , , X ] = stackAlias ( y , x , "x" , stack , options ) ;
24
+ const [ transform , Y , , X ] = stack ( y , x , "y" , " x", stackOptions , options ) ;
24
25
return { ...transform , y1, y : Y , x : X } ;
25
26
}
26
27
27
- export function stackY ( stack = { } , options = { } ) {
28
- if ( arguments . length === 1 ) [ stack , options ] = mergeOptions ( stack ) ;
28
+ export function stackY ( stackOptions = { } , options = { } ) {
29
+ if ( arguments . length === 1 ) [ stackOptions , options ] = mergeOptions ( stackOptions ) ;
29
30
const { x1, x = x1 , y, ...rest } = options ; // note: consumes y!
30
- const [ transform , X , y1 , y2 ] = stackAlias ( x , y , "y" , stack , rest ) ;
31
+ const [ transform , X , y1 , y2 ] = stack ( x , y , "x" , " y", stackOptions , rest ) ;
31
32
return { ...transform , x1, x : X , y1, y2, y : mid ( y1 , y2 ) } ;
32
33
}
33
34
34
- export function stackY1 ( stack = { } , options = { } ) {
35
- if ( arguments . length === 1 ) [ stack , options ] = mergeOptions ( stack ) ;
35
+ export function stackY1 ( stackOptions = { } , options = { } ) {
36
+ if ( arguments . length === 1 ) [ stackOptions , options ] = mergeOptions ( stackOptions ) ;
36
37
const { x1, x = x1 , y} = options ;
37
- const [ transform , X , Y ] = stackAlias ( x , y , "y" , stack , options ) ;
38
+ const [ transform , X , Y ] = stack ( x , y , "x" , " y", stackOptions , options ) ;
38
39
return { ...transform , x1, x : X , y : Y } ;
39
40
}
40
41
41
- export function stackY2 ( stack = { } , options = { } ) {
42
- if ( arguments . length === 1 ) [ stack , options ] = mergeOptions ( stack ) ;
42
+ export function stackY2 ( stackOptions = { } , options = { } ) {
43
+ if ( arguments . length === 1 ) [ stackOptions , options ] = mergeOptions ( stackOptions ) ;
43
44
const { x1, x = x1 , y} = options ;
44
- const [ transform , X , , Y ] = stackAlias ( x , y , "y" , stack , options ) ;
45
+ const [ transform , X , , Y ] = stack ( x , y , "x" , " y", stackOptions , options ) ;
45
46
return { ...transform , x1, x : X , y : Y } ;
46
47
}
47
48
@@ -65,16 +66,16 @@ function mergeOptions(options) {
65
66
return [ { offset, order, reverse} , rest ] ;
66
67
}
67
68
68
- function stack ( x , y = one , ky , { offset, order, reverse} , options ) {
69
+ function stack ( x , y = one , kx , ky , { offset, order, reverse} , options ) {
69
70
const z = maybeZ ( options ) ;
70
71
const [ X , setX ] = maybeColumn ( x ) ;
71
72
const [ Y1 , setY1 ] = column ( y ) ;
72
73
const [ Y2 , setY2 ] = column ( y ) ;
73
74
offset = maybeOffset ( offset ) ;
74
75
order = maybeOrder ( order , offset , ky ) ;
75
76
return [
76
- basic ( options , ( data , facets ) => {
77
- const X = x == null ? undefined : setX ( valueof ( data , x ) ) ;
77
+ basic ( options , ( data , facets , plotOptions ) => {
78
+ const X = x == null ? undefined : setX ( maybeApplyInterval ( valueof ( data , x ) , plotOptions ?. [ kx ] ) ) ;
78
79
const Y = valueof ( data , y , Float64Array ) ;
79
80
const Z = valueof ( data , z ) ;
80
81
const O = order && order ( data , X , Y , Z ) ;
@@ -107,9 +108,6 @@ function stack(x, y = one, ky, {offset, order, reverse}, options) {
107
108
] ;
108
109
}
109
110
110
- // This is used internally so we can use `stack` as an argument name.
111
- const stackAlias = stack ;
112
-
113
111
function maybeOffset ( offset ) {
114
112
if ( offset == null ) return ;
115
113
if ( typeof offset === "function" ) return offset ;
0 commit comments