MCPcopy Index your code
hub / github.com/leeoniya/uPlot / uPlot

Function uPlot

src/uPlot.js:291–3492  ·  view source on GitHub ↗
(opts, data, then)

Source from the content-addressed store, hash-verified

289}
290
291export 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);

Callers

nothing calls this directly

Calls 15

ifNullFunction · 0.90
placeDivFunction · 0.90
addClassFunction · 0.90
placeTagFunction · 0.90
onFunction · 0.90
copyFunction · 0.90
pxRoundGenFunction · 0.90
fnOrSelfFunction · 0.90
timeAxisValsFunction · 0.90
timeAxisStampsFunction · 0.90
timeSeriesValFunction · 0.90
timeSeriesStampFunction · 0.90

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…