1313var Plotly = require ( '../../../../lib/index' ) ;
1414var d3 = require ( 'd3' ) ;
1515var 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');
2018var Lib = require ( '../../../../src/lib' ) ;
2119var Axes = require ( '../../../../src/plots/cartesian/axes' ) ;
2220var axisIds = require ( '../../../../src/plots/cartesian/axis_ids' ) ;
@@ -28,6 +26,19 @@ var testMock = require('./domain_ref_base.json');
2826// NOTE: this tolerance is in pixels
2927var EQUALITY_TOLERANCE = 1e-2 ;
3028
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+
3142// some made-up values for testing
3243// NOTE: The pixel values are intentionally set so that 2*pixel is never greater
3344// than the mock's margin. This is so that annotations are not unintentionally
@@ -492,8 +503,8 @@ function checkAROPosition(gd, aro) {
492503 var aroPathBBox = getSVGElemScreenBBox ( aroPath ) ;
493504 var aroBBox = shapeToBBox ( gd . layout , aro ) ;
494505 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)));
497508 return ret ;
498509}
499510
@@ -507,7 +518,7 @@ function testShape(
507518 yaroPos ,
508519 aroType
509520) {
510- console . log ( 'gd.layout: ' , JSON . stringify ( gd . layout ) ) ;
521+ // console.log('gd.layout: ', JSON.stringify(gd.layout));
511522 var aro = {
512523 type : aroType ,
513524 line : {
@@ -522,7 +533,7 @@ function testShape(
522533 // change to log axes if need be
523534 logAxisIfAxType ( gd . layout , layout , 'x' + xAxNum , xaxisType ) ;
524535 logAxisIfAxType ( gd . layout , layout , 'y' + yAxNum , yaxisType ) ;
525- console . log ( 'layout: ' , JSON . stringify ( layout ) ) ;
536+ // console.log('layout: ', JSON.stringify(layout));
526537 return Plotly . relayout ( gd , layout )
527538 . then ( function ( gd ) {
528539 return checkAROPosition ( gd , aro ) ;
@@ -699,7 +710,7 @@ function comboTestDescriptions(testCombos, desribe) {
699710}
700711
701712function annotationTestCombos ( ) {
702- var testCombos = Array . from ( iterable . cartesianProduct ( [
713+ var testCombos = iterToArray ( iterable . cartesianProduct ( [
703714 axisTypes , axisTypes , axisPairs , aroPositionsX , aroPositionsY , arrowAxis
704715 ] ) ) ;
705716 testCombos = testCombos . map (
@@ -722,7 +733,7 @@ function annotationTestDescriptions() {
722733
723734
724735function imageTestCombos ( ) {
725- var testCombos = Array . from ( iterable . cartesianProduct (
736+ var testCombos = iterToArray ( iterable . cartesianProduct (
726737 [
727738 axisTypes , axisTypes , axisPairs ,
728739 // axis reference types are contained in here
@@ -749,7 +760,7 @@ function imageTestDescriptions() {
749760}
750761
751762function shapeTestCombos ( ) {
752- var testCombos = Array . from ( iterable . cartesianProduct (
763+ var testCombos = iterToArray ( iterable . cartesianProduct (
753764 [
754765 axisTypes , axisTypes , axisPairs ,
755766 // axis reference types are contained in here
0 commit comments