Skip to content

Commit 5ccd083

Browse files
committedOct 26, 2016
td -> gd once and for all
except for image server compatibility, we leave td in plotTile
1 parent 51a0563 commit 5ccd083

File tree

14 files changed

+33
-31
lines changed

14 files changed

+33
-31
lines changed
 

‎src/components/annotations/annotation_defaults.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,20 @@ module.exports = function handleAnnotationDefaults(annIn, fullLayout) {
4242
// positioning
4343
var axLetters = ['x', 'y'],
4444
arrowPosDflt = [-10, -30],
45-
tdMock = {_fullLayout: fullLayout};
45+
gdMock = {_fullLayout: fullLayout};
4646
for(var i = 0; i < 2; i++) {
4747
var axLetter = axLetters[i];
4848

4949
// xref, yref
50-
var axRef = Axes.coerceRef(annIn, annOut, tdMock, axLetter, '', 'paper');
50+
var axRef = Axes.coerceRef(annIn, annOut, gdMock, axLetter, '', 'paper');
5151

5252
// x, y
53-
Axes.coercePosition(annOut, tdMock, coerce, axRef, axLetter, 0.5);
53+
Axes.coercePosition(annOut, gdMock, coerce, axRef, axLetter, 0.5);
5454

5555
if(showArrow) {
5656
var arrowPosAttr = 'a' + axLetter,
5757
// axref, ayref
58-
aaxRef = Axes.coerceRef(annIn, annOut, tdMock, arrowPosAttr, 'pixel');
58+
aaxRef = Axes.coerceRef(annIn, annOut, gdMock, arrowPosAttr, 'pixel');
5959

6060
// for now the arrow can only be on the same axis or specified as pixels
6161
// TODO: sometime it might be interesting to allow it to be on *any* axis
@@ -66,7 +66,7 @@ module.exports = function handleAnnotationDefaults(annIn, fullLayout) {
6666

6767
// ax, ay
6868
var aDflt = (aaxRef === 'pixel') ? arrowPosDflt[i] : 0.4;
69-
Axes.coercePosition(annOut, tdMock, coerce, aaxRef, arrowPosAttr, aDflt);
69+
Axes.coercePosition(annOut, gdMock, coerce, aaxRef, arrowPosAttr, aDflt);
7070
}
7171

7272
// xanchor, yanchor

‎src/components/drawing/index.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,14 @@ drawing.getPx = function(s, styleAttr) {
7575
return Number(s.style(styleAttr).replace(/px$/, ''));
7676
};
7777

78-
drawing.crispRound = function(td, lineWidth, dflt) {
78+
drawing.crispRound = function(gd, lineWidth, dflt) {
7979
// for lines that disable antialiasing we want to
8080
// make sure the width is an integer, and at least 1 if it's nonzero
8181

8282
if(!lineWidth || !isNumeric(lineWidth)) return dflt || 0;
8383

8484
// but not for static plots - these don't get antialiased anyway.
85-
if(td._context.staticPlot) return lineWidth;
85+
if(gd._context.staticPlot) return lineWidth;
8686

8787
if(lineWidth < 1) return 1;
8888
return Math.round(lineWidth);

‎src/components/images/defaults.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ function imageDefaults(imageIn, imageOut, fullLayout) {
5353
coerce('opacity');
5454

5555
for(var i = 0; i < 2; i++) {
56-
var tdMock = { _fullLayout: fullLayout },
56+
var gdMock = { _fullLayout: fullLayout },
5757
axLetter = ['x', 'y'][i];
5858

5959
// 'paper' is the fallback axref
60-
Axes.coerceRef(imageIn, imageOut, tdMock, axLetter, 'paper');
60+
Axes.coerceRef(imageIn, imageOut, gdMock, axLetter, 'paper');
6161
}
6262

6363
return imageOut;

‎src/components/shapes/shape_defaults.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ module.exports = function handleShapeDefaults(shapeIn, fullLayout) {
3636
var axLetters = ['x', 'y'];
3737
for(var i = 0; i < 2; i++) {
3838
var axLetter = axLetters[i],
39-
tdMock = {_fullLayout: fullLayout};
39+
gdMock = {_fullLayout: fullLayout};
4040

4141
// xref, yref
42-
var axRef = Axes.coerceRef(shapeIn, shapeOut, tdMock, axLetter, '', 'paper');
42+
var axRef = Axes.coerceRef(shapeIn, shapeOut, gdMock, axLetter, '', 'paper');
4343

4444
if(shapeType !== 'path') {
4545
var dflt0 = 0.25,
@@ -49,7 +49,7 @@ module.exports = function handleShapeDefaults(shapeIn, fullLayout) {
4949
r2pos;
5050

5151
if(axRef !== 'paper') {
52-
ax = Axes.getFromId(tdMock, axRef);
52+
ax = Axes.getFromId(gdMock, axRef);
5353
r2pos = helpers.rangeToShapePosition(ax);
5454
pos2r = helpers.shapePositionToRange(ax);
5555

@@ -72,8 +72,8 @@ module.exports = function handleShapeDefaults(shapeIn, fullLayout) {
7272
shapeIn[attr1] = pos2r(shapeIn[attr1], true);
7373

7474
// x0, x1 (and y0, y1)
75-
Axes.coercePosition(shapeOut, tdMock, coerce, axRef, attr0, dflt0);
76-
Axes.coercePosition(shapeOut, tdMock, coerce, axRef, attr1, dflt1);
75+
Axes.coercePosition(shapeOut, gdMock, coerce, axRef, attr0, dflt0);
76+
Axes.coercePosition(shapeOut, gdMock, coerce, axRef, attr1, dflt1);
7777

7878
// hack part 2
7979
shapeOut[attr0] = r2pos(shapeOut[attr0]);

‎src/lib/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ lib.smooth = function(arrayIn, FWHM) {
257257
* as long as its returns are not promises (ie have no .then)
258258
* includes one argument arg to send to all functions...
259259
* this is mainly just to prevent us having to make wrapper functions
260-
* when the only purpose of the wrapper is to reference gd / td
260+
* when the only purpose of the wrapper is to reference gd
261261
* and a final step to be executed at the end
262262
* TODO: if there's an error and everything is sync,
263263
* this doesn't happen yet because we want to make sure

‎src/lib/svg_text_utils.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -111,8 +111,8 @@ exports.convertToTspans = function(_context, _callback) {
111111
}
112112

113113
if(tex) {
114-
var td = Lib.getPlotDiv(that.node());
115-
((td && td._promises) || []).push(new Promise(function(resolve) {
114+
var gd = Lib.getPlotDiv(that.node());
115+
((gd && gd._promises) || []).push(new Promise(function(resolve) {
116116
that.style({visibility: 'hidden'});
117117
var config = {fontSize: parseInt(that.style('font-size'), 10)};
118118

‎src/plot_api/to_image.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ function toImage(gd, opts) {
5252

5353
// first clone the GD so we can operate in a clean environment
5454
var clone = clonePlot(gd, {format: 'png', height: opts.height, width: opts.width});
55-
var clonedGd = clone.td;
55+
var clonedGd = clone.gd;
5656

5757
// put the cloned div somewhere off screen before attaching to DOM
5858
clonedGd.style.position = 'absolute';

‎src/plots/cartesian/axes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -89,15 +89,15 @@ axes.coerceRef = function(containerIn, containerOut, gd, attr, dflt, extraOption
8989
* - for date axes: JS Dates or milliseconds, and convert to date strings
9090
* - for other types: coerce them to numbers
9191
*/
92-
axes.coercePosition = function(containerOut, td, coerce, axRef, attr, dflt) {
92+
axes.coercePosition = function(containerOut, gd, coerce, axRef, attr, dflt) {
9393
var pos,
9494
newPos;
9595

9696
if(axRef === 'paper' || axRef === 'pixel') {
9797
pos = coerce(attr, dflt);
9898
}
9999
else {
100-
var ax = axes.getFromId(td, axRef);
100+
var ax = axes.getFromId(gd, axRef);
101101

102102
dflt = ax.fraction2r(dflt);
103103
pos = coerce(attr, dflt);

‎src/plots/cartesian/axis_autotype.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function moreDates(a) {
5454
return (dcnt > ncnt * 2);
5555
}
5656

57-
// are the (x,y)-values in td.data mostly text?
57+
// are the (x,y)-values in gd.data mostly text?
5858
// require twice as many categories as numbers
5959
function category(a) {
6060
// test at most 1000 points

‎src/plots/cartesian/layout_attributes.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ module.exports = {
4040
type: {
4141
valType: 'enumerated',
4242
// '-' means we haven't yet run autotype or couldn't find any data
43-
// it gets turned into linear in td._fullLayout but not copied back
44-
// to td.data like the others are.
43+
// it gets turned into linear in gd._fullLayout but not copied back
44+
// to gd.data like the others are.
4545
values: ['-', 'linear', 'log', 'date', 'category'],
4646
dflt: '-',
4747
role: 'info',

‎src/plots/cartesian/set_convert.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ module.exports = function setConvert(ax) {
315315
// makeCalcdata: takes an x or y array and converts it
316316
// to a position on the axis object "ax"
317317
// inputs:
318-
// trace - a data object from td.data
318+
// trace - a data object from gd.data
319319
// axLetter - a string, either 'x' or 'y', for which item
320320
// to convert (TODO: is this now always the same as
321321
// the first letter of ax._id?)

‎src/snapshot/cloneplot.js

+6-5
Original file line numberDiff line numberDiff line change
@@ -124,11 +124,12 @@ module.exports = function clonePlot(graphObj, options) {
124124
}
125125
}
126126

127-
var td = document.createElement('div');
128-
if(options.tileClass) td.className = options.tileClass;
127+
var gd = document.createElement('div');
128+
if(options.tileClass) gd.className = options.tileClass;
129129

130130
var plotTile = {
131-
td: td,
131+
gd: gd,
132+
td: gd, // for external (image server) compatibility
132133
layout: newLayout,
133134
data: newData,
134135
config: {
@@ -148,8 +149,8 @@ module.exports = function clonePlot(graphObj, options) {
148149
plotTile.config.setBackground = options.setBackground || 'opaque';
149150
}
150151

151-
// attaching the default Layout the td, so you can grab it later
152-
plotTile.td.defaultLayout = cloneLayoutOverride(options.tileClass);
152+
// attaching the default Layout the gd, so you can grab it later
153+
plotTile.gd.defaultLayout = cloneLayoutOverride(options.tileClass);
153154

154155
return plotTile;
155156
};

‎src/snapshot/toimage.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function toImage(gd, opts) {
3030
var ev = new EventEmitter();
3131

3232
var clone = clonePlot(gd, {format: 'png'});
33-
var clonedGd = clone.td;
33+
var clonedGd = clone.gd;
3434

3535
// put the cloned div somewhere off screen before attaching to DOM
3636
clonedGd.style.position = 'absolute';

‎test/jasmine/tests/snapshot_test.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,8 @@ describe('Plotly.Snapshot', function() {
8686
var themeTile = Plotly.Snapshot.clone(dummyGraphObj, themeOptions);
8787
expect(themeTile.layout.height).toEqual(THEMETILE_DEFAULT_LAYOUT.height);
8888
expect(themeTile.layout.width).toEqual(THEMETILE_DEFAULT_LAYOUT.width);
89-
expect(themeTile.td.defaultLayout).toEqual(THEMETILE_DEFAULT_LAYOUT);
89+
expect(themeTile.gd.defaultLayout).toEqual(THEMETILE_DEFAULT_LAYOUT);
90+
expect(themeTile.gd).toBe(themeTile.td); // image server compatibility
9091
expect(themeTile.config).toEqual(config);
9192
});
9293

0 commit comments

Comments
 (0)
Please sign in to comment.