@@ -12,10 +12,10 @@ Plotly.register(
1212var withSetupTeardown = require ( '../assets/with_setup_teardown' ) ;
1313
1414var plotData = {
15- " data" : [
15+ ' data' : [
1616 {
17- " type" : " contourgl" ,
18- "z" : [
17+ ' type' : ' contourgl' ,
18+ 'z' : [
1919 [
2020 10 ,
2121 10.625 ,
@@ -52,35 +52,35 @@ var plotData = {
5252 10
5353 ]
5454 ] ,
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
6060 } ,
61- " uid" : " ad5624" ,
62- " zmin" : 0 ,
63- " zmax" : 20
61+ ' uid' : ' ad5624' ,
62+ ' zmin' : 0 ,
63+ ' zmax' : 20
6464 }
6565 ] ,
66- " layout" : {
67- " xaxis" : {
68- " range" : [
66+ ' layout' : {
67+ ' xaxis' : {
68+ ' range' : [
6969 0 ,
7070 4
7171 ] ,
72- " autorange" : true
72+ ' autorange' : true
7373 } ,
74- " yaxis" : {
75- " range" : [
74+ ' yaxis' : {
75+ ' range' : [
7676 0 ,
7777 4
7878 ] ,
79- " autorange" : true
79+ ' autorange' : true
8080 } ,
81- " height" : 450 ,
82- " width" : 1000 ,
83- " autosize" : true
81+ ' height' : 450 ,
82+ ' width' : 1000 ,
83+ ' autosize' : true
8484 }
8585} ;
8686
@@ -96,63 +96,63 @@ function rotate(rad, point) {
9696 return {
9797 x : point . x * Math . cos ( rad ) - point . y * Math . sin ( rad ) ,
9898 y : point . x * Math . sin ( rad ) + point . y * Math . cos ( rad )
99- }
99+ } ;
100100}
101101
102102function 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
105105 var i , j , p , z = new Array ( x . length ) ;
106106 for ( i = 0 ; i < x . length ; i ++ ) {
107107 z [ i ] = new Array ( y . length ) ;
108108 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 ) ) ;
111111 }
112112 }
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}
114114}
115115
116116// equivalent to the new example case in gl-contour2d
117117var plotDataElliptical = function ( maxJitter ) {
118118 var model = generate ( maxJitter ) ;
119119 return {
120- " data" : [
120+ ' data' : [
121121 {
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'
132132 } ,
133- " uid" : " ad5624" ,
134- " zmin" : 0 ,
135- " zmax" : 2
133+ ' uid' : ' ad5624' ,
134+ ' zmin' : 0 ,
135+ ' zmax' : 2
136136 }
137137 ] ,
138- " layout" : {
139- " xaxis" : {
140- " range" : [
138+ ' layout' : {
139+ ' xaxis' : {
140+ ' range' : [
141141 - 10 ,
142142 10
143143 ] ,
144- " autorange" : true
144+ ' autorange' : true
145145 } ,
146- " yaxis" : {
147- " range" : [
146+ ' yaxis' : {
147+ ' range' : [
148148 - 10 ,
149149 10
150150 ] ,
151- " autorange" : true
151+ ' autorange' : true
152152 } ,
153- " height" : 600 ,
154- " width" : 600 ,
155- " autosize" : true
153+ ' height' : 600 ,
154+ ' width' : 600 ,
155+ ' autosize' : true
156156 }
157157 } ;
158158} ;
@@ -162,9 +162,9 @@ function makePlot(gd, mock) {
162162 return Plotly . plot ( gd , mock . data , mock . layout ) ;
163163}
164164
165- fdescribe ( 'contourgl plots' , function ( ) {
165+ describe ( 'contourgl plots' , function ( ) {
166166
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,
168168 // contains no inflexion points etc.
169169 it ( 'render without raising an error' , function ( done ) {
170170 withSetupTeardown ( done , function ( gd ) {
@@ -173,19 +173,17 @@ fdescribe('contourgl plots', function() {
173173 } ) ;
174174
175175 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' ) ;
179177 withSetupTeardown ( done , function ( gd ) {
180178 return makePlot ( gd , mock ) ;
181179 } ) ;
182180 } ) ;
183181
184182 it ( 'render without raising an error (coloring: "lines")' , function ( done ) {
185183 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
187185 withSetupTeardown ( done , function ( gd ) {
188- return makePlot ( gd , plotDataElliptical ) ;
186+ return makePlot ( gd , mock ) ;
189187 } ) ;
190188 } ) ;
191189
@@ -196,18 +194,12 @@ fdescribe('contourgl plots', function() {
196194 } ) ;
197195 } ) ;
198196
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
203200 mock . data [ 0 ] . line = { smoothing : 0 } ;
204201 withSetupTeardown ( done , function ( gd ) {
205202 return makePlot ( gd , mock ) ;
206203 } ) ;
207204 } ) ;
208-
209-
210-
211-
212-
213205} ) ;
0 commit comments