Skip to content

Commit f32d425

Browse files
committed
lint (rename d -> pt, some unused unpacked vars)
1 parent a66dc66 commit f32d425

File tree

3 files changed

+46
-42
lines changed

3 files changed

+46
-42
lines changed

src/plots/geo/geo.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function Geo(options, fullLayout) {
4040
// a subset of https://github.com/d3/d3-geo-projection
4141
addProjectionsToD3();
4242

43-
this.showHover = fullLayout.hovermode==='closest';
43+
this.showHover = (fullLayout.hovermode === 'closest');
4444
this.hoverContainer = null;
4545

4646
this.topojsonName = null;

src/traces/choropleth/plot.js

+21-21
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ plotChoropleth.calcGeoJSON = function(trace, topojson) {
5959

6060
plotChoropleth.plot = function(geo, choroplethData, geoLayout) {
6161
var framework = geo.framework,
62-
topojson = geo.topojson,
6362
gChoropleth = framework.select('g.choroplethlayer'),
6463
gBaseLayer = framework.select('g.baselayer'),
6564
gBaseLayerOverChoropleth = framework.select('g.baselayeroverchoropleth'),
@@ -82,20 +81,20 @@ plotChoropleth.plot = function(geo, choroplethData, geoLayout) {
8281
.each(function(trace) {
8382
if(trace.visible !== true) return;
8483

85-
var cdi = plotChoropleth.calcGeoJSON(trace, topojson),
84+
var cdi = plotChoropleth.calcGeoJSON(trace, geo.topojson),
8685
cleanHoverLabelsFunc = makeCleanHoverLabelsFunc(geo, trace);
8786

88-
function handleMouseOver(d) {
87+
function handleMouseOver(pt, ptIndex) {
8988
if(!geo.showHover) return;
9089

91-
var xy = geo.projection(d.properties.ct);
92-
cleanHoverLabelsFunc(d);
90+
var xy = geo.projection(pt.properties.ct);
91+
cleanHoverLabelsFunc(pt);
9392

9493
Plotly.Fx.loneHover({
9594
x: xy[0],
9695
y: xy[1],
97-
name: d.nameLabel,
98-
text: d.textLabel
96+
name: pt.nameLabel,
97+
text: pt.textLabel
9998
}, {
10099
container: geo.hoverContainer.node()
101100
});
@@ -140,11 +139,11 @@ plotChoropleth.style = function(geo) {
140139
sclFunc = makeScaleFunction(scl, zmin, zmax);
141140

142141
s.selectAll('path.choroplethlocation')
143-
.each(function(d) {
142+
.each(function(pt) {
144143
d3.select(this)
145-
.attr('fill', function(d) { return sclFunc(d.z); })
146-
.call(Color.stroke, d.mlc || markerLine.color)
147-
.call(Drawing.dashLine, '', d.mlw || markerLine.width);
144+
.attr('fill', function(pt) { return sclFunc(pt.z); })
145+
.call(Color.stroke, pt.mlc || markerLine.color)
146+
.call(Drawing.dashLine, '', pt.mlw || markerLine.width);
148147
});
149148
});
150149
};
@@ -153,9 +152,9 @@ function makeCleanHoverLabelsFunc(geo, trace) {
153152
var hoverinfo = trace.hoverinfo;
154153

155154
if(hoverinfo === 'none') {
156-
return function cleanHoverLabelsFunc(d) {
157-
delete d.nameLabel;
158-
delete d.textLabel;
155+
return function cleanHoverLabelsFunc(pt) {
156+
delete pt.nameLabel;
157+
delete pt.textLabel;
159158
};
160159
}
161160

@@ -174,20 +173,21 @@ function makeCleanHoverLabelsFunc(geo, trace) {
174173
return Plotly.Axes.tickText(axis, axis.c2l(val), 'hover').text;
175174
}
176175

177-
return function cleanHoverLabelsFunc(d) {
176+
return function cleanHoverLabelsFunc(pt) {
178177
// put location id in name label container
179178
// if name isn't part of hoverinfo
180179
var thisText = [];
181180

182-
if(hasIdAsNameLabel) d.nameLabel = d.id;
181+
if(hasIdAsNameLabel) pt.nameLabel = pt.id;
183182
else {
184-
if(hasName) d.nameLabel = trace.name;
185-
if(hasLocation) thisText.push(d.id);
183+
if(hasName) pt.nameLabel = trace.name;
184+
if(hasLocation) thisText.push(pt.id);
186185
}
187186

188-
if(hasZ) thisText.push(formatter(d.z));
189-
if(hasText) thisText.push(d.tx);
187+
if(hasZ) thisText.push(formatter(pt.z));
188+
if(hasText) thisText.push(pt.tx);
189+
190+
pt.textLabel = thisText.join('<br>');
190191

191-
d.textLabel = thisText.join('<br>');
192192
};
193193
}

src/traces/scattergeo/plot.js

+24-20
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ function makeLineGeoJSON(trace) {
117117

118118
plotScatterGeo.plot = function(geo, scattergeoData) {
119119
var gScatterGeo = geo.framework.select('g.scattergeolayer'),
120-
topojson = geo.topojson;
121120

122121
// TODO move to more d3-idiomatic pattern (that's work on replot)
123122
// N.B. html('') does not work in IE11
@@ -152,25 +151,27 @@ plotScatterGeo.plot = function(geo, scattergeoData) {
152151
return;
153152
}
154153

155-
var cdi = plotScatterGeo.calcGeoJSON(trace, topojson),
154+
var cdi = plotScatterGeo.calcGeoJSON(trace, geo.topojson),
156155
cleanHoverLabelsFunc = makeCleanHoverLabelsFunc(geo, trace);
157156

158157
var hoverinfo = trace.hoverinfo,
159-
hasNameLabel = (hoverinfo === 'all' ||
160-
hoverinfo.indexOf('name') !== -1);
158+
hasNameLabel = (
159+
hoverinfo === 'all' ||
160+
hoverinfo.indexOf('name') !== -1
161+
);
161162

162-
function handleMouseOver(d) {
163+
function handleMouseOver(pt, ptIndex) {
163164
if(!geo.showHover) return;
164165

165-
var xy = geo.projection([d.lon, d.lat]);
166-
cleanHoverLabelsFunc(d);
166+
var xy = geo.projection([pt.lon, pt.lat]);
167+
cleanHoverLabelsFunc(pt);
167168

168169
Fx.loneHover({
169170
x: xy[0],
170171
y: xy[1],
171172
name: hasNameLabel ? trace.name : undefined,
172-
text: d.textLabel,
173-
color: d.mc || (trace.marker || {}).color
173+
text: pt.textLabel,
174+
color: pt.mc || (trace.marker || {}).color
174175
}, {
175176
container: geo.hoverContainer.node()
176177
});
@@ -237,11 +238,13 @@ function makeCleanHoverLabelsFunc(geo, trace) {
237238
}
238239

239240
var hoverinfoParts = (hoverinfo === 'all') ?
240-
attributes.hoverinfo.flags :
241-
hoverinfo.split('+');
241+
attributes.hoverinfo.flags :
242+
hoverinfo.split('+');
242243

243-
var hasLocation = (hoverinfoParts.indexOf('location') !== -1 &&
244-
Array.isArray(trace.locations)),
244+
var hasLocation = (
245+
hoverinfoParts.indexOf('location') !== -1 &&
246+
Array.isArray(trace.locations)
247+
),
245248
hasLon = (hoverinfoParts.indexOf('lon') !== -1),
246249
hasLat = (hoverinfoParts.indexOf('lat') !== -1),
247250
hasText = (hoverinfoParts.indexOf('text') !== -1);
@@ -251,18 +254,19 @@ function makeCleanHoverLabelsFunc(geo, trace) {
251254
return Axes.tickText(axis, axis.c2l(val), 'hover').text + '\u00B0';
252255
}
253256

254-
return function cleanHoverLabelsFunc(d) {
257+
return function cleanHoverLabelsFunc(pt) {
255258
var thisText = [];
256259

257-
if(hasLocation) thisText.push(d.location);
260+
if(hasLocation) thisText.push(pt.location);
258261
else if(hasLon && hasLat) {
259-
thisText.push('(' + formatter(d.lon) + ', ' + formatter(d.lat) + ')');
262+
thisText.push('(' + formatter(pt.lon) + ', ' + formatter(pt.lat) + ')');
260263
}
261-
else if(hasLon) thisText.push('lon: ' + formatter(d.lon));
262-
else if(hasLat) thisText.push('lat: ' + formatter(d.lat));
264+
else if(hasLon) thisText.push('lon: ' + formatter(pt.lon));
265+
else if(hasLat) thisText.push('lat: ' + formatter(pt.lat));
263266

264-
if(hasText) thisText.push(d.tx || trace.text);
267+
if(hasText) thisText.push(pt.tx || trace.text);
268+
269+
pt.textLabel = thisText.join('<br>');
265270

266-
d.textLabel = thisText.join('<br>');
267271
};
268272
}

0 commit comments

Comments
 (0)