update plugin files
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* uPlot.js (μPlot)
|
||||
* A small, fast chart for time series, lines, areas, ohlc & bars
|
||||
* https://github.com/leeoniya/uPlot (v1.6.5)
|
||||
* https://github.com/leeoniya/uPlot (v1.6.7)
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
@@ -257,6 +257,8 @@ const retArg1 = (_0, _1) => _1;
|
||||
|
||||
const retNull = _ => null;
|
||||
|
||||
const retTrue = _ => true;
|
||||
|
||||
function incrRoundUp(num, incr) {
|
||||
return ceil(num/incr)*incr;
|
||||
}
|
||||
@@ -317,15 +319,21 @@ function isObj(v) {
|
||||
return is;
|
||||
}
|
||||
|
||||
function copy(o) {
|
||||
function fastIsObj(v) {
|
||||
return v != null && typeof v == 'object';
|
||||
}
|
||||
|
||||
function copy(o, _isObj) {
|
||||
_isObj = _isObj || isObj;
|
||||
|
||||
let out;
|
||||
|
||||
if (isArr(o))
|
||||
out = o.map(copy);
|
||||
else if (isObj(o)) {
|
||||
out = o.map(v => copy(v, _isObj));
|
||||
else if (_isObj(o)) {
|
||||
out = {};
|
||||
for (var k in o)
|
||||
out[k] = copy(o[k]);
|
||||
out[k] = copy(o[k], _isObj);
|
||||
}
|
||||
else
|
||||
out = o;
|
||||
@@ -481,11 +489,15 @@ const win = window;
|
||||
const pxRatio = devicePixelRatio;
|
||||
|
||||
function addClass(el, c) {
|
||||
c != null && el.classList.add(c);
|
||||
if (c != null) {
|
||||
let cl = el.classList;
|
||||
!cl.contains(c) && cl.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
function remClass(el, c) {
|
||||
el.classList.remove(c);
|
||||
let cl = el.classList;
|
||||
cl.contains(c) && cl.remove(c);
|
||||
}
|
||||
|
||||
function setStylePx(el, name, value) {
|
||||
@@ -587,58 +599,49 @@ function suffix(int) {
|
||||
}
|
||||
*/
|
||||
|
||||
const getFullYear = 'getFullYear';
|
||||
const getMonth = 'getMonth';
|
||||
const getDate = 'getDate';
|
||||
const getDay = 'getDay';
|
||||
const getHours = 'getHours';
|
||||
const getMinutes = 'getMinutes';
|
||||
const getSeconds = 'getSeconds';
|
||||
const getMilliseconds = 'getMilliseconds';
|
||||
|
||||
const subs = {
|
||||
// 2019
|
||||
YYYY: d => d[getFullYear](),
|
||||
YYYY: d => d.getFullYear(),
|
||||
// 19
|
||||
YY: d => (d[getFullYear]()+'').slice(2),
|
||||
YY: d => (d.getFullYear()+'').slice(2),
|
||||
// July
|
||||
MMMM: (d, names) => names.MMMM[d[getMonth]()],
|
||||
MMMM: (d, names) => names.MMMM[d.getMonth()],
|
||||
// Jul
|
||||
MMM: (d, names) => names.MMM[d[getMonth]()],
|
||||
MMM: (d, names) => names.MMM[d.getMonth()],
|
||||
// 07
|
||||
MM: d => zeroPad2(d[getMonth]()+1),
|
||||
MM: d => zeroPad2(d.getMonth()+1),
|
||||
// 7
|
||||
M: d => d[getMonth]()+1,
|
||||
M: d => d.getMonth()+1,
|
||||
// 09
|
||||
DD: d => zeroPad2(d[getDate]()),
|
||||
DD: d => zeroPad2(d.getDate()),
|
||||
// 9
|
||||
D: d => d[getDate](),
|
||||
D: d => d.getDate(),
|
||||
// Monday
|
||||
WWWW: (d, names) => names.WWWW[d[getDay]()],
|
||||
WWWW: (d, names) => names.WWWW[d.getDay()],
|
||||
// Mon
|
||||
WWW: (d, names) => names.WWW[d[getDay]()],
|
||||
WWW: (d, names) => names.WWW[d.getDay()],
|
||||
// 03
|
||||
HH: d => zeroPad2(d[getHours]()),
|
||||
HH: d => zeroPad2(d.getHours()),
|
||||
// 3
|
||||
H: d => d[getHours](),
|
||||
H: d => d.getHours(),
|
||||
// 9 (12hr, unpadded)
|
||||
h: d => {let h = d[getHours](); return h == 0 ? 12 : h > 12 ? h - 12 : h;},
|
||||
h: d => {let h = d.getHours(); return h == 0 ? 12 : h > 12 ? h - 12 : h;},
|
||||
// AM
|
||||
AA: d => d[getHours]() >= 12 ? 'PM' : 'AM',
|
||||
AA: d => d.getHours() >= 12 ? 'PM' : 'AM',
|
||||
// am
|
||||
aa: d => d[getHours]() >= 12 ? 'pm' : 'am',
|
||||
aa: d => d.getHours() >= 12 ? 'pm' : 'am',
|
||||
// a
|
||||
a: d => d[getHours]() >= 12 ? 'p' : 'a',
|
||||
a: d => d.getHours() >= 12 ? 'p' : 'a',
|
||||
// 09
|
||||
mm: d => zeroPad2(d[getMinutes]()),
|
||||
mm: d => zeroPad2(d.getMinutes()),
|
||||
// 9
|
||||
m: d => d[getMinutes](),
|
||||
m: d => d.getMinutes(),
|
||||
// 09
|
||||
ss: d => zeroPad2(d[getSeconds]()),
|
||||
ss: d => zeroPad2(d.getSeconds()),
|
||||
// 9
|
||||
s: d => d[getSeconds](),
|
||||
s: d => d.getSeconds(),
|
||||
// 374
|
||||
fff: d => zeroPad3(d[getMilliseconds]()),
|
||||
fff: d => zeroPad3(d.getMilliseconds()),
|
||||
};
|
||||
|
||||
function fmtDate(tpl, names) {
|
||||
@@ -667,13 +670,13 @@ function tzDate(date, tz) {
|
||||
let date2;
|
||||
|
||||
// perf optimization
|
||||
if (tz == 'Etc/UTC')
|
||||
if (tz == 'UTC' || tz == 'Etc/UTC')
|
||||
date2 = new Date(+date + date.getTimezoneOffset() * 6e4);
|
||||
else if (tz == localTz)
|
||||
date2 = date;
|
||||
else {
|
||||
date2 = new Date(date.toLocaleString('en-US', {timeZone: tz}));
|
||||
date2.setMilliseconds(date[getMilliseconds]());
|
||||
date2.setMilliseconds(date.getMilliseconds());
|
||||
}
|
||||
|
||||
return date2;
|
||||
@@ -804,17 +807,17 @@ function genTimeStuffs(ms) {
|
||||
let minDateTs = minDate * ms;
|
||||
|
||||
// get ts of 12am (this lands us at or before the original scaleMin)
|
||||
let minMin = mkDate(minDate[getFullYear](), isYr ? 0 : minDate[getMonth](), isMo || isYr ? 1 : minDate[getDate]());
|
||||
let minMin = mkDate(minDate.getFullYear(), isYr ? 0 : minDate.getMonth(), isMo || isYr ? 1 : minDate.getDate());
|
||||
let minMinTs = minMin * ms;
|
||||
|
||||
if (isMo || isYr) {
|
||||
let moIncr = isMo ? foundIncr / mo : 0;
|
||||
let yrIncr = isYr ? foundIncr / y : 0;
|
||||
// let tzOffset = scaleMin - minDateTs; // needed?
|
||||
let split = minDateTs == minMinTs ? minDateTs : mkDate(minMin[getFullYear]() + yrIncr, minMin[getMonth]() + moIncr, 1) * ms;
|
||||
let split = minDateTs == minMinTs ? minDateTs : mkDate(minMin.getFullYear() + yrIncr, minMin.getMonth() + moIncr, 1) * ms;
|
||||
let splitDate = new Date(split / ms);
|
||||
let baseYear = splitDate[getFullYear]();
|
||||
let baseMonth = splitDate[getMonth]();
|
||||
let baseYear = splitDate.getFullYear();
|
||||
let baseMonth = splitDate.getMonth();
|
||||
|
||||
for (let i = 0; split <= scaleMax; i++) {
|
||||
let next = mkDate(baseYear + yrIncr * i, baseMonth + moIncr * i, 1);
|
||||
@@ -834,7 +837,7 @@ function genTimeStuffs(ms) {
|
||||
|
||||
let date0 = tzDate(split);
|
||||
|
||||
let prevHour = date0[getHours]() + (date0[getMinutes]() / m) + (date0[getSeconds]() / h);
|
||||
let prevHour = date0.getHours() + (date0.getMinutes() / m) + (date0.getSeconds() / h);
|
||||
let incrHours = foundIncr / h;
|
||||
|
||||
let minSpace = self.axes[axisIdx]._space;
|
||||
@@ -923,12 +926,12 @@ function timeAxisVals(tzDate, stamps) {
|
||||
return splits.map(split => {
|
||||
let date = tzDate(split);
|
||||
|
||||
let newYear = date[getFullYear]();
|
||||
let newMnth = date[getMonth]();
|
||||
let newDate = date[getDate]();
|
||||
let newHour = date[getHours]();
|
||||
let newMins = date[getMinutes]();
|
||||
let newSecs = date[getSeconds]();
|
||||
let newYear = date.getFullYear();
|
||||
let newMnth = date.getMonth();
|
||||
let newDate = date.getDate();
|
||||
let newHour = date.getHours();
|
||||
let newMins = date.getMinutes();
|
||||
let newSecs = date.getSeconds();
|
||||
|
||||
let stamp = (
|
||||
newYear != prevYear && s[2] ||
|
||||
@@ -1841,6 +1844,8 @@ function catmullRomFitting(xCoords, yCoords, alpha, moveTo, bezierCurveTo) {
|
||||
|
||||
function stepped(opts) {
|
||||
const align = ifNull(opts.align, 1);
|
||||
// whether to draw ascenders/descenders at null/gap bondaries
|
||||
const ascDesc = ifNull(opts.ascDesc, false);
|
||||
|
||||
return (u, seriesIdx, idx0, idx1) => {
|
||||
return orient(u, seriesIdx, (series, dataX, dataY, scaleX, scaleY, valToPosX, valToPosY, xOff, yOff, xDim, yDim) => {
|
||||
@@ -1885,8 +1890,9 @@ function stepped(opts) {
|
||||
let halfStroke = (series.width * pxRatio) / 2;
|
||||
|
||||
let lastGap = gaps[gaps.length - 1];
|
||||
lastGap[0] += halfStroke;
|
||||
lastGap[1] -= halfStroke;
|
||||
|
||||
lastGap[0] += (ascDesc || align == 1) ? halfStroke : -halfStroke;
|
||||
lastGap[1] -= (ascDesc || align == -1) ? halfStroke : -halfStroke;
|
||||
}
|
||||
|
||||
inGap = false;
|
||||
@@ -2183,7 +2189,9 @@ function uPlot(opts, data, then) {
|
||||
|
||||
let rn = sc.range;
|
||||
|
||||
if (scaleKey != xScaleKey && !isArr(rn) && isObj(rn)) {
|
||||
let rangeIsArr = isArr(rn);
|
||||
|
||||
if (scaleKey != xScaleKey && !rangeIsArr && isObj(rn)) {
|
||||
let cfg = rn;
|
||||
// this is similar to snapNumY
|
||||
rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg);
|
||||
@@ -2194,7 +2202,7 @@ function uPlot(opts, data, then) {
|
||||
(sc.distr == 3 ? snapLogY : sc.distr == 4 ? snapAsinhY : snapNumY)
|
||||
));
|
||||
|
||||
sc.auto = fnOrSelf(sc.auto);
|
||||
sc.auto = fnOrSelf(rangeIsArr ? false : sc.auto);
|
||||
|
||||
sc.clamp = fnOrSelf(sc.clamp || clampScale);
|
||||
|
||||
@@ -2271,8 +2279,10 @@ function uPlot(opts, data, then) {
|
||||
for (let k in scales) {
|
||||
let sc = scales[k];
|
||||
|
||||
if (sc.min != null || sc.max != null)
|
||||
if (sc.min != null || sc.max != null) {
|
||||
pendScales[k] = {min: sc.min, max: sc.max};
|
||||
sc.min = sc.max = null;
|
||||
}
|
||||
}
|
||||
|
||||
// self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
@@ -2774,7 +2784,7 @@ function uPlot(opts, data, then) {
|
||||
else
|
||||
_setScale(xScaleKey, xsc.min, xsc.max);
|
||||
|
||||
shouldSetCursor = true;
|
||||
shouldSetCursor = cursor.left >= 0;
|
||||
shouldSetLegend = true;
|
||||
commit();
|
||||
}
|
||||
@@ -2830,7 +2840,7 @@ function uPlot(opts, data, then) {
|
||||
// log("setScales()", arguments);
|
||||
|
||||
// wip scales
|
||||
let wipScales = copy(scales);
|
||||
let wipScales = copy(scales, fastIsObj);
|
||||
|
||||
for (let k in wipScales) {
|
||||
let wsc = wipScales[k];
|
||||
@@ -2957,7 +2967,7 @@ function uPlot(opts, data, then) {
|
||||
}
|
||||
|
||||
if (cursor.show)
|
||||
shouldSetCursor = true;
|
||||
shouldSetCursor = cursor.left >= 0;
|
||||
}
|
||||
|
||||
for (let k in pendScales)
|
||||
@@ -3503,6 +3513,13 @@ function uPlot(opts, data, then) {
|
||||
shouldSetSize = false;
|
||||
}
|
||||
|
||||
if (fullWidCss > 0 && fullHgtCss > 0) {
|
||||
ctx.clearRect(0, 0, can.width, can.height);
|
||||
fire("drawClear");
|
||||
drawOrder.forEach(fn => fn());
|
||||
fire("draw");
|
||||
}
|
||||
|
||||
// if (shouldSetSelect) {
|
||||
// TODO: update .u-select metrics (if visible)
|
||||
// setStylePx(selectDiv, TOP, select.top = 0);
|
||||
@@ -3519,13 +3536,6 @@ function uPlot(opts, data, then) {
|
||||
|
||||
// if (FEAT_LEGEND && legend.show && legend.live && shouldSetLegend) {}
|
||||
|
||||
if (fullWidCss > 0 && fullHgtCss > 0) {
|
||||
ctx.clearRect(0, 0, can.width, can.height);
|
||||
fire("drawClear");
|
||||
drawOrder.forEach(fn => fn());
|
||||
fire("draw");
|
||||
}
|
||||
|
||||
if (!ready) {
|
||||
ready = true;
|
||||
self.status = 1;
|
||||
@@ -3679,7 +3689,6 @@ function uPlot(opts, data, then) {
|
||||
|
||||
let s = series[i];
|
||||
|
||||
// will this cause redundant commit() if both show and focus are set?
|
||||
if (opts.focus != null)
|
||||
setFocus(i);
|
||||
|
||||
@@ -3693,12 +3702,12 @@ function uPlot(opts, data, then) {
|
||||
|
||||
fire("setSeries", i, opts);
|
||||
|
||||
pub && sync.pub("setSeries", self, i, opts);
|
||||
pub && pubSync("setSeries", self, i, opts);
|
||||
}
|
||||
|
||||
self.setSeries = setSeries;
|
||||
|
||||
function _alpha(i, value) {
|
||||
function setAlpha(i, value) {
|
||||
series[i].alpha = value;
|
||||
|
||||
if (cursor.show && cursorPts[i])
|
||||
@@ -3708,11 +3717,6 @@ function uPlot(opts, data, then) {
|
||||
legendRows[i][0].parentNode.style.opacity = value;
|
||||
}
|
||||
|
||||
function _setAlpha(i, value) {
|
||||
|
||||
_alpha(i, value);
|
||||
}
|
||||
|
||||
// y-distance
|
||||
let closestDist;
|
||||
let closestSeries;
|
||||
@@ -3726,14 +3730,16 @@ function uPlot(opts, data, then) {
|
||||
|
||||
let allFocused = i == null;
|
||||
|
||||
let _setAlpha = focus.alpha != 1;
|
||||
|
||||
series.forEach((s, i2) => {
|
||||
let isFocused = allFocused || i2 == 0 || i2 == i;
|
||||
s._focus = allFocused ? null : isFocused;
|
||||
_setAlpha(i2, isFocused ? 1 : focus.alpha);
|
||||
_setAlpha && setAlpha(i2, isFocused ? 1 : focus.alpha);
|
||||
});
|
||||
|
||||
focusedSeries = i;
|
||||
commit();
|
||||
_setAlpha && commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4006,7 +4012,7 @@ function uPlot(opts, data, then) {
|
||||
let uni = drag.uni;
|
||||
|
||||
if (uni != null) {
|
||||
// only calc drag status if they pass the dist asinh
|
||||
// only calc drag status if they pass the dist thresh
|
||||
if (dragX && dragY) {
|
||||
dragX = rawDX >= uni;
|
||||
dragY = rawDY >= uni;
|
||||
@@ -4076,7 +4082,7 @@ function uPlot(opts, data, then) {
|
||||
if (ts != null) {
|
||||
// this is not technically a "mousemove" event, since it's debounced, rename to setCursor?
|
||||
// since this is internal, we can tweak it later
|
||||
sync.pub(mousemove, self, mouseLeft1, mouseTop1, xDim, yDim, idx);
|
||||
pubSync(mousemove, self, mouseLeft1, mouseTop1, xDim, yDim, idx);
|
||||
|
||||
if (cursorFocus) {
|
||||
let o = syncOpts.setSeries;
|
||||
@@ -4201,7 +4207,7 @@ function uPlot(opts, data, then) {
|
||||
|
||||
if (e != null) {
|
||||
onMouse(mouseup, doc, mouseUp);
|
||||
sync.pub(mousedown, self, mouseLeft0, mouseTop0, plotWidCss, plotHgtCss, null);
|
||||
pubSync(mousedown, self, mouseLeft0, mouseTop0, plotWidCss, plotHgtCss, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4265,7 +4271,7 @@ function uPlot(opts, data, then) {
|
||||
|
||||
if (e != null) {
|
||||
offMouse(mouseup, doc);
|
||||
sync.pub(mouseup, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
pubSync(mouseup, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4324,7 +4330,7 @@ function uPlot(opts, data, then) {
|
||||
hideSelect();
|
||||
|
||||
if (e != null)
|
||||
sync.pub(dblclick, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
pubSync(dblclick, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
}
|
||||
|
||||
// internal pub/sub
|
||||
@@ -4375,6 +4381,10 @@ function uPlot(opts, data, then) {
|
||||
const syncOpts = assign({
|
||||
key: null,
|
||||
setSeries: false,
|
||||
filters: {
|
||||
pub: retTrue,
|
||||
sub: retTrue,
|
||||
},
|
||||
scales: [xScaleKey, null]
|
||||
}, cursor.sync);
|
||||
|
||||
@@ -4382,10 +4392,16 @@ function uPlot(opts, data, then) {
|
||||
|
||||
const sync = _sync(syncKey);
|
||||
|
||||
function pubSync(type, src, x, y, w, h, i) {
|
||||
if (syncOpts.filters.pub(type, src, x, y, w, h, i))
|
||||
sync.pub(type, src, x, y, w, h, i);
|
||||
}
|
||||
|
||||
sync.sub(self);
|
||||
|
||||
function pub(type, src, x, y, w, h, i) {
|
||||
events[type](null, src, x, y, w, h, i);
|
||||
if (syncOpts.filters.sub(type, src, x, y, w, h, i))
|
||||
events[type](null, src, x, y, w, h, i);
|
||||
}
|
||||
|
||||
(self.pub = pub);
|
||||
@@ -4412,6 +4428,8 @@ function uPlot(opts, data, then) {
|
||||
|
||||
_setSize(opts.width, opts.height);
|
||||
|
||||
updateCursor();
|
||||
|
||||
setSelect(select, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* uPlot.js (μPlot)
|
||||
* A small, fast chart for time series, lines, areas, ohlc & bars
|
||||
* https://github.com/leeoniya/uPlot (v1.6.5)
|
||||
* https://github.com/leeoniya/uPlot (v1.6.7)
|
||||
*/
|
||||
|
||||
const FEAT_TIME = true;
|
||||
@@ -255,6 +255,8 @@ const retArg1 = (_0, _1) => _1;
|
||||
|
||||
const retNull = _ => null;
|
||||
|
||||
const retTrue = _ => true;
|
||||
|
||||
function incrRoundUp(num, incr) {
|
||||
return ceil(num/incr)*incr;
|
||||
}
|
||||
@@ -315,15 +317,21 @@ function isObj(v) {
|
||||
return is;
|
||||
}
|
||||
|
||||
function copy(o) {
|
||||
function fastIsObj(v) {
|
||||
return v != null && typeof v == 'object';
|
||||
}
|
||||
|
||||
function copy(o, _isObj) {
|
||||
_isObj = _isObj || isObj;
|
||||
|
||||
let out;
|
||||
|
||||
if (isArr(o))
|
||||
out = o.map(copy);
|
||||
else if (isObj(o)) {
|
||||
out = o.map(v => copy(v, _isObj));
|
||||
else if (_isObj(o)) {
|
||||
out = {};
|
||||
for (var k in o)
|
||||
out[k] = copy(o[k]);
|
||||
out[k] = copy(o[k], _isObj);
|
||||
}
|
||||
else
|
||||
out = o;
|
||||
@@ -479,11 +487,15 @@ const win = window;
|
||||
const pxRatio = devicePixelRatio;
|
||||
|
||||
function addClass(el, c) {
|
||||
c != null && el.classList.add(c);
|
||||
if (c != null) {
|
||||
let cl = el.classList;
|
||||
!cl.contains(c) && cl.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
function remClass(el, c) {
|
||||
el.classList.remove(c);
|
||||
let cl = el.classList;
|
||||
cl.contains(c) && cl.remove(c);
|
||||
}
|
||||
|
||||
function setStylePx(el, name, value) {
|
||||
@@ -585,58 +597,49 @@ function suffix(int) {
|
||||
}
|
||||
*/
|
||||
|
||||
const getFullYear = 'getFullYear';
|
||||
const getMonth = 'getMonth';
|
||||
const getDate = 'getDate';
|
||||
const getDay = 'getDay';
|
||||
const getHours = 'getHours';
|
||||
const getMinutes = 'getMinutes';
|
||||
const getSeconds = 'getSeconds';
|
||||
const getMilliseconds = 'getMilliseconds';
|
||||
|
||||
const subs = {
|
||||
// 2019
|
||||
YYYY: d => d[getFullYear](),
|
||||
YYYY: d => d.getFullYear(),
|
||||
// 19
|
||||
YY: d => (d[getFullYear]()+'').slice(2),
|
||||
YY: d => (d.getFullYear()+'').slice(2),
|
||||
// July
|
||||
MMMM: (d, names) => names.MMMM[d[getMonth]()],
|
||||
MMMM: (d, names) => names.MMMM[d.getMonth()],
|
||||
// Jul
|
||||
MMM: (d, names) => names.MMM[d[getMonth]()],
|
||||
MMM: (d, names) => names.MMM[d.getMonth()],
|
||||
// 07
|
||||
MM: d => zeroPad2(d[getMonth]()+1),
|
||||
MM: d => zeroPad2(d.getMonth()+1),
|
||||
// 7
|
||||
M: d => d[getMonth]()+1,
|
||||
M: d => d.getMonth()+1,
|
||||
// 09
|
||||
DD: d => zeroPad2(d[getDate]()),
|
||||
DD: d => zeroPad2(d.getDate()),
|
||||
// 9
|
||||
D: d => d[getDate](),
|
||||
D: d => d.getDate(),
|
||||
// Monday
|
||||
WWWW: (d, names) => names.WWWW[d[getDay]()],
|
||||
WWWW: (d, names) => names.WWWW[d.getDay()],
|
||||
// Mon
|
||||
WWW: (d, names) => names.WWW[d[getDay]()],
|
||||
WWW: (d, names) => names.WWW[d.getDay()],
|
||||
// 03
|
||||
HH: d => zeroPad2(d[getHours]()),
|
||||
HH: d => zeroPad2(d.getHours()),
|
||||
// 3
|
||||
H: d => d[getHours](),
|
||||
H: d => d.getHours(),
|
||||
// 9 (12hr, unpadded)
|
||||
h: d => {let h = d[getHours](); return h == 0 ? 12 : h > 12 ? h - 12 : h;},
|
||||
h: d => {let h = d.getHours(); return h == 0 ? 12 : h > 12 ? h - 12 : h;},
|
||||
// AM
|
||||
AA: d => d[getHours]() >= 12 ? 'PM' : 'AM',
|
||||
AA: d => d.getHours() >= 12 ? 'PM' : 'AM',
|
||||
// am
|
||||
aa: d => d[getHours]() >= 12 ? 'pm' : 'am',
|
||||
aa: d => d.getHours() >= 12 ? 'pm' : 'am',
|
||||
// a
|
||||
a: d => d[getHours]() >= 12 ? 'p' : 'a',
|
||||
a: d => d.getHours() >= 12 ? 'p' : 'a',
|
||||
// 09
|
||||
mm: d => zeroPad2(d[getMinutes]()),
|
||||
mm: d => zeroPad2(d.getMinutes()),
|
||||
// 9
|
||||
m: d => d[getMinutes](),
|
||||
m: d => d.getMinutes(),
|
||||
// 09
|
||||
ss: d => zeroPad2(d[getSeconds]()),
|
||||
ss: d => zeroPad2(d.getSeconds()),
|
||||
// 9
|
||||
s: d => d[getSeconds](),
|
||||
s: d => d.getSeconds(),
|
||||
// 374
|
||||
fff: d => zeroPad3(d[getMilliseconds]()),
|
||||
fff: d => zeroPad3(d.getMilliseconds()),
|
||||
};
|
||||
|
||||
function fmtDate(tpl, names) {
|
||||
@@ -665,13 +668,13 @@ function tzDate(date, tz) {
|
||||
let date2;
|
||||
|
||||
// perf optimization
|
||||
if (tz == 'Etc/UTC')
|
||||
if (tz == 'UTC' || tz == 'Etc/UTC')
|
||||
date2 = new Date(+date + date.getTimezoneOffset() * 6e4);
|
||||
else if (tz == localTz)
|
||||
date2 = date;
|
||||
else {
|
||||
date2 = new Date(date.toLocaleString('en-US', {timeZone: tz}));
|
||||
date2.setMilliseconds(date[getMilliseconds]());
|
||||
date2.setMilliseconds(date.getMilliseconds());
|
||||
}
|
||||
|
||||
return date2;
|
||||
@@ -802,17 +805,17 @@ function genTimeStuffs(ms) {
|
||||
let minDateTs = minDate * ms;
|
||||
|
||||
// get ts of 12am (this lands us at or before the original scaleMin)
|
||||
let minMin = mkDate(minDate[getFullYear](), isYr ? 0 : minDate[getMonth](), isMo || isYr ? 1 : minDate[getDate]());
|
||||
let minMin = mkDate(minDate.getFullYear(), isYr ? 0 : minDate.getMonth(), isMo || isYr ? 1 : minDate.getDate());
|
||||
let minMinTs = minMin * ms;
|
||||
|
||||
if (isMo || isYr) {
|
||||
let moIncr = isMo ? foundIncr / mo : 0;
|
||||
let yrIncr = isYr ? foundIncr / y : 0;
|
||||
// let tzOffset = scaleMin - minDateTs; // needed?
|
||||
let split = minDateTs == minMinTs ? minDateTs : mkDate(minMin[getFullYear]() + yrIncr, minMin[getMonth]() + moIncr, 1) * ms;
|
||||
let split = minDateTs == minMinTs ? minDateTs : mkDate(minMin.getFullYear() + yrIncr, minMin.getMonth() + moIncr, 1) * ms;
|
||||
let splitDate = new Date(split / ms);
|
||||
let baseYear = splitDate[getFullYear]();
|
||||
let baseMonth = splitDate[getMonth]();
|
||||
let baseYear = splitDate.getFullYear();
|
||||
let baseMonth = splitDate.getMonth();
|
||||
|
||||
for (let i = 0; split <= scaleMax; i++) {
|
||||
let next = mkDate(baseYear + yrIncr * i, baseMonth + moIncr * i, 1);
|
||||
@@ -832,7 +835,7 @@ function genTimeStuffs(ms) {
|
||||
|
||||
let date0 = tzDate(split);
|
||||
|
||||
let prevHour = date0[getHours]() + (date0[getMinutes]() / m) + (date0[getSeconds]() / h);
|
||||
let prevHour = date0.getHours() + (date0.getMinutes() / m) + (date0.getSeconds() / h);
|
||||
let incrHours = foundIncr / h;
|
||||
|
||||
let minSpace = self.axes[axisIdx]._space;
|
||||
@@ -921,12 +924,12 @@ function timeAxisVals(tzDate, stamps) {
|
||||
return splits.map(split => {
|
||||
let date = tzDate(split);
|
||||
|
||||
let newYear = date[getFullYear]();
|
||||
let newMnth = date[getMonth]();
|
||||
let newDate = date[getDate]();
|
||||
let newHour = date[getHours]();
|
||||
let newMins = date[getMinutes]();
|
||||
let newSecs = date[getSeconds]();
|
||||
let newYear = date.getFullYear();
|
||||
let newMnth = date.getMonth();
|
||||
let newDate = date.getDate();
|
||||
let newHour = date.getHours();
|
||||
let newMins = date.getMinutes();
|
||||
let newSecs = date.getSeconds();
|
||||
|
||||
let stamp = (
|
||||
newYear != prevYear && s[2] ||
|
||||
@@ -1839,6 +1842,8 @@ function catmullRomFitting(xCoords, yCoords, alpha, moveTo, bezierCurveTo) {
|
||||
|
||||
function stepped(opts) {
|
||||
const align = ifNull(opts.align, 1);
|
||||
// whether to draw ascenders/descenders at null/gap bondaries
|
||||
const ascDesc = ifNull(opts.ascDesc, false);
|
||||
|
||||
return (u, seriesIdx, idx0, idx1) => {
|
||||
return orient(u, seriesIdx, (series, dataX, dataY, scaleX, scaleY, valToPosX, valToPosY, xOff, yOff, xDim, yDim) => {
|
||||
@@ -1883,8 +1888,9 @@ function stepped(opts) {
|
||||
let halfStroke = (series.width * pxRatio) / 2;
|
||||
|
||||
let lastGap = gaps[gaps.length - 1];
|
||||
lastGap[0] += halfStroke;
|
||||
lastGap[1] -= halfStroke;
|
||||
|
||||
lastGap[0] += (ascDesc || align == 1) ? halfStroke : -halfStroke;
|
||||
lastGap[1] -= (ascDesc || align == -1) ? halfStroke : -halfStroke;
|
||||
}
|
||||
|
||||
inGap = false;
|
||||
@@ -2181,7 +2187,9 @@ function uPlot(opts, data, then) {
|
||||
|
||||
let rn = sc.range;
|
||||
|
||||
if (scaleKey != xScaleKey && !isArr(rn) && isObj(rn)) {
|
||||
let rangeIsArr = isArr(rn);
|
||||
|
||||
if (scaleKey != xScaleKey && !rangeIsArr && isObj(rn)) {
|
||||
let cfg = rn;
|
||||
// this is similar to snapNumY
|
||||
rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg);
|
||||
@@ -2192,7 +2200,7 @@ function uPlot(opts, data, then) {
|
||||
(sc.distr == 3 ? snapLogY : sc.distr == 4 ? snapAsinhY : snapNumY)
|
||||
));
|
||||
|
||||
sc.auto = fnOrSelf(sc.auto);
|
||||
sc.auto = fnOrSelf(rangeIsArr ? false : sc.auto);
|
||||
|
||||
sc.clamp = fnOrSelf(sc.clamp || clampScale);
|
||||
|
||||
@@ -2269,8 +2277,10 @@ function uPlot(opts, data, then) {
|
||||
for (let k in scales) {
|
||||
let sc = scales[k];
|
||||
|
||||
if (sc.min != null || sc.max != null)
|
||||
if (sc.min != null || sc.max != null) {
|
||||
pendScales[k] = {min: sc.min, max: sc.max};
|
||||
sc.min = sc.max = null;
|
||||
}
|
||||
}
|
||||
|
||||
// self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
@@ -2772,7 +2782,7 @@ function uPlot(opts, data, then) {
|
||||
else
|
||||
_setScale(xScaleKey, xsc.min, xsc.max);
|
||||
|
||||
shouldSetCursor = true;
|
||||
shouldSetCursor = cursor.left >= 0;
|
||||
shouldSetLegend = true;
|
||||
commit();
|
||||
}
|
||||
@@ -2828,7 +2838,7 @@ function uPlot(opts, data, then) {
|
||||
// log("setScales()", arguments);
|
||||
|
||||
// wip scales
|
||||
let wipScales = copy(scales);
|
||||
let wipScales = copy(scales, fastIsObj);
|
||||
|
||||
for (let k in wipScales) {
|
||||
let wsc = wipScales[k];
|
||||
@@ -2955,7 +2965,7 @@ function uPlot(opts, data, then) {
|
||||
}
|
||||
|
||||
if (cursor.show)
|
||||
shouldSetCursor = true;
|
||||
shouldSetCursor = cursor.left >= 0;
|
||||
}
|
||||
|
||||
for (let k in pendScales)
|
||||
@@ -3501,6 +3511,13 @@ function uPlot(opts, data, then) {
|
||||
shouldSetSize = false;
|
||||
}
|
||||
|
||||
if (fullWidCss > 0 && fullHgtCss > 0) {
|
||||
ctx.clearRect(0, 0, can.width, can.height);
|
||||
fire("drawClear");
|
||||
drawOrder.forEach(fn => fn());
|
||||
fire("draw");
|
||||
}
|
||||
|
||||
// if (shouldSetSelect) {
|
||||
// TODO: update .u-select metrics (if visible)
|
||||
// setStylePx(selectDiv, TOP, select.top = 0);
|
||||
@@ -3517,13 +3534,6 @@ function uPlot(opts, data, then) {
|
||||
|
||||
// if (FEAT_LEGEND && legend.show && legend.live && shouldSetLegend) {}
|
||||
|
||||
if (fullWidCss > 0 && fullHgtCss > 0) {
|
||||
ctx.clearRect(0, 0, can.width, can.height);
|
||||
fire("drawClear");
|
||||
drawOrder.forEach(fn => fn());
|
||||
fire("draw");
|
||||
}
|
||||
|
||||
if (!ready) {
|
||||
ready = true;
|
||||
self.status = 1;
|
||||
@@ -3677,7 +3687,6 @@ function uPlot(opts, data, then) {
|
||||
|
||||
let s = series[i];
|
||||
|
||||
// will this cause redundant commit() if both show and focus are set?
|
||||
if (opts.focus != null)
|
||||
setFocus(i);
|
||||
|
||||
@@ -3691,12 +3700,12 @@ function uPlot(opts, data, then) {
|
||||
|
||||
fire("setSeries", i, opts);
|
||||
|
||||
pub && sync.pub("setSeries", self, i, opts);
|
||||
pub && pubSync("setSeries", self, i, opts);
|
||||
}
|
||||
|
||||
self.setSeries = setSeries;
|
||||
|
||||
function _alpha(i, value) {
|
||||
function setAlpha(i, value) {
|
||||
series[i].alpha = value;
|
||||
|
||||
if (cursor.show && cursorPts[i])
|
||||
@@ -3706,11 +3715,6 @@ function uPlot(opts, data, then) {
|
||||
legendRows[i][0].parentNode.style.opacity = value;
|
||||
}
|
||||
|
||||
function _setAlpha(i, value) {
|
||||
|
||||
_alpha(i, value);
|
||||
}
|
||||
|
||||
// y-distance
|
||||
let closestDist;
|
||||
let closestSeries;
|
||||
@@ -3724,14 +3728,16 @@ function uPlot(opts, data, then) {
|
||||
|
||||
let allFocused = i == null;
|
||||
|
||||
let _setAlpha = focus.alpha != 1;
|
||||
|
||||
series.forEach((s, i2) => {
|
||||
let isFocused = allFocused || i2 == 0 || i2 == i;
|
||||
s._focus = allFocused ? null : isFocused;
|
||||
_setAlpha(i2, isFocused ? 1 : focus.alpha);
|
||||
_setAlpha && setAlpha(i2, isFocused ? 1 : focus.alpha);
|
||||
});
|
||||
|
||||
focusedSeries = i;
|
||||
commit();
|
||||
_setAlpha && commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4004,7 +4010,7 @@ function uPlot(opts, data, then) {
|
||||
let uni = drag.uni;
|
||||
|
||||
if (uni != null) {
|
||||
// only calc drag status if they pass the dist asinh
|
||||
// only calc drag status if they pass the dist thresh
|
||||
if (dragX && dragY) {
|
||||
dragX = rawDX >= uni;
|
||||
dragY = rawDY >= uni;
|
||||
@@ -4074,7 +4080,7 @@ function uPlot(opts, data, then) {
|
||||
if (ts != null) {
|
||||
// this is not technically a "mousemove" event, since it's debounced, rename to setCursor?
|
||||
// since this is internal, we can tweak it later
|
||||
sync.pub(mousemove, self, mouseLeft1, mouseTop1, xDim, yDim, idx);
|
||||
pubSync(mousemove, self, mouseLeft1, mouseTop1, xDim, yDim, idx);
|
||||
|
||||
if (cursorFocus) {
|
||||
let o = syncOpts.setSeries;
|
||||
@@ -4199,7 +4205,7 @@ function uPlot(opts, data, then) {
|
||||
|
||||
if (e != null) {
|
||||
onMouse(mouseup, doc, mouseUp);
|
||||
sync.pub(mousedown, self, mouseLeft0, mouseTop0, plotWidCss, plotHgtCss, null);
|
||||
pubSync(mousedown, self, mouseLeft0, mouseTop0, plotWidCss, plotHgtCss, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4263,7 +4269,7 @@ function uPlot(opts, data, then) {
|
||||
|
||||
if (e != null) {
|
||||
offMouse(mouseup, doc);
|
||||
sync.pub(mouseup, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
pubSync(mouseup, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4322,7 +4328,7 @@ function uPlot(opts, data, then) {
|
||||
hideSelect();
|
||||
|
||||
if (e != null)
|
||||
sync.pub(dblclick, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
pubSync(dblclick, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
}
|
||||
|
||||
// internal pub/sub
|
||||
@@ -4373,6 +4379,10 @@ function uPlot(opts, data, then) {
|
||||
const syncOpts = assign({
|
||||
key: null,
|
||||
setSeries: false,
|
||||
filters: {
|
||||
pub: retTrue,
|
||||
sub: retTrue,
|
||||
},
|
||||
scales: [xScaleKey, null]
|
||||
}, cursor.sync);
|
||||
|
||||
@@ -4380,10 +4390,16 @@ function uPlot(opts, data, then) {
|
||||
|
||||
const sync = _sync(syncKey);
|
||||
|
||||
function pubSync(type, src, x, y, w, h, i) {
|
||||
if (syncOpts.filters.pub(type, src, x, y, w, h, i))
|
||||
sync.pub(type, src, x, y, w, h, i);
|
||||
}
|
||||
|
||||
sync.sub(self);
|
||||
|
||||
function pub(type, src, x, y, w, h, i) {
|
||||
events[type](null, src, x, y, w, h, i);
|
||||
if (syncOpts.filters.sub(type, src, x, y, w, h, i))
|
||||
events[type](null, src, x, y, w, h, i);
|
||||
}
|
||||
|
||||
(self.pub = pub);
|
||||
@@ -4410,6 +4426,8 @@ function uPlot(opts, data, then) {
|
||||
|
||||
_setSize(opts.width, opts.height);
|
||||
|
||||
updateCursor();
|
||||
|
||||
setSelect(select, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* uPlot.js (μPlot)
|
||||
* A small, fast chart for time series, lines, areas, ohlc & bars
|
||||
* https://github.com/leeoniya/uPlot (v1.6.5)
|
||||
* https://github.com/leeoniya/uPlot (v1.6.7)
|
||||
*/
|
||||
|
||||
var uPlot = (function () {
|
||||
@@ -265,6 +265,8 @@ var uPlot = (function () {
|
||||
|
||||
var retNull = _ => null;
|
||||
|
||||
var retTrue = _ => true;
|
||||
|
||||
function incrRoundUp(num, incr) {
|
||||
return ceil(num/incr)*incr;
|
||||
}
|
||||
@@ -325,15 +327,21 @@ var uPlot = (function () {
|
||||
return is;
|
||||
}
|
||||
|
||||
function copy(o) {
|
||||
function fastIsObj(v) {
|
||||
return v != null && typeof v == 'object';
|
||||
}
|
||||
|
||||
function copy(o, _isObj) {
|
||||
_isObj = _isObj || isObj;
|
||||
|
||||
var out;
|
||||
|
||||
if (isArr(o))
|
||||
{ out = o.map(copy); }
|
||||
else if (isObj(o)) {
|
||||
{ out = o.map(v => copy(v, _isObj)); }
|
||||
else if (_isObj(o)) {
|
||||
out = {};
|
||||
for (var k in o)
|
||||
{ out[k] = copy(o[k]); }
|
||||
{ out[k] = copy(o[k], _isObj); }
|
||||
}
|
||||
else
|
||||
{ out = o; }
|
||||
@@ -489,11 +497,15 @@ var uPlot = (function () {
|
||||
var pxRatio = devicePixelRatio;
|
||||
|
||||
function addClass(el, c) {
|
||||
c != null && el.classList.add(c);
|
||||
if (c != null) {
|
||||
var cl = el.classList;
|
||||
!cl.contains(c) && cl.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
function remClass(el, c) {
|
||||
el.classList.remove(c);
|
||||
var cl = el.classList;
|
||||
cl.contains(c) && cl.remove(c);
|
||||
}
|
||||
|
||||
function setStylePx(el, name, value) {
|
||||
@@ -593,58 +605,49 @@ var uPlot = (function () {
|
||||
}
|
||||
*/
|
||||
|
||||
var getFullYear = 'getFullYear';
|
||||
var getMonth = 'getMonth';
|
||||
var getDate = 'getDate';
|
||||
var getDay = 'getDay';
|
||||
var getHours = 'getHours';
|
||||
var getMinutes = 'getMinutes';
|
||||
var getSeconds = 'getSeconds';
|
||||
var getMilliseconds = 'getMilliseconds';
|
||||
|
||||
var subs = {
|
||||
// 2019
|
||||
YYYY: d => d[getFullYear](),
|
||||
YYYY: d => d.getFullYear(),
|
||||
// 19
|
||||
YY: d => (d[getFullYear]()+'').slice(2),
|
||||
YY: d => (d.getFullYear()+'').slice(2),
|
||||
// July
|
||||
MMMM: (d, names) => names.MMMM[d[getMonth]()],
|
||||
MMMM: (d, names) => names.MMMM[d.getMonth()],
|
||||
// Jul
|
||||
MMM: (d, names) => names.MMM[d[getMonth]()],
|
||||
MMM: (d, names) => names.MMM[d.getMonth()],
|
||||
// 07
|
||||
MM: d => zeroPad2(d[getMonth]()+1),
|
||||
MM: d => zeroPad2(d.getMonth()+1),
|
||||
// 7
|
||||
M: d => d[getMonth]()+1,
|
||||
M: d => d.getMonth()+1,
|
||||
// 09
|
||||
DD: d => zeroPad2(d[getDate]()),
|
||||
DD: d => zeroPad2(d.getDate()),
|
||||
// 9
|
||||
D: d => d[getDate](),
|
||||
D: d => d.getDate(),
|
||||
// Monday
|
||||
WWWW: (d, names) => names.WWWW[d[getDay]()],
|
||||
WWWW: (d, names) => names.WWWW[d.getDay()],
|
||||
// Mon
|
||||
WWW: (d, names) => names.WWW[d[getDay]()],
|
||||
WWW: (d, names) => names.WWW[d.getDay()],
|
||||
// 03
|
||||
HH: d => zeroPad2(d[getHours]()),
|
||||
HH: d => zeroPad2(d.getHours()),
|
||||
// 3
|
||||
H: d => d[getHours](),
|
||||
H: d => d.getHours(),
|
||||
// 9 (12hr, unpadded)
|
||||
h: d => {var h = d[getHours](); return h == 0 ? 12 : h > 12 ? h - 12 : h;},
|
||||
h: d => {var h = d.getHours(); return h == 0 ? 12 : h > 12 ? h - 12 : h;},
|
||||
// AM
|
||||
AA: d => d[getHours]() >= 12 ? 'PM' : 'AM',
|
||||
AA: d => d.getHours() >= 12 ? 'PM' : 'AM',
|
||||
// am
|
||||
aa: d => d[getHours]() >= 12 ? 'pm' : 'am',
|
||||
aa: d => d.getHours() >= 12 ? 'pm' : 'am',
|
||||
// a
|
||||
a: d => d[getHours]() >= 12 ? 'p' : 'a',
|
||||
a: d => d.getHours() >= 12 ? 'p' : 'a',
|
||||
// 09
|
||||
mm: d => zeroPad2(d[getMinutes]()),
|
||||
mm: d => zeroPad2(d.getMinutes()),
|
||||
// 9
|
||||
m: d => d[getMinutes](),
|
||||
m: d => d.getMinutes(),
|
||||
// 09
|
||||
ss: d => zeroPad2(d[getSeconds]()),
|
||||
ss: d => zeroPad2(d.getSeconds()),
|
||||
// 9
|
||||
s: d => d[getSeconds](),
|
||||
s: d => d.getSeconds(),
|
||||
// 374
|
||||
fff: d => zeroPad3(d[getMilliseconds]()),
|
||||
fff: d => zeroPad3(d.getMilliseconds()),
|
||||
};
|
||||
|
||||
function fmtDate(tpl, names) {
|
||||
@@ -673,13 +676,13 @@ var uPlot = (function () {
|
||||
var date2;
|
||||
|
||||
// perf optimization
|
||||
if (tz == 'Etc/UTC')
|
||||
if (tz == 'UTC' || tz == 'Etc/UTC')
|
||||
{ date2 = new Date(+date + date.getTimezoneOffset() * 6e4); }
|
||||
else if (tz == localTz)
|
||||
{ date2 = date; }
|
||||
else {
|
||||
date2 = new Date(date.toLocaleString('en-US', {timeZone: tz}));
|
||||
date2.setMilliseconds(date[getMilliseconds]());
|
||||
date2.setMilliseconds(date.getMilliseconds());
|
||||
}
|
||||
|
||||
return date2;
|
||||
@@ -808,17 +811,17 @@ var uPlot = (function () {
|
||||
var minDateTs = minDate * ms;
|
||||
|
||||
// get ts of 12am (this lands us at or before the original scaleMin)
|
||||
var minMin = mkDate(minDate[getFullYear](), isYr ? 0 : minDate[getMonth](), isMo || isYr ? 1 : minDate[getDate]());
|
||||
var minMin = mkDate(minDate.getFullYear(), isYr ? 0 : minDate.getMonth(), isMo || isYr ? 1 : minDate.getDate());
|
||||
var minMinTs = minMin * ms;
|
||||
|
||||
if (isMo || isYr) {
|
||||
var moIncr = isMo ? foundIncr / mo : 0;
|
||||
var yrIncr = isYr ? foundIncr / y : 0;
|
||||
// let tzOffset = scaleMin - minDateTs; // needed?
|
||||
var split = minDateTs == minMinTs ? minDateTs : mkDate(minMin[getFullYear]() + yrIncr, minMin[getMonth]() + moIncr, 1) * ms;
|
||||
var split = minDateTs == minMinTs ? minDateTs : mkDate(minMin.getFullYear() + yrIncr, minMin.getMonth() + moIncr, 1) * ms;
|
||||
var splitDate = new Date(split / ms);
|
||||
var baseYear = splitDate[getFullYear]();
|
||||
var baseMonth = splitDate[getMonth]();
|
||||
var baseYear = splitDate.getFullYear();
|
||||
var baseMonth = splitDate.getMonth();
|
||||
|
||||
for (var i = 0; split <= scaleMax; i++) {
|
||||
var next = mkDate(baseYear + yrIncr * i, baseMonth + moIncr * i, 1);
|
||||
@@ -838,7 +841,7 @@ var uPlot = (function () {
|
||||
|
||||
var date0 = tzDate(split$1);
|
||||
|
||||
var prevHour = date0[getHours]() + (date0[getMinutes]() / m) + (date0[getSeconds]() / h);
|
||||
var prevHour = date0.getHours() + (date0.getMinutes() / m) + (date0.getSeconds() / h);
|
||||
var incrHours = foundIncr / h;
|
||||
|
||||
var minSpace = self.axes[axisIdx]._space;
|
||||
@@ -932,12 +935,12 @@ var uPlot = (function () {
|
||||
return splits.map(split => {
|
||||
var date = tzDate(split);
|
||||
|
||||
var newYear = date[getFullYear]();
|
||||
var newMnth = date[getMonth]();
|
||||
var newDate = date[getDate]();
|
||||
var newHour = date[getHours]();
|
||||
var newMins = date[getMinutes]();
|
||||
var newSecs = date[getSeconds]();
|
||||
var newYear = date.getFullYear();
|
||||
var newMnth = date.getMonth();
|
||||
var newDate = date.getDate();
|
||||
var newHour = date.getHours();
|
||||
var newMins = date.getMinutes();
|
||||
var newSecs = date.getSeconds();
|
||||
|
||||
var stamp = (
|
||||
newYear != prevYear && s[2] ||
|
||||
@@ -1843,6 +1846,8 @@ var uPlot = (function () {
|
||||
|
||||
function stepped(opts) {
|
||||
var align = ifNull(opts.align, 1);
|
||||
// whether to draw ascenders/descenders at null/gap bondaries
|
||||
var ascDesc = ifNull(opts.ascDesc, false);
|
||||
|
||||
return (u, seriesIdx, idx0, idx1) => {
|
||||
return orient(u, seriesIdx, (series, dataX, dataY, scaleX, scaleY, valToPosX, valToPosY, xOff, yOff, xDim, yDim) => {
|
||||
@@ -1887,8 +1892,9 @@ var uPlot = (function () {
|
||||
var halfStroke = (series.width * pxRatio) / 2;
|
||||
|
||||
var lastGap = gaps[gaps.length - 1];
|
||||
lastGap[0] += halfStroke;
|
||||
lastGap[1] -= halfStroke;
|
||||
|
||||
lastGap[0] += (ascDesc || align == 1) ? halfStroke : -halfStroke;
|
||||
lastGap[1] -= (ascDesc || align == -1) ? halfStroke : -halfStroke;
|
||||
}
|
||||
|
||||
inGap = false;
|
||||
@@ -2185,7 +2191,9 @@ var uPlot = (function () {
|
||||
|
||||
var rn = sc.range;
|
||||
|
||||
if (scaleKey != xScaleKey && !isArr(rn) && isObj(rn)) {
|
||||
var rangeIsArr = isArr(rn);
|
||||
|
||||
if (scaleKey != xScaleKey && !rangeIsArr && isObj(rn)) {
|
||||
var cfg = rn;
|
||||
// this is similar to snapNumY
|
||||
rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg);
|
||||
@@ -2196,7 +2204,7 @@ var uPlot = (function () {
|
||||
(sc.distr == 3 ? snapLogY : sc.distr == 4 ? snapAsinhY : snapNumY)
|
||||
));
|
||||
|
||||
sc.auto = fnOrSelf(sc.auto);
|
||||
sc.auto = fnOrSelf(rangeIsArr ? false : sc.auto);
|
||||
|
||||
sc.clamp = fnOrSelf(sc.clamp || clampScale);
|
||||
|
||||
@@ -2273,8 +2281,10 @@ var uPlot = (function () {
|
||||
for (var k$1 in scales) {
|
||||
var sc = scales[k$1];
|
||||
|
||||
if (sc.min != null || sc.max != null)
|
||||
{ pendScales[k$1] = {min: sc.min, max: sc.max}; }
|
||||
if (sc.min != null || sc.max != null) {
|
||||
pendScales[k$1] = {min: sc.min, max: sc.max};
|
||||
sc.min = sc.max = null;
|
||||
}
|
||||
}
|
||||
|
||||
// self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone;
|
||||
@@ -2783,7 +2793,7 @@ var uPlot = (function () {
|
||||
else
|
||||
{ _setScale(xScaleKey, xsc.min, xsc.max); }
|
||||
|
||||
shouldSetCursor = true;
|
||||
shouldSetCursor = cursor.left >= 0;
|
||||
shouldSetLegend = true;
|
||||
commit();
|
||||
}
|
||||
@@ -2841,7 +2851,7 @@ var uPlot = (function () {
|
||||
// log("setScales()", arguments);
|
||||
|
||||
// wip scales
|
||||
var wipScales = copy(scales);
|
||||
var wipScales = copy(scales, fastIsObj);
|
||||
|
||||
for (var k in wipScales) {
|
||||
var wsc = wipScales[k];
|
||||
@@ -2968,7 +2978,7 @@ var uPlot = (function () {
|
||||
}
|
||||
|
||||
if (cursor.show)
|
||||
{ shouldSetCursor = true; }
|
||||
{ shouldSetCursor = cursor.left >= 0; }
|
||||
}
|
||||
|
||||
for (var k$5 in pendScales)
|
||||
@@ -3522,6 +3532,13 @@ var uPlot = (function () {
|
||||
shouldSetSize = false;
|
||||
}
|
||||
|
||||
if (fullWidCss > 0 && fullHgtCss > 0) {
|
||||
ctx.clearRect(0, 0, can.width, can.height);
|
||||
fire("drawClear");
|
||||
drawOrder.forEach(fn => fn());
|
||||
fire("draw");
|
||||
}
|
||||
|
||||
// if (shouldSetSelect) {
|
||||
// TODO: update .u-select metrics (if visible)
|
||||
// setStylePx(selectDiv, TOP, select.top = 0);
|
||||
@@ -3538,13 +3555,6 @@ var uPlot = (function () {
|
||||
|
||||
// if (FEAT_LEGEND && legend.show && legend.live && shouldSetLegend) {}
|
||||
|
||||
if (fullWidCss > 0 && fullHgtCss > 0) {
|
||||
ctx.clearRect(0, 0, can.width, can.height);
|
||||
fire("drawClear");
|
||||
drawOrder.forEach(fn => fn());
|
||||
fire("draw");
|
||||
}
|
||||
|
||||
if (!ready) {
|
||||
ready = true;
|
||||
self.status = 1;
|
||||
@@ -3698,7 +3708,6 @@ var uPlot = (function () {
|
||||
|
||||
var s = series[i];
|
||||
|
||||
// will this cause redundant commit() if both show and focus are set?
|
||||
if (opts.focus != null)
|
||||
{ setFocus(i); }
|
||||
|
||||
@@ -3712,12 +3721,12 @@ var uPlot = (function () {
|
||||
|
||||
fire("setSeries", i, opts);
|
||||
|
||||
pub && sync.pub("setSeries", self, i, opts);
|
||||
pub && pubSync("setSeries", self, i, opts);
|
||||
}
|
||||
|
||||
self.setSeries = setSeries;
|
||||
|
||||
function _alpha(i, value) {
|
||||
function setAlpha(i, value) {
|
||||
series[i].alpha = value;
|
||||
|
||||
if (cursor.show && cursorPts[i])
|
||||
@@ -3727,11 +3736,6 @@ var uPlot = (function () {
|
||||
{ legendRows[i][0].parentNode.style.opacity = value; }
|
||||
}
|
||||
|
||||
function _setAlpha(i, value) {
|
||||
|
||||
_alpha(i, value);
|
||||
}
|
||||
|
||||
// y-distance
|
||||
var closestDist;
|
||||
var closestSeries;
|
||||
@@ -3745,14 +3749,16 @@ var uPlot = (function () {
|
||||
|
||||
var allFocused = i == null;
|
||||
|
||||
var _setAlpha = focus.alpha != 1;
|
||||
|
||||
series.forEach((s, i2) => {
|
||||
var isFocused = allFocused || i2 == 0 || i2 == i;
|
||||
s._focus = allFocused ? null : isFocused;
|
||||
_setAlpha(i2, isFocused ? 1 : focus.alpha);
|
||||
_setAlpha && setAlpha(i2, isFocused ? 1 : focus.alpha);
|
||||
});
|
||||
|
||||
focusedSeries = i;
|
||||
commit();
|
||||
_setAlpha && commit();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4033,7 +4039,7 @@ var uPlot = (function () {
|
||||
var uni = drag.uni;
|
||||
|
||||
if (uni != null) {
|
||||
// only calc drag status if they pass the dist asinh
|
||||
// only calc drag status if they pass the dist thresh
|
||||
if (dragX && dragY) {
|
||||
dragX = rawDX >= uni;
|
||||
dragY = rawDY >= uni;
|
||||
@@ -4103,7 +4109,7 @@ var uPlot = (function () {
|
||||
if (ts != null) {
|
||||
// this is not technically a "mousemove" event, since it's debounced, rename to setCursor?
|
||||
// since this is internal, we can tweak it later
|
||||
sync.pub(mousemove, self, mouseLeft1, mouseTop1, xDim, yDim, idx);
|
||||
pubSync(mousemove, self, mouseLeft1, mouseTop1, xDim, yDim, idx);
|
||||
|
||||
if (cursorFocus) {
|
||||
var o = syncOpts.setSeries;
|
||||
@@ -4232,7 +4238,7 @@ var uPlot = (function () {
|
||||
|
||||
if (e != null) {
|
||||
onMouse(mouseup, doc, mouseUp);
|
||||
sync.pub(mousedown, self, mouseLeft0, mouseTop0, plotWidCss, plotHgtCss, null);
|
||||
pubSync(mousedown, self, mouseLeft0, mouseTop0, plotWidCss, plotHgtCss, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4299,7 +4305,7 @@ var uPlot = (function () {
|
||||
|
||||
if (e != null) {
|
||||
offMouse(mouseup, doc);
|
||||
sync.pub(mouseup, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
pubSync(mouseup, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4358,7 +4364,7 @@ var uPlot = (function () {
|
||||
hideSelect();
|
||||
|
||||
if (e != null)
|
||||
{ sync.pub(dblclick, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null); }
|
||||
{ pubSync(dblclick, self, mouseLeft1, mouseTop1, plotWidCss, plotHgtCss, null); }
|
||||
}
|
||||
|
||||
// internal pub/sub
|
||||
@@ -4409,6 +4415,10 @@ var uPlot = (function () {
|
||||
var syncOpts = assign({
|
||||
key: null,
|
||||
setSeries: false,
|
||||
filters: {
|
||||
pub: retTrue,
|
||||
sub: retTrue,
|
||||
},
|
||||
scales: [xScaleKey, null]
|
||||
}, cursor.sync);
|
||||
|
||||
@@ -4416,10 +4426,16 @@ var uPlot = (function () {
|
||||
|
||||
var sync = _sync(syncKey);
|
||||
|
||||
function pubSync(type, src, x, y, w, h, i) {
|
||||
if (syncOpts.filters.pub(type, src, x, y, w, h, i))
|
||||
{ sync.pub(type, src, x, y, w, h, i); }
|
||||
}
|
||||
|
||||
sync.sub(self);
|
||||
|
||||
function pub(type, src, x, y, w, h, i) {
|
||||
events[type](null, src, x, y, w, h, i);
|
||||
if (syncOpts.filters.sub(type, src, x, y, w, h, i))
|
||||
{ events[type](null, src, x, y, w, h, i); }
|
||||
}
|
||||
|
||||
(self.pub = pub);
|
||||
@@ -4446,6 +4462,8 @@ var uPlot = (function () {
|
||||
|
||||
_setSize(opts.width, opts.height);
|
||||
|
||||
updateCursor();
|
||||
|
||||
setSelect(select, false);
|
||||
}
|
||||
|
||||
|
||||
4
plugins/uplot/uPlot.iife.min.js
vendored
4
plugins/uplot/uPlot.iife.min.js
vendored
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user