@@ -156,6 +156,120 @@ describe('spikeline hover', function() {
156
156
. then ( done ) ;
157
157
} ) ;
158
158
159
+ it ( 'draws lines up to x-axis position' , function ( done ) {
160
+ Plotly . plot ( gd , [
161
+ { y : [ 1 , 2 , 1 ] } ,
162
+ { y : [ 2 , 1 , 2 ] , yaxis : 'y2' }
163
+ ] , {
164
+ // here the x-axis is drawn at the middle of the graph
165
+ xaxis : { showspike : true , spikemode : 'toaxis' } ,
166
+ yaxis : { domain : [ 0.5 , 1 ] } ,
167
+ yaxis2 : { anchor : 'x' , domain : [ 0 , 0.5 ] } ,
168
+ width : 400 ,
169
+ height : 400
170
+ } )
171
+ . then ( function ( ) {
172
+ _hover ( { xval : 1 , yval : 2 } ) ;
173
+ // from "y" of x-axis up to "y" of pt
174
+ _assert ( [ [ 189 , 210.5 , 189 , 109.25 ] ] , [ ] ) ;
175
+ } )
176
+ . then ( function ( ) { return Plotly . relayout ( gd , 'xaxis.spikemode' , 'across' ) ; } )
177
+ . then ( function ( ) {
178
+ _hover ( { xval : 1 , yval : 2 } ) ;
179
+ // from "y" of xy subplot top, down to "y" xy2 subplot bottom
180
+ _assert ( [ [ 189 , 100 , 189 , 320 ] ] , [ ] ) ;
181
+ } )
182
+ . catch ( failTest )
183
+ . then ( done ) ;
184
+ } ) ;
185
+
186
+ it ( 'draws lines up to y-axis position - anchor free case' , function ( done ) {
187
+ Plotly . plot ( gd , [
188
+ { y : [ 1 , 2 , 1 ] } ,
189
+ { y : [ 2 , 1 , 2 ] , xaxis : 'x2' }
190
+ ] , {
191
+ yaxis : { domain : [ 0.5 , 1 ] } ,
192
+ xaxis2 : {
193
+ anchor : 'free' , position : 0 , overlaying : 'x' ,
194
+ showspikes : true , spikemode : 'across'
195
+ } ,
196
+ width : 400 ,
197
+ height : 400 ,
198
+ showlegend : false
199
+ } )
200
+ . then ( function ( ) {
201
+ _hover ( { xval : 0 , yval : 2 } , 'x2y' ) ;
202
+ // from "y" of pt, down to "y" of x2 axis
203
+ _assert ( [ [ 95.75 , 100 , 95.75 , 320 ] ] , [ ] ) ;
204
+ } )
205
+ . then ( function ( ) { return Plotly . relayout ( gd , 'xaxis2.position' , 0.6 ) ; } )
206
+ . then ( function ( ) {
207
+ _hover ( { xval : 0 , yval : 2 } , 'x2y' ) ;
208
+ // from "y" of pt, down to "y" of x axis (which is further down)
209
+ _assert ( [ [ 95.75 , 100 , 95.75 , 210 ] ] , [ ] ) ;
210
+ } )
211
+ . catch ( failTest )
212
+ . then ( done ) ;
213
+ } ) ;
214
+
215
+ it ( 'draws lines up to y-axis position' , function ( done ) {
216
+ Plotly . plot ( gd , [
217
+ { y : [ 1 , 2 , 1 ] } ,
218
+ { y : [ 2 , 1 , 2 ] , xaxis : 'x2' }
219
+ ] , {
220
+ // here the y-axis is drawn at the middle of the graph,
221
+ // with xy subplot to the right and xy2 to the left
222
+ yaxis : { showspike : true , spikemode : 'toaxis' } ,
223
+ xaxis : { domain : [ 0.5 , 1 ] } ,
224
+ xaxis2 : { anchor : 'y' , domain : [ 0 , 0.5 ] } ,
225
+ width : 400 ,
226
+ height : 400 ,
227
+ showlegend : false
228
+ } )
229
+ . then ( function ( ) {
230
+ _hover ( { xval : 1 , yval : 2 } ) ;
231
+ // from "x" of y-axis to "x" of pt
232
+ _assert ( [ [ 199.5 , 114.75 , 260 , 114.75 ] ] , [ ] ) ;
233
+ } )
234
+ . then ( function ( ) { return Plotly . relayout ( gd , 'yaxis.spikemode' , 'across' ) ; } )
235
+ . then ( function ( ) {
236
+ _hover ( { xval : 1 , yval : 2 } ) ;
237
+ // from "x" at xy2 subplot left, to "x" at xy subplot right
238
+ _assert ( [ [ 80 , 114.75 , 320 , 114.75 ] ] , [ ] ) ;
239
+ } )
240
+ . catch ( failTest )
241
+ . then ( done ) ;
242
+ } ) ;
243
+
244
+ it ( 'draws lines up to y-axis position - anchor free case' , function ( done ) {
245
+ Plotly . plot ( gd , [
246
+ { y : [ 1 , 2 , 1 ] } ,
247
+ { y : [ 2 , 1 , 2 ] , yaxis : 'y2' }
248
+ ] , {
249
+ xaxis : { domain : [ 0.5 , 1 ] } ,
250
+ yaxis2 : {
251
+ anchor : 'free' , position : 0 , overlaying : 'y' ,
252
+ showspikes : true , spikemode : 'across'
253
+ } ,
254
+ width : 400 ,
255
+ height : 400 ,
256
+ showlegend : false
257
+ } )
258
+ . then ( function ( ) {
259
+ _hover ( { xval : 0 , yval : 2 } , 'xy2' ) ;
260
+ // from "x" of y2 axis to "x" of pt
261
+ _assert ( [ [ 80 , 114.75 , 320 , 114.75 ] ] , [ ] ) ;
262
+ } )
263
+ . then ( function ( ) { return Plotly . relayout ( gd , 'yaxis2.position' , 0.6 ) ; } )
264
+ . then ( function ( ) {
265
+ _hover ( { xval : 0 , yval : 2 } , 'xy2' ) ;
266
+ // from "x" of y axis (which is further left) to "x" of pt
267
+ _assert ( [ [ 200 , 114.75 , 320 , 114.75 ] ] , [ ] ) ;
268
+ } )
269
+ . catch ( failTest )
270
+ . then ( done ) ;
271
+ } ) ;
272
+
159
273
it ( 'draws lines and markers on enabled axes in the spikesnap "cursor" mode' , function ( done ) {
160
274
var _mock = makeMock ( 'toaxis' , 'x' ) ;
161
275
0 commit comments