@@ -12,10 +12,10 @@ Plotly.register(
12
12
var withSetupTeardown = require ( '../assets/with_setup_teardown' ) ;
13
13
14
14
var plotData = {
15
- " data" : [
15
+ ' data' : [
16
16
{
17
- " type" : " contourgl" ,
18
- "z" : [
17
+ ' type' : ' contourgl' ,
18
+ 'z' : [
19
19
[
20
20
10 ,
21
21
10.625 ,
@@ -52,35 +52,35 @@ var plotData = {
52
52
10
53
53
]
54
54
] ,
55
- " colorscale" : " Jet" ,
56
- " contours" : {
57
- " start" : 2 ,
58
- " end" : 10 ,
59
- " size" : 1
55
+ ' colorscale' : ' Jet' ,
56
+ ' contours' : {
57
+ ' start' : 2 ,
58
+ ' end' : 10 ,
59
+ ' size' : 1
60
60
} ,
61
- " uid" : " ad5624" ,
62
- " zmin" : 0 ,
63
- " zmax" : 20
61
+ ' uid' : ' ad5624' ,
62
+ ' zmin' : 0 ,
63
+ ' zmax' : 20
64
64
}
65
65
] ,
66
- " layout" : {
67
- " xaxis" : {
68
- " range" : [
66
+ ' layout' : {
67
+ ' xaxis' : {
68
+ ' range' : [
69
69
0 ,
70
70
4
71
71
] ,
72
- " autorange" : true
72
+ ' autorange' : true
73
73
} ,
74
- " yaxis" : {
75
- " range" : [
74
+ ' yaxis' : {
75
+ ' range' : [
76
76
0 ,
77
77
4
78
78
] ,
79
- " autorange" : true
79
+ ' autorange' : true
80
80
} ,
81
- " height" : 450 ,
82
- " width" : 1000 ,
83
- " autosize" : true
81
+ ' height' : 450 ,
82
+ ' width' : 1000 ,
83
+ ' autosize' : true
84
84
}
85
85
} ;
86
86
@@ -96,63 +96,63 @@ function rotate(rad, point) {
96
96
return {
97
97
x : point . x * Math . cos ( rad ) - point . y * Math . sin ( rad ) ,
98
98
y : point . x * Math . sin ( rad ) + point . y * Math . cos ( rad )
99
- }
99
+ } ;
100
100
}
101
101
102
102
function generate ( maxJitter ) {
103
- var x = d3 . range ( - 12 , 13 , 4 ) ; // left closed, right open interval
104
- var y = d3 . range ( - 12 , 13 , 4 ) ; // left closed, right open interval
103
+ var x = d3 . range ( - 1 , 1.5 , 0.5 ) ; // left closed, right open interval
104
+ var y = d3 . range ( - 1 , 1.5 , 0.5 ) ; // left closed, right open interval
105
105
var i , j , p , z = new Array ( x . length ) ;
106
106
for ( i = 0 ; i < x . length ; i ++ ) {
107
107
z [ i ] = new Array ( y . length ) ;
108
108
for ( j = 0 ; j < y . length ; j ++ ) {
109
- p = rotate ( Math . PI / 4 , { x : x [ i ] , y : - y [ j ] } )
110
- z [ i ] [ j ] = jitter ( maxJitter , Math . pow ( p . x , 2 ) / ( 10 * 10 ) + Math . pow ( p . y , 2 ) / ( 4 * 4 ) )
109
+ p = rotate ( Math . PI / 4 , { x : x [ i ] , y : - y [ j ] } ) ;
110
+ z [ i ] [ j ] = jitter ( maxJitter , Math . pow ( p . x , 2 ) + Math . pow ( p . y , 2 ) ) ;
111
111
}
112
112
}
113
- return { x : x , y : y , z : z } // looking forward to the ES2015 return {x, y, z}
113
+ return { x : x , y : y , z : z } ; // looking forward to the ES2015 return {x, y, z}
114
114
}
115
115
116
116
// equivalent to the new example case in gl-contour2d
117
117
var plotDataElliptical = function ( maxJitter ) {
118
118
var model = generate ( maxJitter ) ;
119
119
return {
120
- " data" : [
120
+ ' data' : [
121
121
{
122
- " type" : " contourgl" ,
123
- "x" : model . x ,
124
- "y" : model . y ,
125
- "z" : transpose ( model . z ) , // gl-vis is column-major order while ploly is row-major order
126
- " colorscale" : " Jet" ,
127
- " contours" : {
128
- " start" : 0 ,
129
- " end" : 2 ,
130
- " size" : 0.1 ,
131
- " coloring" : " fill"
122
+ ' type' : ' contourgl' ,
123
+ 'x' : model . x ,
124
+ 'y' : model . y ,
125
+ 'z' : transpose ( model . z ) , // gl-vis is column-major order while ploly is row-major order
126
+ ' colorscale' : ' Jet' ,
127
+ ' contours' : {
128
+ ' start' : 0 ,
129
+ ' end' : 2 ,
130
+ ' size' : 0.1 ,
131
+ ' coloring' : ' fill'
132
132
} ,
133
- " uid" : " ad5624" ,
134
- " zmin" : 0 ,
135
- " zmax" : 2
133
+ ' uid' : ' ad5624' ,
134
+ ' zmin' : 0 ,
135
+ ' zmax' : 2
136
136
}
137
137
] ,
138
- " layout" : {
139
- " xaxis" : {
140
- " range" : [
138
+ ' layout' : {
139
+ ' xaxis' : {
140
+ ' range' : [
141
141
- 10 ,
142
142
10
143
143
] ,
144
- " autorange" : true
144
+ ' autorange' : true
145
145
} ,
146
- " yaxis" : {
147
- " range" : [
146
+ ' yaxis' : {
147
+ ' range' : [
148
148
- 10 ,
149
149
10
150
150
] ,
151
- " autorange" : true
151
+ ' autorange' : true
152
152
} ,
153
- " height" : 600 ,
154
- " width" : 600 ,
155
- " autosize" : true
153
+ ' height' : 600 ,
154
+ ' width' : 600 ,
155
+ ' autosize' : true
156
156
}
157
157
} ;
158
158
} ;
@@ -162,9 +162,9 @@ function makePlot(gd, mock) {
162
162
return Plotly . plot ( gd , mock . data , mock . layout ) ;
163
163
}
164
164
165
- fdescribe ( 'contourgl plots' , function ( ) {
165
+ describe ( 'contourgl plots' , function ( ) {
166
166
167
- // this dataset is a special case, very forgiving to the contour renderer, as it's convex,
167
+ // this first dataset is a special case, very forgiving to the contour renderer, as it's convex,
168
168
// contains no inflexion points etc.
169
169
it ( 'render without raising an error' , function ( done ) {
170
170
withSetupTeardown ( done , function ( gd ) {
@@ -173,19 +173,17 @@ fdescribe('contourgl plots', function() {
173
173
} ) ;
174
174
175
175
it ( 'render without raising an error' , function ( done ) {
176
- var mock = require ( '@mocks/simple_contour_fill_gl.json' ) ;
177
- //mock.data[0].type = "contour"; // induce gl rendering
178
- //mock.data[0].contours = {coloring: "fill"}; // "fill" is the default
176
+ var mock = require ( '@mocks/gl2d_simple_contour_fill.json' ) ;
179
177
withSetupTeardown ( done , function ( gd ) {
180
178
return makePlot ( gd , mock ) ;
181
179
} ) ;
182
180
} ) ;
183
181
184
182
it ( 'render without raising an error (coloring: "lines")' , function ( done ) {
185
183
var mock = Lib . extendDeep ( { } , plotDataElliptical ( 0 ) ) ;
186
- mock . data [ 0 ] . contours . coloring = " lines" ; // " fill" is the default
184
+ mock . data [ 0 ] . contours . coloring = ' lines' ; // ' fill' is the default
187
185
withSetupTeardown ( done , function ( gd ) {
188
- return makePlot ( gd , plotDataElliptical ) ;
186
+ return makePlot ( gd , mock ) ;
189
187
} ) ;
190
188
} ) ;
191
189
@@ -196,18 +194,12 @@ fdescribe('contourgl plots', function() {
196
194
} ) ;
197
195
} ) ;
198
196
199
- fit ( 'render ellipses with added noise without raising an error (coloring: "fill")' , function ( done ) {
200
- var mock = plotDataElliptical ( 0 ) ;
201
- mock . data [ 0 ] . contours . coloring = "lines" ; // "fill" is the default
202
- mock . data [ 0 ] . type = "contourgl" ;
197
+ it ( 'render ellipses with added noise without raising an error (coloring: "fill")' , function ( done ) {
198
+ var mock = plotDataElliptical ( 0.5 ) ;
199
+ mock . data [ 0 ] . contours . coloring = 'fill' ; // 'fill' is the default
203
200
mock . data [ 0 ] . line = { smoothing : 0 } ;
204
201
withSetupTeardown ( done , function ( gd ) {
205
202
return makePlot ( gd , mock ) ;
206
203
} ) ;
207
204
} ) ;
208
-
209
-
210
-
211
-
212
-
213
205
} ) ;
0 commit comments