13
13
var Plotly = require ( '../../../../lib/index' ) ;
14
14
var d3 = require ( 'd3' ) ;
15
15
var pixelCalc = require ( '../../assets/pixel_calc' ) ;
16
- var getSVGElemScreenBBox = require (
17
- '../../assets/get_svg_elem_screen_bbox' ) ;
18
- var SVGTools = require (
19
- '../../assets/svg_tools' ) ;
16
+ var getSVGElemScreenBBox = require ( '../../assets/get_svg_elem_screen_bbox' ) ;
17
+ // var SVGTools = require('../../assets/svg_tools');
20
18
var Lib = require ( '../../../../src/lib' ) ;
21
19
var Axes = require ( '../../../../src/plots/cartesian/axes' ) ;
22
20
var axisIds = require ( '../../../../src/plots/cartesian/axis_ids' ) ;
@@ -28,6 +26,19 @@ var testMock = require('./domain_ref_base.json');
28
26
// NOTE: this tolerance is in pixels
29
27
var EQUALITY_TOLERANCE = 1e-2 ;
30
28
29
+ // Make an array from a finite iterable (for environments not having
30
+ // Array.from)
31
+ function iterToArray ( iter ) {
32
+ var a = [ ] ;
33
+ do {
34
+ var v = iter . next ( ) ;
35
+ // when done is true v.value is undefined
36
+ if ( v . done ) { return a ; }
37
+ a . push ( v . value ) ;
38
+ } while ( true ) ;
39
+ return a ;
40
+ }
41
+
31
42
// some made-up values for testing
32
43
// NOTE: The pixel values are intentionally set so that 2*pixel is never greater
33
44
// than the mock's margin. This is so that annotations are not unintentionally
@@ -492,8 +503,8 @@ function checkAROPosition(gd, aro) {
492
503
var aroPathBBox = getSVGElemScreenBBox ( aroPath ) ;
493
504
var aroBBox = shapeToBBox ( gd . layout , aro ) ;
494
505
var ret = compareBBoxes ( aroBBox , aroPathBBox ) ;
495
- console . log ( 'aroBBox: ' + JSON . stringify ( aroBBox ) ) ;
496
- console . log ( 'aroPathBBox: ' + JSON . stringify ( SVGTools . svgRectToObj ( aroPathBBox ) ) ) ;
506
+ // console.log('aroBBox: ' + JSON.stringify(aroBBox));
507
+ // console.log('aroPathBBox: ' + JSON.stringify(SVGTools.svgRectToObj(aroPathBBox)));
497
508
return ret ;
498
509
}
499
510
@@ -507,7 +518,7 @@ function testShape(
507
518
yaroPos ,
508
519
aroType
509
520
) {
510
- console . log ( 'gd.layout: ' , JSON . stringify ( gd . layout ) ) ;
521
+ // console.log('gd.layout: ', JSON.stringify(gd.layout));
511
522
var aro = {
512
523
type : aroType ,
513
524
line : {
@@ -522,7 +533,7 @@ function testShape(
522
533
// change to log axes if need be
523
534
logAxisIfAxType ( gd . layout , layout , 'x' + xAxNum , xaxisType ) ;
524
535
logAxisIfAxType ( gd . layout , layout , 'y' + yAxNum , yaxisType ) ;
525
- console . log ( 'layout: ' , JSON . stringify ( layout ) ) ;
536
+ // console.log('layout: ', JSON.stringify(layout));
526
537
return Plotly . relayout ( gd , layout )
527
538
. then ( function ( gd ) {
528
539
return checkAROPosition ( gd , aro ) ;
@@ -699,7 +710,7 @@ function comboTestDescriptions(testCombos, desribe) {
699
710
}
700
711
701
712
function annotationTestCombos ( ) {
702
- var testCombos = Array . from ( iterable . cartesianProduct ( [
713
+ var testCombos = iterToArray ( iterable . cartesianProduct ( [
703
714
axisTypes , axisTypes , axisPairs , aroPositionsX , aroPositionsY , arrowAxis
704
715
] ) ) ;
705
716
testCombos = testCombos . map (
@@ -722,7 +733,7 @@ function annotationTestDescriptions() {
722
733
723
734
724
735
function imageTestCombos ( ) {
725
- var testCombos = Array . from ( iterable . cartesianProduct (
736
+ var testCombos = iterToArray ( iterable . cartesianProduct (
726
737
[
727
738
axisTypes , axisTypes , axisPairs ,
728
739
// axis reference types are contained in here
@@ -749,7 +760,7 @@ function imageTestDescriptions() {
749
760
}
750
761
751
762
function shapeTestCombos ( ) {
752
- var testCombos = Array . from ( iterable . cartesianProduct (
763
+ var testCombos = iterToArray ( iterable . cartesianProduct (
753
764
[
754
765
axisTypes , axisTypes , axisPairs ,
755
766
// axis reference types are contained in here
0 commit comments