@@ -8,8 +8,14 @@ describe('dc.BoxPlot', () => {
8
8
9
9
dimension = data . dimension ( d => d . countrycode ) ;
10
10
group = dimension . group ( ) . reduce (
11
- ( p , v ) => { p . push ( + v . value ) ; return p ; } ,
12
- ( p , v ) => { p . splice ( p . indexOf ( + v . value ) , 1 ) ; return p ; } ,
11
+ ( p , v ) => {
12
+ p . push ( + v . value ) ;
13
+ return p ;
14
+ } ,
15
+ ( p , v ) => {
16
+ p . splice ( p . indexOf ( + v . value ) , 1 ) ;
17
+ return p ;
18
+ } ,
13
19
( ) => [ ]
14
20
) ;
15
21
@@ -22,12 +28,12 @@ describe('dc.BoxPlot', () => {
22
28
. group ( group )
23
29
. width ( 300 )
24
30
. height ( 144 )
25
- . margins ( { top : 0 , right : 0 , bottom : 0 , left : 0 } )
31
+ . margins ( { top : 0 , right : 0 , bottom : 0 , left : 0 } )
26
32
. boxPadding ( 0 )
27
33
. transitionDuration ( 0 )
28
34
. transitionDelay ( 0 )
29
35
. y ( d3 . scaleLinear ( ) . domain ( [ 0 , 144 ] ) )
30
- . ordinalColors ( [ '#01' , '#02' ] ) ;
36
+ . ordinalColors ( [ '#01' , '#02' ] ) ;
31
37
} ) ;
32
38
33
39
describe ( 'rendering the box plot' , ( ) => {
@@ -86,11 +92,7 @@ describe('dc.BoxPlot', () => {
86
92
87
93
describe ( 'with renderDataPoints enabled' , ( ) => {
88
94
beforeEach ( ( ) => {
89
- chart
90
- . renderDataPoints ( true )
91
- . renderTitle ( true )
92
- . boxWidth ( 100 )
93
- . render ( ) ;
95
+ chart . renderDataPoints ( true ) . renderTitle ( true ) . boxWidth ( 100 ) . render ( ) ;
94
96
} ) ;
95
97
96
98
it ( 'should create one data point per data value (non-outlier)' , ( ) => {
@@ -101,8 +103,8 @@ describe('dc.BoxPlot', () => {
101
103
} ) ;
102
104
it ( 'should display the data between 10 to 90 of the box (by default)' , ( ) => {
103
105
const w = box ( 1 ) . select ( 'rect.box' ) . attr ( 'width' ) ;
104
- const min = ( w / 2 ) - ( w * chart . dataWidthPortion ( ) / 2 ) ;
105
- const max = ( w / 2 ) + ( w * chart . dataWidthPortion ( ) / 2 ) ;
106
+ const min = w / 2 - ( w * chart . dataWidthPortion ( ) ) / 2 ;
107
+ const max = w / 2 + ( w * chart . dataWidthPortion ( ) ) / 2 ;
106
108
chart . selectAll ( 'circle.data' ) . each ( function ( ) {
107
109
expect ( d3 . select ( this ) . attr ( 'cx' ) ) . toBeGreaterThan ( min - 0.1 ) ;
108
110
expect ( d3 . select ( this ) . attr ( 'cx' ) ) . toBeLessThan ( max + 0.1 ) ;
@@ -111,15 +113,13 @@ describe('dc.BoxPlot', () => {
111
113
112
114
describe ( 'and dataWidthPortion set to 50%' , ( ) => {
113
115
beforeEach ( ( ) => {
114
- chart
115
- . dataWidthPortion ( 0.5 )
116
- . render ( ) ;
116
+ chart . dataWidthPortion ( 0.5 ) . render ( ) ;
117
117
} ) ;
118
118
119
119
it ( 'should display the data between 25 to 75 of the box' , ( ) => {
120
120
const w = box ( 1 ) . select ( 'rect.box' ) . attr ( 'width' ) ;
121
- const min = ( w / 2 ) - ( w * chart . dataWidthPortion ( ) / 2 ) ;
122
- const max = ( w / 2 ) + ( w * chart . dataWidthPortion ( ) / 2 ) ;
121
+ const min = w / 2 - ( w * chart . dataWidthPortion ( ) ) / 2 ;
122
+ const max = w / 2 + ( w * chart . dataWidthPortion ( ) ) / 2 ;
123
123
chart . selectAll ( 'circle.data' ) . each ( function ( ) {
124
124
expect ( d3 . select ( this ) . attr ( 'cx' ) ) . toBeGreaterThan ( min - 0.1 ) ;
125
125
expect ( d3 . select ( this ) . attr ( 'cx' ) ) . toBeLessThan ( max + 0.1 ) ;
@@ -129,15 +129,13 @@ describe('dc.BoxPlot', () => {
129
129
130
130
describe ( 'and dataWidthPortion set to 10%' , ( ) => {
131
131
beforeEach ( ( ) => {
132
- chart
133
- . dataWidthPortion ( 0.1 )
134
- . render ( ) ;
132
+ chart . dataWidthPortion ( 0.1 ) . render ( ) ;
135
133
} ) ;
136
134
137
135
it ( 'should display the data between 45 to 55 of the box' , ( ) => {
138
136
const w = box ( 1 ) . select ( 'rect.box' ) . attr ( 'width' ) ;
139
- const min = ( w / 2 ) - ( w * chart . dataWidthPortion ( ) / 2 ) ;
140
- const max = ( w / 2 ) + ( w * chart . dataWidthPortion ( ) / 2 ) ;
137
+ const min = w / 2 - ( w * chart . dataWidthPortion ( ) ) / 2 ;
138
+ const max = w / 2 + ( w * chart . dataWidthPortion ( ) ) / 2 ;
141
139
chart . selectAll ( 'circle.data' ) . each ( function ( ) {
142
140
expect ( d3 . select ( this ) . attr ( 'cx' ) ) . toBeGreaterThan ( min - 0.1 ) ;
143
141
expect ( d3 . select ( this ) . attr ( 'cx' ) ) . toBeLessThan ( max + 0.1 ) ;
@@ -170,7 +168,9 @@ describe('dc.BoxPlot', () => {
170
168
} ) ;
171
169
172
170
it ( 'should be settable to a function' , ( ) => {
173
- chart . boxWidth ( ( innerChartWidth , xUnits ) => innerChartWidth / ( xUnits + 2 ) ) . render ( ) ;
171
+ chart
172
+ . boxWidth ( ( innerChartWidth , xUnits ) => innerChartWidth / ( xUnits + 2 ) )
173
+ . render ( ) ;
174
174
expect ( box ( 1 ) . select ( 'rect.box' ) . attr ( 'width' ) ) . toBe ( '75' ) ;
175
175
} ) ;
176
176
} ) ;
@@ -291,7 +291,7 @@ describe('dc.BoxPlot', () => {
291
291
} ) ;
292
292
} ) ;
293
293
294
- function box ( n ) {
294
+ function box ( n ) {
295
295
const nthBox = d3 . select ( chart . selectAll ( 'g.box' ) . nodes ( ) [ n ] ) ;
296
296
nthBox . boxText = function ( i ) {
297
297
return d3 . select ( this . selectAll ( 'text.box' ) . nodes ( ) [ i ] ) ;
@@ -305,4 +305,3 @@ describe('dc.BoxPlot', () => {
305
305
return nthBox ;
306
306
}
307
307
} ) ;
308
-
0 commit comments