@@ -5,9 +5,9 @@ it("barX() has the expected defaults", () => {
5
5
const bar = Plot . barX ( ) ;
6
6
assert . strictEqual ( bar . data , undefined ) ;
7
7
// assert.strictEqual(bar.transform, undefined);
8
- assert . deepStrictEqual ( bar . channels . map ( c => c . name ) , [ "x1" , "x2" , "y" ] ) ;
9
- // assert.deepStrictEqual(bar.channels.map(c => Plot.valueof([1, 2, 3], c.value)), [[0, 0, 0], [1, 2, 3]]);
10
- assert . deepStrictEqual ( bar . channels . map ( c => c . scale ) , [ "x" , "x" , "y" ] ) ;
8
+ assert . deepStrictEqual ( Object . keys ( bar . channels ) , [ "x1" , "x2" , "y" ] ) ;
9
+ // assert.deepStrictEqual(Object.values( bar.channels) .map(c => Plot.valueof([1, 2, 3], c.value)), [[0, 0, 0], [1, 2, 3]]);
10
+ assert . deepStrictEqual ( Object . values ( bar . channels ) . map ( c => c . scale ) , [ "x" , "x" , "y" ] ) ;
11
11
assert . strictEqual ( bar . fill , undefined ) ;
12
12
assert . strictEqual ( bar . fillOpacity , undefined ) ;
13
13
assert . strictEqual ( bar . stroke , undefined ) ;
@@ -28,15 +28,15 @@ it("barX() has the expected defaults", () => {
28
28
29
29
it ( "barX(data, {y}) uses a band scale" , ( ) => {
30
30
const bar = Plot . barX ( undefined , { y : "x" } ) ;
31
- assert . deepStrictEqual ( bar . channels . map ( c => c . name ) , [ "x1" , "x2" , "y" ] ) ;
32
- assert . deepStrictEqual ( bar . channels . map ( c => c . scale ) , [ "x" , "x" , "y" ] ) ;
33
- assert . strictEqual ( bar . channels . find ( c => c . name === "y" ) . type , "band" ) ;
34
- assert . strictEqual ( bar . channels . find ( c => c . name === "y" ) . value . label , "x" ) ;
31
+ assert . deepStrictEqual ( Object . keys ( bar . channels ) , [ "x1" , "x2" , "y" ] ) ;
32
+ assert . deepStrictEqual ( Object . values ( bar . channels ) . map ( c => c . scale ) , [ "x" , "x" , "y" ] ) ;
33
+ assert . strictEqual ( bar . channels . y . type , "band" ) ;
34
+ assert . strictEqual ( bar . channels . y . value . label , "x" ) ;
35
35
} ) ;
36
36
37
37
it ( "barX(data, {title}) specifies an optional title channel" , ( ) => {
38
38
const bar = Plot . barX ( undefined , { title : "x" } ) ;
39
- const title = bar . channels . find ( c => c . name === "title" ) ;
39
+ const { title} = bar . channels ;
40
40
assert . strictEqual ( title . value , "x" ) ;
41
41
assert . strictEqual ( title . scale , undefined ) ;
42
42
} ) ;
@@ -54,7 +54,7 @@ it("barX(data, {fill}) allows fill to be null", () => {
54
54
it ( "barX(data, {fill}) allows fill to be a variable color" , ( ) => {
55
55
const bar = Plot . barX ( undefined , { fill : "x" } ) ;
56
56
assert . strictEqual ( bar . fill , undefined ) ;
57
- const fill = bar . channels . find ( c => c . name === "fill" ) ;
57
+ const { fill} = bar . channels ;
58
58
assert . strictEqual ( fill . value , "x" ) ;
59
59
assert . strictEqual ( fill . scale , "color" ) ;
60
60
} ) ;
@@ -72,20 +72,20 @@ it("barX(data, {stroke}) allows stroke to be null", () => {
72
72
it ( "barX(data, {stroke}) allows stroke to be a variable color" , ( ) => {
73
73
const bar = Plot . barX ( undefined , { stroke : "x" } ) ;
74
74
assert . strictEqual ( bar . stroke , undefined ) ;
75
- const stroke = bar . channels . find ( c => c . name === "stroke" ) ;
75
+ const { stroke} = bar . channels ;
76
76
assert . strictEqual ( stroke . value , "x" ) ;
77
77
assert . strictEqual ( stroke . scale , "color" ) ;
78
78
} ) ;
79
79
80
80
it ( "barX(data, {x, y}) defaults x1 to zero and x2 to x" , ( ) => {
81
81
const bar = Plot . barX ( undefined , { x : "0" , y : "1" } ) ;
82
- const x1 = bar . channels . find ( c => c . name === "x1" ) ;
82
+ const { x1 } = bar . channels ;
83
83
// assert.strictEqual(x1.value, 0);
84
84
assert . strictEqual ( x1 . scale , "x" ) ;
85
- const x2 = bar . channels . find ( c => c . name === "x2" ) ;
85
+ const { x2 } = bar . channels ;
86
86
assert . strictEqual ( x2 . value . label , "0" ) ;
87
87
assert . strictEqual ( x2 . scale , "x" ) ;
88
- const y = bar . channels . find ( c => c . name === "y" ) ;
88
+ const { y } = bar . channels ;
89
89
assert . strictEqual ( y . value . label , "1" ) ;
90
90
assert . strictEqual ( y . scale , "y" ) ;
91
91
} ) ;
@@ -99,9 +99,9 @@ it("barY() has the expected defaults", () => {
99
99
const bar = Plot . barY ( ) ;
100
100
assert . strictEqual ( bar . data , undefined ) ;
101
101
// assert.strictEqual(bar.transform, undefined);
102
- assert . deepStrictEqual ( bar . channels . map ( c => c . name ) , [ "y1" , "y2" , "x" ] ) ;
103
- // assert.deepStrictEqual(bar.channels.map(c => Plot.valueof([1, 2, 3], c.value)), [[0, 0, 0], [1, 2, 3]]);
104
- assert . deepStrictEqual ( bar . channels . map ( c => c . scale ) , [ "y" , "y" , "x" ] ) ;
102
+ assert . deepStrictEqual ( Object . keys ( bar . channels ) , [ "y1" , "y2" , "x" ] ) ;
103
+ // assert.deepStrictEqual(Object.values( bar.channels) .map(c => Plot.valueof([1, 2, 3], c.value)), [[0, 0, 0], [1, 2, 3]]);
104
+ assert . deepStrictEqual ( Object . values ( bar . channels ) . map ( c => c . scale ) , [ "y" , "y" , "x" ] ) ;
105
105
assert . strictEqual ( bar . fill , undefined ) ;
106
106
assert . strictEqual ( bar . fillOpacity , undefined ) ;
107
107
assert . strictEqual ( bar . stroke , undefined ) ;
@@ -122,15 +122,15 @@ it("barY() has the expected defaults", () => {
122
122
123
123
it ( "barY(data, {x}) uses a band scale" , ( ) => {
124
124
const bar = Plot . barY ( undefined , { x : "y" } ) ;
125
- assert . deepStrictEqual ( bar . channels . map ( c => c . name ) , [ "y1" , "y2" , "x" ] ) ;
126
- assert . deepStrictEqual ( bar . channels . map ( c => c . scale ) , [ "y" , "y" , "x" ] ) ;
127
- assert . strictEqual ( bar . channels . find ( c => c . name === "x" ) . type , "band" ) ;
128
- assert . strictEqual ( bar . channels . find ( c => c . name === "x" ) . value . label , "y" ) ;
125
+ assert . deepStrictEqual ( Object . keys ( bar . channels ) , [ "y1" , "y2" , "x" ] ) ;
126
+ assert . deepStrictEqual ( Object . values ( bar . channels ) . map ( c => c . scale ) , [ "y" , "y" , "x" ] ) ;
127
+ assert . strictEqual ( bar . channels . x . type , "band" ) ;
128
+ assert . strictEqual ( bar . channels . x . value . label , "y" ) ;
129
129
} ) ;
130
130
131
131
it ( "barY(data, {title}) specifies an optional title channel" , ( ) => {
132
132
const bar = Plot . barY ( undefined , { title : "x" } ) ;
133
- const title = bar . channels . find ( c => c . name === "title" ) ;
133
+ const { title} = bar . channels ;
134
134
assert . strictEqual ( title . value , "x" ) ;
135
135
assert . strictEqual ( title . scale , undefined ) ;
136
136
} ) ;
@@ -148,7 +148,7 @@ it("barY(data, {fill}) allows fill to be null", () => {
148
148
it ( "barY(data, {fill}) allows fill to be a variable color" , ( ) => {
149
149
const bar = Plot . barY ( undefined , { fill : "x" } ) ;
150
150
assert . strictEqual ( bar . fill , undefined ) ;
151
- const fill = bar . channels . find ( c => c . name === "fill" ) ;
151
+ const { fill} = bar . channels ;
152
152
assert . strictEqual ( fill . value , "x" ) ;
153
153
assert . strictEqual ( fill . scale , "color" ) ;
154
154
} ) ;
@@ -166,20 +166,20 @@ it("barY(data, {stroke}) allows stroke to be null", () => {
166
166
it ( "barY(data, {stroke}) allows stroke to be a variable color" , ( ) => {
167
167
const bar = Plot . barY ( undefined , { stroke : "x" } ) ;
168
168
assert . strictEqual ( bar . stroke , undefined ) ;
169
- const stroke = bar . channels . find ( c => c . name === "stroke" ) ;
169
+ const { stroke} = bar . channels ;
170
170
assert . strictEqual ( stroke . value , "x" ) ;
171
171
assert . strictEqual ( stroke . scale , "color" ) ;
172
172
} ) ;
173
173
174
174
it ( "barY(data, {x, y}) defaults y1 to zero and y2 to y" , ( ) => {
175
175
const bar = Plot . barY ( undefined , { x : "0" , y : "1" } ) ;
176
- const x = bar . channels . find ( c => c . name === "x" ) ;
176
+ const { x } = bar . channels ;
177
177
assert . strictEqual ( x . value . label , "0" ) ;
178
178
assert . strictEqual ( x . scale , "x" ) ;
179
- const y1 = bar . channels . find ( c => c . name === "y1" ) ;
179
+ const { y1 } = bar . channels ;
180
180
// assert.strictEqual(y1.value, 0);
181
181
assert . strictEqual ( y1 . scale , "y" ) ;
182
- const y2 = bar . channels . find ( c => c . name === "y2" ) ;
182
+ const { y2 } = bar . channels ;
183
183
assert . strictEqual ( y2 . value . label , "1" ) ;
184
184
assert . strictEqual ( y2 . scale , "y" ) ;
185
185
} ) ;
0 commit comments