(opts, data, then)
| 289 | } |
| 290 | |
| 291 | export default function uPlot(opts, data, then) { |
| 292 | const self = { |
| 293 | mode: ifNull(opts.mode, 1), |
| 294 | }; |
| 295 | |
| 296 | const mode = self.mode; |
| 297 | |
| 298 | function getHPos(val, scale, dim, off) { |
| 299 | let pct = scale.valToPct(val); |
| 300 | return off + dim * (scale.dir == -1 ? (1 - pct) : pct); |
| 301 | } |
| 302 | |
| 303 | function getVPos(val, scale, dim, off) { |
| 304 | let pct = scale.valToPct(val); |
| 305 | return off + dim * (scale.dir == -1 ? pct : (1 - pct)); |
| 306 | } |
| 307 | |
| 308 | function getPos(val, scale, dim, off) { |
| 309 | return scale.ori == 0 ? getHPos(val, scale, dim, off) : getVPos(val, scale, dim, off); |
| 310 | } |
| 311 | |
| 312 | self.valToPosH = getHPos; |
| 313 | self.valToPosV = getVPos; |
| 314 | |
| 315 | let ready = false; |
| 316 | self.status = 0; |
| 317 | |
| 318 | const root = self.root = placeDiv(UPLOT); |
| 319 | |
| 320 | if (opts.id != null) |
| 321 | root.id = opts.id; |
| 322 | |
| 323 | addClass(root, opts.class); |
| 324 | |
| 325 | if (opts.title) { |
| 326 | let title = placeDiv(TITLE, root); |
| 327 | title.textContent = opts.title; |
| 328 | } |
| 329 | |
| 330 | const can = placeTag("canvas"); |
| 331 | const ctx = self.ctx = can.getContext("2d"); |
| 332 | |
| 333 | const wrap = placeDiv(WRAP, root); |
| 334 | |
| 335 | on("click", wrap, e => { |
| 336 | if (e.target === over) { |
| 337 | let didDrag = mouseLeft1 != mouseLeft0 || mouseTop1 != mouseTop0; |
| 338 | didDrag && drag.click(self, e); |
| 339 | } |
| 340 | }, true); |
| 341 | |
| 342 | const under = self.under = placeDiv(UNDER, wrap); |
| 343 | wrap.appendChild(can); |
| 344 | const over = self.over = placeDiv(OVER, wrap); |
| 345 | |
| 346 | opts = copy(opts); |
| 347 | |
| 348 | const pxAlign = +ifNull(opts.pxAlign, 1); |
nothing calls this directly
no test coverage detected
searching dependent graphs…