(gd, closestPoints, opts)
| 2255 | } |
| 2256 | |
| 2257 | function createSpikelines(gd, closestPoints, opts) { |
| 2258 | var container = opts.container; |
| 2259 | var fullLayout = opts.fullLayout; |
| 2260 | var gs = fullLayout._size; |
| 2261 | var evt = opts.event; |
| 2262 | var showY = !!closestPoints.hLinePoint; |
| 2263 | var showX = !!closestPoints.vLinePoint; |
| 2264 | |
| 2265 | var xa, ya; |
| 2266 | |
| 2267 | // Remove old spikeline items |
| 2268 | container.selectAll('.spikeline').remove(); |
| 2269 | |
| 2270 | if (!(showX || showY)) return; |
| 2271 | |
| 2272 | var contrastColor = Color.combine(fullLayout.plot_bgcolor, fullLayout.paper_bgcolor); |
| 2273 | |
| 2274 | // Horizontal line (to y-axis) |
| 2275 | if (showY) { |
| 2276 | var hLinePoint = closestPoints.hLinePoint; |
| 2277 | var hLinePointX, hLinePointY; |
| 2278 | |
| 2279 | xa = hLinePoint && hLinePoint.xa; |
| 2280 | ya = hLinePoint && hLinePoint.ya; |
| 2281 | var ySnap = ya.spikesnap; |
| 2282 | |
| 2283 | if (ySnap === 'cursor') { |
| 2284 | hLinePointX = evt.pointerX; |
| 2285 | hLinePointY = evt.pointerY; |
| 2286 | } else { |
| 2287 | hLinePointX = xa._offset + hLinePoint.x; |
| 2288 | hLinePointY = ya._offset + hLinePoint.y; |
| 2289 | } |
| 2290 | var dfltHLineColor = |
| 2291 | tinycolor.readability(hLinePoint.color, contrastColor) < 1.5 |
| 2292 | ? Color.contrast(contrastColor) |
| 2293 | : hLinePoint.color; |
| 2294 | var yMode = ya.spikemode; |
| 2295 | var yThickness = ya.spikethickness; |
| 2296 | var yColor = ya.spikecolor || dfltHLineColor; |
| 2297 | var xEdge = Axes.getPxPosition(gd, ya); |
| 2298 | var xBase, xEndSpike; |
| 2299 | |
| 2300 | if (yMode.indexOf('toaxis') !== -1 || yMode.indexOf('across') !== -1) { |
| 2301 | if (yMode.indexOf('toaxis') !== -1) { |
| 2302 | xBase = xEdge; |
| 2303 | xEndSpike = hLinePointX; |
| 2304 | } |
| 2305 | if (yMode.indexOf('across') !== -1) { |
| 2306 | var xAcross0 = ya._counterDomainMin; |
| 2307 | var xAcross1 = ya._counterDomainMax; |
| 2308 | if (ya.anchor === 'free') { |
| 2309 | xAcross0 = Math.min(xAcross0, ya.position); |
| 2310 | xAcross1 = Math.max(xAcross1, ya.position); |
| 2311 | } |
| 2312 | xBase = gs.l + xAcross0 * gs.w; |
| 2313 | xEndSpike = gs.l + xAcross1 * gs.w; |
| 2314 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…