Skip to content

Commit 472c135

Browse files
changed shape / annotation / image function prototypes
now they use opt instead of many arguments
1 parent a31a94a commit 472c135

File tree

1 file changed

+39
-18
lines changed

1 file changed

+39
-18
lines changed

test/jasmine/assets/domain_ref/components.js

Lines changed: 39 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,6 @@ var yAnchors = ['top', 'middle', 'bottom'];
119119
// plot so you can use d3.select('g image').node()
120120
var aroColor = 'rgb(50, 100, 150)';
121121

122-
123122
// acts on an Object representing a aro which could be a line or a rect
124123
// DEPRECATED
125124
function aroFromAROPos(aro, axletter, axnum, aropos) {
@@ -134,7 +133,6 @@ function aroFromAROPos(aro, axletter, axnum, aropos) {
134133
}
135134
}
136135

137-
138136
// {axid} is the axis id, e.g., x2, y, etc.
139137
// {ref} is ['range'|'domain'|'paper']
140138
function makeAxRef(axid, ref) {
@@ -228,8 +226,20 @@ function annaxscale(ac, c0) {
228226
// of the arrow doesn't change where the arrow meets the text box.
229227
// xaxistype can be linear|log, only used if xref has type 'range' or 'domain',
230228
// same for yaxistype and yref
231-
function annotationTest(gd, layout, x0, y0, ax, ay, xref, yref, axref, ayref,
232-
xaxistype, yaxistype, xid, yid) {
229+
function annotationTest(gd, layout, opt) {
230+
var x0 = opt.x0;
231+
var y0 = opt.y0;
232+
var ax = opt.ax;
233+
var ay = opt.ay;
234+
var xref = opt.xref;
235+
var yref = opt.yref;
236+
var axref = opt.axref;
237+
var ayref = opt.ayref;
238+
var xaxistype = opt.xaxistype;
239+
var yaxistype = opt.yaxistype;
240+
var xid = opt.xid;
241+
var yid = opt.yid;
242+
233243
// Take the log of values corresponding to log axes. This is because the
234244
// test is designed to make predicting the pixel positions easy, and it's
235245
// easiest when we work with the logarithm of values on log axes (doubling
@@ -432,7 +442,6 @@ function imageToBBox(layout, img) {
432442
return bbox;
433443
}
434444

435-
436445
function coordsEq(a, b) {
437446
if(a && b) {
438447
return Math.abs(a - b) < EQUALITY_TOLERANCE;
@@ -465,8 +474,20 @@ function findImage(id) {
465474
return ret;
466475
}
467476

468-
function imageTest(gd, layout, xaxtype, yaxtype, x, y, sizex, sizey, xanchor,
469-
yanchor, xref, yref, xid, yid) {
477+
function imageTest(gd, layout, opt) {
478+
var xaxtype = opt.xaxtype;
479+
var yaxtype = opt.yaxtype;
480+
var x = opt.x;
481+
var y = opt.y;
482+
var sizex = opt.sizex;
483+
var sizey = opt.sizey;
484+
var xanchor = opt.xanchor;
485+
var yanchor = opt.yanchor;
486+
var xref = opt.xref;
487+
var yref = opt.yref;
488+
var xid = opt.xid;
489+
var yid = opt.yid;
490+
470491
var image = {
471492
x: x,
472493
y: y,
@@ -507,16 +528,17 @@ function checkAROPosition(gd, aro) {
507528
return ret;
508529
}
509530

510-
function testShape(
531+
function shapeTest(
511532
gd,
512-
xAxNum,
513-
xaxisType,
514-
xaroPos,
515-
yAxNum,
516-
yaxisType,
517-
yaroPos,
518-
aroType
519-
) {
533+
opt) {
534+
var xAxNum = opt.xAxNum;
535+
var xaxisType = opt.xaxisType;
536+
var xaroPos = opt.xaroPos;
537+
var yAxNum = opt.yAxNum;
538+
var yaxisType = opt.yaxisType;
539+
var yaroPos = opt.yaroPos;
540+
var aroType = opt.aroType;
541+
520542
// console.log('gd.layout: ', JSON.stringify(gd.layout));
521543
var aro = {
522544
type: aroType,
@@ -572,7 +594,7 @@ function testShapeCombo(combo, assert, gd) {
572594
var yAxNum = axispair[1].substr(1);
573595
return Plotly.newPlot(gd, Lib.extendDeep({}, testMock))
574596
.then(function(gd) {
575-
return testShape(gd, xAxNum, xaxisType, xaroPos, yAxNum, yaxisType, yaroPos,
597+
return shapeTest(gd, xAxNum, xaxisType, xaroPos, yAxNum, yaxisType, yaroPos,
576598
shapeType);
577599
}).then(function(testRet) {
578600
assert(testRet);
@@ -730,7 +752,6 @@ function annotationTestDescriptions() {
730752
return comboTestDescriptions(testCombos, describeAnnotationComboTest);
731753
}
732754

733-
734755
function imageTestCombos() {
735756
var testCombos = iterToArray(iterable.cartesianProduct(
736757
[

0 commit comments

Comments
 (0)