(gd, layout, opt)
| 228 | // xaxistype can be linear|log, only used if xref has type 'range' or 'domain', |
| 229 | // same for yaxistype and yref |
| 230 | function annotationTest(gd, layout, opt) { |
| 231 | var x0 = opt.x0; |
| 232 | var y0 = opt.y0; |
| 233 | var ax = opt.ax; |
| 234 | var ay = opt.ay; |
| 235 | var xref = opt.xref; |
| 236 | var yref = opt.yref; |
| 237 | var axref = opt.axref; |
| 238 | var ayref = opt.ayref; |
| 239 | var xaxistype = opt.xaxistype; |
| 240 | var yaxistype = opt.yaxistype; |
| 241 | var xid = opt.xid; |
| 242 | var yid = opt.yid; |
| 243 | |
| 244 | // Take the log of values corresponding to log axes. This is because the |
| 245 | // test is designed to make predicting the pixel positions easy, and it's |
| 246 | // easiest when we work with the logarithm of values on log axes (doubling |
| 247 | // the log value doubles the pixel value, etc.). |
| 248 | var xreftype = Axes.getRefType(xref); |
| 249 | var yreftype = Axes.getRefType(yref); |
| 250 | var axreftype = Axes.getRefType(axref); |
| 251 | var ayreftype = Axes.getRefType(ayref); |
| 252 | x0 = xreftype === 'range' && xaxistype === 'log' ? Math.log10(x0) : x0; |
| 253 | ax = axreftype === 'range' && xaxistype === 'log' ? Math.log10(ax) : ax; |
| 254 | y0 = yreftype === 'range' && yaxistype === 'log' ? Math.log10(y0) : y0; |
| 255 | ay = ayreftype === 'range' && yaxistype === 'log' ? Math.log10(ay) : ay; |
| 256 | // if xref != axref or axref === 'pixel' then ax is a value relative to |
| 257 | // x0 but in pixels. Same for yref |
| 258 | var axpixels = false; |
| 259 | if((axreftype === 'pixel') || (axreftype !== xreftype)) { |
| 260 | axpixels = true; |
| 261 | } |
| 262 | var aypixels = false; |
| 263 | if((ayreftype === 'pixel') || (ayreftype !== yreftype)) { |
| 264 | aypixels = true; |
| 265 | } |
| 266 | logAxisIfAxType(gd.layout, layout, xid, xaxistype); |
| 267 | logAxisIfAxType(gd.layout, layout, yid, yaxistype); |
| 268 | var xpixels; |
| 269 | var ypixels; |
| 270 | var opts0 = { |
| 271 | ax: ax, |
| 272 | ay: ay, |
| 273 | axref: axref, |
| 274 | ayref: ayref, |
| 275 | }; |
| 276 | var opts1 = { |
| 277 | ax: axpixels ? 2 * ax : annaxscale(ax, x0), |
| 278 | ay: aypixels ? 2 * ay : annaxscale(ay, y0), |
| 279 | axref: axref, |
| 280 | ayref: ayref, |
| 281 | }; |
| 282 | // 2 colors so we can extract each annotation individually |
| 283 | var color0 = 'rgb(10, 20, 30)'; |
| 284 | var color1 = 'rgb(10, 20, 31)'; |
| 285 | var anno0 = aroFromParams('annotation', x0, y0, xref, yref, color0, opts0); |
| 286 | var anno1 = aroFromParams('annotation', x0, y0, xref, yref, color1, opts1); |
| 287 | layout.annotations = [anno0, anno1]; |
no test coverage detected
searching dependent graphs…