update plugin files

pull/3427/head
REJack 2021-02-17 08:25:25 +01:00
parent 378a39ea12
commit 1c856b0d8c
16 changed files with 542 additions and 11665 deletions

View File

@ -9759,7 +9759,7 @@ var dropzone_Dropzone = /*#__PURE__*/function (_Emitter) {
dropzone_Dropzone.initClass(); dropzone_Dropzone.initClass();
dropzone_Dropzone.version = "5.7.4"; // This is a map of options for your different dropzones. Add configurations dropzone_Dropzone.version = "5.7.6"; // This is a map of options for your different dropzones. Add configurations
// to this object for your different dropzone elemens. // to this object for your different dropzone elemens.
// //
// Example: // Example:
@ -9867,9 +9867,9 @@ dropzone_Dropzone.discover = function () {
return result; return result;
}(); }();
}; // Since the whole Drag'n'Drop API is pretty new, some browsers implement it, }; // Some browsers support drag and drog functionality, but not correctly.
// but not correctly. //
// So I created a blacklist of userAgents. Yes, yes. Browser sniffing, I know. // So I created a blocklist of userAgents. Yes, yes. Browser sniffing, I know.
// But what to do when browsers *theoretically* support an API, but crash // But what to do when browsers *theoretically* support an API, but crash
// when using it. // when using it.
// //
@ -9877,10 +9877,9 @@ dropzone_Dropzone.discover = function () {
// //
// ** It should only be used on browser that *do* support the API, but // ** It should only be used on browser that *do* support the API, but
// incorrectly ** // incorrectly **
//
dropzone_Dropzone.blacklistedBrowsers = [// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API. dropzone_Dropzone.blockedBrowsers = [// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
/opera.*(Macintosh|Windows Phone).*version\/12/i]; // Checks if the browser is supported /opera.*(Macintosh|Windows Phone).*version\/12/i]; // Checks if the browser is supported
dropzone_Dropzone.isBrowserSupported = function () { dropzone_Dropzone.isBrowserSupported = function () {
@ -9890,8 +9889,14 @@ dropzone_Dropzone.isBrowserSupported = function () {
if (!("classList" in document.createElement("a"))) { if (!("classList" in document.createElement("a"))) {
capableBrowser = false; capableBrowser = false;
} else { } else {
// The browser supports the API, but may be blacklisted. if (dropzone_Dropzone.blacklistedBrowsers !== undefined) {
var _iterator25 = dropzone_createForOfIteratorHelper(dropzone_Dropzone.blacklistedBrowsers, true), // Since this has been renamed, this makes sure we don't break older
// configuration.
dropzone_Dropzone.blockedBrowsers = dropzone_Dropzone.blacklistedBrowsers;
} // The browser supports the API, but may be blocked.
var _iterator25 = dropzone_createForOfIteratorHelper(dropzone_Dropzone.blockedBrowsers, true),
_step25; _step25;
try { try {

View File

@ -9759,7 +9759,7 @@ var dropzone_Dropzone = /*#__PURE__*/function (_Emitter) {
dropzone_Dropzone.initClass(); dropzone_Dropzone.initClass();
dropzone_Dropzone.version = "5.7.4"; // This is a map of options for your different dropzones. Add configurations dropzone_Dropzone.version = "5.7.6"; // This is a map of options for your different dropzones. Add configurations
// to this object for your different dropzone elemens. // to this object for your different dropzone elemens.
// //
// Example: // Example:
@ -9867,9 +9867,9 @@ dropzone_Dropzone.discover = function () {
return result; return result;
}(); }();
}; // Since the whole Drag'n'Drop API is pretty new, some browsers implement it, }; // Some browsers support drag and drog functionality, but not correctly.
// but not correctly. //
// So I created a blacklist of userAgents. Yes, yes. Browser sniffing, I know. // So I created a blocklist of userAgents. Yes, yes. Browser sniffing, I know.
// But what to do when browsers *theoretically* support an API, but crash // But what to do when browsers *theoretically* support an API, but crash
// when using it. // when using it.
// //
@ -9877,10 +9877,9 @@ dropzone_Dropzone.discover = function () {
// //
// ** It should only be used on browser that *do* support the API, but // ** It should only be used on browser that *do* support the API, but
// incorrectly ** // incorrectly **
//
dropzone_Dropzone.blacklistedBrowsers = [// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API. dropzone_Dropzone.blockedBrowsers = [// The mac os and windows phone version of opera 12 seems to have a problem with the File drag'n'drop API.
/opera.*(Macintosh|Windows Phone).*version\/12/i]; // Checks if the browser is supported /opera.*(Macintosh|Windows Phone).*version\/12/i]; // Checks if the browser is supported
dropzone_Dropzone.isBrowserSupported = function () { dropzone_Dropzone.isBrowserSupported = function () {
@ -9890,8 +9889,14 @@ dropzone_Dropzone.isBrowserSupported = function () {
if (!("classList" in document.createElement("a"))) { if (!("classList" in document.createElement("a"))) {
capableBrowser = false; capableBrowser = false;
} else { } else {
// The browser supports the API, but may be blacklisted. if (dropzone_Dropzone.blacklistedBrowsers !== undefined) {
var _iterator25 = dropzone_createForOfIteratorHelper(dropzone_Dropzone.blacklistedBrowsers, true), // Since this has been renamed, this makes sure we don't break older
// configuration.
dropzone_Dropzone.blockedBrowsers = dropzone_Dropzone.blacklistedBrowsers;
} // The browser supports the API, but may be blocked.
var _iterator25 = dropzone_createForOfIteratorHelper(dropzone_Dropzone.blockedBrowsers, true),
_step25; _step25;
try { try {

View File

@ -1 +1 @@
.dropzone,.dropzone *{box-sizing:border-box}.dropzone{position:relative}.dropzone .dz-preview{position:relative;display:inline-block;width:120px;margin:0.5em}.dropzone .dz-preview .dz-progress{display:block;height:15px;border:1px solid #aaa}.dropzone .dz-preview .dz-progress .dz-upload{display:block;height:100%;width:0;background:green}.dropzone .dz-preview .dz-error-message{color:red;display:none}.dropzone .dz-preview.dz-error .dz-error-message,.dropzone .dz-preview.dz-error .dz-error-mark{display:block}.dropzone .dz-preview.dz-success .dz-success-mark{display:block}.dropzone .dz-preview .dz-error-mark,.dropzone .dz-preview .dz-success-mark{position:absolute;display:none;left:30px;top:30px;width:54px;height:58px;left:50%;margin-left:-27px} .dropzone,.dropzone *{box-sizing:border-box}.dropzone{position:relative}.dropzone .dz-preview{position:relative;display:inline-block;width:120px;margin:.5em}.dropzone .dz-preview .dz-progress{display:block;height:15px;border:1px solid #aaa}.dropzone .dz-preview .dz-progress .dz-upload{display:block;height:100%;width:0;background:green}.dropzone .dz-preview .dz-error-message{color:red;display:none}.dropzone .dz-preview.dz-error .dz-error-message,.dropzone .dz-preview.dz-error .dz-error-mark{display:block}.dropzone .dz-preview.dz-success .dz-success-mark{display:block}.dropzone .dz-preview .dz-error-mark,.dropzone .dz-preview .dz-success-mark{position:absolute;display:none;left:30px;top:30px;width:54px;height:58px;left:50%;margin-left:-27px}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*! /*!
* sweetalert2 v10.14.0 * sweetalert2 v10.14.1
* Released under the MIT License. * Released under the MIT License.
*/ */
(function (global, factory) { (function (global, factory) {
@ -363,7 +363,7 @@
}; };
var getIcon = function getIcon() { var getIcon = function getIcon() {
var visibleIcon = getIcons().filter(function (icon) { var visibleIcon = getIcons().filter(function (icon) {
return isVisible(icon); return icon.style.display !== 'none';
}); });
return visibleIcon.length ? visibleIcon[0] : null; return visibleIcon.length ? visibleIcon[0] : null;
}; };
@ -3627,7 +3627,7 @@
}; };
}); });
SweetAlert.DismissReason = DismissReason; SweetAlert.DismissReason = DismissReason;
SweetAlert.version = '10.14.0'; SweetAlert.version = '10.14.1';
var Swal = SweetAlert; var Swal = SweetAlert;
Swal["default"] = Swal; Swal["default"] = Swal;

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
/*! /*!
* sweetalert2 v10.14.0 * sweetalert2 v10.14.1
* Released under the MIT License. * Released under the MIT License.
*/ */
(function (global, factory) { (function (global, factory) {
@ -363,7 +363,7 @@
}; };
var getIcon = function getIcon() { var getIcon = function getIcon() {
var visibleIcon = getIcons().filter(function (icon) { var visibleIcon = getIcons().filter(function (icon) {
return isVisible(icon); return icon.style.display !== 'none';
}); });
return visibleIcon.length ? visibleIcon[0] : null; return visibleIcon.length ? visibleIcon[0] : null;
}; };
@ -3627,7 +3627,7 @@
}; };
}); });
SweetAlert.DismissReason = DismissReason; SweetAlert.DismissReason = DismissReason;
SweetAlert.version = '10.14.0'; SweetAlert.version = '10.14.1';
var Swal = SweetAlert; var Swal = SweetAlert;
Swal["default"] = Swal; Swal["default"] = Swal;

File diff suppressed because one or more lines are too long

View File

@ -4,7 +4,7 @@
* *
* uPlot.js (μPlot) * uPlot.js (μPlot)
* A small, fast chart for time series, lines, areas, ohlc & bars * A small, fast chart for time series, lines, areas, ohlc & bars
* https://github.com/leeoniya/uPlot (v1.6.4) * https://github.com/leeoniya/uPlot (v1.6.5)
*/ */
'use strict'; 'use strict';
@ -110,6 +110,7 @@ function fixIncr(minIncr, maxIncr, minExp, maxExp) {
} }
function rangeLog(min, max, base, fullMags) { function rangeLog(min, max, base, fullMags) {
let logFn = base == 10 ? log10 : log2; let logFn = base == 10 ? log10 : log2;
if (min == max) { if (min == max) {
@ -129,8 +130,8 @@ function rangeLog(min, max, base, fullMags) {
max = minMaxIncrs[1]; max = minMaxIncrs[1];
} }
else { else {
minExp = floor(logFn(min)); minExp = floor(logFn(abs(min)));
maxExp = floor(logFn(max)); maxExp = floor(logFn(abs(max)));
minMaxIncrs = fixIncr(pow(base, minExp), pow(base, maxExp), minExp, maxExp); minMaxIncrs = fixIncr(pow(base, minExp), pow(base, maxExp), minExp, maxExp);
@ -141,6 +142,18 @@ function rangeLog(min, max, base, fullMags) {
return [min, max]; return [min, max];
} }
function rangeAsinh(min, max, base, fullMags) {
let minMax = rangeLog(min, max, base, fullMags);
if (min == 0)
minMax[0] = 0;
if (max == 0)
minMax[1] = 0;
return minMax;
}
const _eqRangePart = { const _eqRangePart = {
pad: 0, pad: 0,
soft: null, soft: null,
@ -212,6 +225,7 @@ const fmtNum = new Intl.NumberFormat(navigator.language).format;
const M = Math; const M = Math;
const PI = M.PI;
const abs = M.abs; const abs = M.abs;
const floor = M.floor; const floor = M.floor;
const round = M.round; const round = M.round;
@ -222,7 +236,8 @@ const pow = M.pow;
const sqrt = M.sqrt; const sqrt = M.sqrt;
const log10 = M.log10; const log10 = M.log10;
const log2 = M.log2; const log2 = M.log2;
const PI = M.PI; const sinh = (v, linthresh = 1) => M.sinh(v / linthresh);
const asinh = (v, linthresh = 1) => M.asinh(v / linthresh);
const inf = Infinity; const inf = Infinity;
@ -1145,6 +1160,7 @@ function numAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace,
return splits; return splits;
} }
// this doesnt work for sin, which needs to come off from 0 independently in pos and neg dirs
function logAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) { function logAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) {
const splits = []; const splits = [];
@ -1173,6 +1189,18 @@ function logAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace,
return splits; return splits;
} }
function asinhAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) {
let sc = self.scales[self.axes[axisIdx].scale];
let linthresh = sc.asinh;
let posSplits = scaleMax > linthresh ? logAxisSplits(self, axisIdx, max(linthresh, scaleMin), scaleMax, foundIncr) : [linthresh];
let zero = scaleMax >= 0 && scaleMin <= 0 ? [0] : [];
let negSplits = scaleMin < -linthresh ? logAxisSplits(self, axisIdx, max(linthresh, -scaleMax), -scaleMin, foundIncr): [linthresh];
return negSplits.reverse().map(v => -v).concat(zero, posSplits);
}
const RE_ALL = /./; const RE_ALL = /./;
const RE_12357 = /[12357]/; const RE_12357 = /[12357]/;
const RE_125 = /[125]/; const RE_125 = /[125]/;
@ -1181,8 +1209,9 @@ const RE_1 = /1/;
function logAxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) { function logAxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) {
let axis = self.axes[axisIdx]; let axis = self.axes[axisIdx];
let scaleKey = axis.scale; let scaleKey = axis.scale;
let sc = self.scales[scaleKey];
if (self.scales[scaleKey].log == 2) if (sc.distr == 3 && sc.log == 2)
return splits; return splits;
let valToPos = self.valToPos; let valToPos = self.valToPos;
@ -1198,7 +1227,7 @@ function logAxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) {
RE_1 RE_1
); );
return splits.map(v => re.test(v) ? v : null); return splits.map(v => ((sc.distr == 4 && v == 0) || re.test(v)) ? v : null);
} }
function numSeriesVal(self, val) { function numSeriesVal(self, val) {
@ -1292,6 +1321,7 @@ const xScaleOpts = {
auto: true, auto: true,
distr: 1, distr: 1,
log: 10, log: 10,
asinh: 1,
min: null, min: null,
max: null, max: null,
dir: 1, dir: 1,
@ -1305,10 +1335,14 @@ const yScaleOpts = assign({}, xScaleOpts, {
const syncs = {}; const syncs = {};
function _sync(opts) { function _sync(key, opts) {
let s = syncs[key];
if (!s) {
let clients = []; let clients = [];
return { s = {
key,
sub(client) { sub(client) {
clients.push(client); clients.push(client);
}, },
@ -1316,13 +1350,16 @@ function _sync(opts) {
clients = clients.filter(c => c != client); clients = clients.filter(c => c != client);
}, },
pub(type, self, x, y, w, h, i) { pub(type, self, x, y, w, h, i) {
if (clients.length > 1) { for (let i = 0; i < clients.length; i++)
clients.forEach(client => { clients[i] != self && clients[i].pub(type, self, x, y, w, h, i);
client != self && client.pub(type, self, x, y, w, h, i);
});
}
} }
}; };
if (key != null)
syncs[key] = s;
}
return s;
} }
function orient(u, seriesIdx, cb) { function orient(u, seriesIdx, cb) {
@ -2012,6 +2049,12 @@ function snapLogY(self, dataMin, dataMax, scale) {
const snapLogX = snapLogY; const snapLogX = snapLogY;
function snapAsinhY(self, dataMin, dataMax, scale) {
return dataMin == null ? nullMinMax : rangeAsinh(dataMin, dataMax, self.scales[scale].log, false);
}
const snapAsinhX = snapAsinhY;
// dim is logical (getClientBoundingRect) pixels, not canvas pixels // dim is logical (getClientBoundingRect) pixels, not canvas pixels
function findIncr(min, max, incrs, dim, minSpace) { function findIncr(min, max, incrs, dim, minSpace) {
let pxPerUnit = dim / (max - min); let pxPerUnit = dim / (max - min);
@ -2039,12 +2082,15 @@ function pxRatioFont(font) {
function uPlot(opts, data, then) { function uPlot(opts, data, then) {
const self = {}; const self = {};
// TODO: cache denoms & mins scale.cache = {r, min, }
function getValPct(val, scale) { function getValPct(val, scale) {
return ( let _val = (
scale.distr == 3 scale.distr == 3 ? log10(val > 0 ? val : scale.clamp(self, val, scale.min, scale.max, scale.key)) :
? log10((val > 0 ? val : scale.clamp(self, val, scale.min, scale.max, scale.key)) / scale.min) / log10(scale.max / scale.min) scale.distr == 4 ? asinh(val, scale.asinh) :
: (val - scale.min) / (scale.max - scale.min) val
); );
return (_val - scale._min) / (scale._max - scale._min);
} }
function getHPos(val, scale, dim, off) { function getHPos(val, scale, dim, off) {
@ -2134,7 +2180,6 @@ function uPlot(opts, data, then) {
sc.key = scaleKey; sc.key = scaleKey;
let isTime = sc.time; let isTime = sc.time;
let isLog = sc.distr == 3;
let rn = sc.range; let rn = sc.range;
@ -2144,11 +2189,17 @@ function uPlot(opts, data, then) {
rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg); rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg);
} }
sc.range = fnOrSelf(rn || (isTime ? snapTimeX : scaleKey == xScaleKey ? (isLog ? snapLogX : snapNumX) : (isLog ? snapLogY : snapNumY))); sc.range = fnOrSelf(rn || (isTime ? snapTimeX : scaleKey == xScaleKey ?
(sc.distr == 3 ? snapLogX : sc.distr == 4 ? snapAsinhX : snapNumX) :
(sc.distr == 3 ? snapLogY : sc.distr == 4 ? snapAsinhY : snapNumY)
));
sc.auto = fnOrSelf(sc.auto); sc.auto = fnOrSelf(sc.auto);
sc.clamp = fnOrSelf(sc.clamp || clampScale); sc.clamp = fnOrSelf(sc.clamp || clampScale);
// caches for expensive ops like asinh() & log()
sc._min = sc._max = null;
} }
} }
} }
@ -2299,7 +2350,7 @@ function uPlot(opts, data, then) {
if (i > 0) { if (i > 0) {
onMouse("click", label, e => { onMouse("click", label, e => {
if ( cursor._lock) if (cursor._lock)
return; return;
setSeries(series.indexOf(s), {show: !s.show}, syncOpts.setSeries); setSeries(series.indexOf(s), {show: !s.show}, syncOpts.setSeries);
@ -2578,7 +2629,7 @@ function uPlot(opts, data, then) {
if (showLegend) if (showLegend)
legendRows.splice(i, 0, initLegendRow(s, i)); legendRows.splice(i, 0, initLegendRow(s, i));
if ( cursor.show) { if (cursor.show) {
let pt = initCursorPt(s, i); let pt = initCursorPt(s, i);
pt && cursorPts.splice(i, 0, pt); pt && cursorPts.splice(i, 0, pt);
} }
@ -2629,7 +2680,7 @@ function uPlot(opts, data, then) {
axis.space = fnOrSelf(axis.space); axis.space = fnOrSelf(axis.space);
axis.rotate = fnOrSelf(axis.rotate); axis.rotate = fnOrSelf(axis.rotate);
axis.incrs = fnOrSelf(axis.incrs || ( sc.distr == 2 ? wholeIncrs : (isTime ? (ms == 1 ? timeIncrsMs : timeIncrsS) : numIncrs))); axis.incrs = fnOrSelf(axis.incrs || ( sc.distr == 2 ? wholeIncrs : (isTime ? (ms == 1 ? timeIncrsMs : timeIncrsS) : numIncrs)));
axis.splits = fnOrSelf(axis.splits || (isTime && sc.distr == 1 ? _timeAxisSplits : sc.distr == 3 ? logAxisSplits : numAxisSplits)); axis.splits = fnOrSelf(axis.splits || (isTime && sc.distr == 1 ? _timeAxisSplits : sc.distr == 3 ? logAxisSplits : sc.distr == 4 ? asinhAxisSplits : numAxisSplits));
axis.stroke = fnOrSelf(axis.stroke); axis.stroke = fnOrSelf(axis.stroke);
axis.grid.stroke = fnOrSelf(axis.grid.stroke); axis.grid.stroke = fnOrSelf(axis.grid.stroke);
@ -2647,7 +2698,7 @@ function uPlot(opts, data, then) {
) : av || numAxisVals ) : av || numAxisVals
); );
axis.filter = fnOrSelf(axis.filter || ( sc.distr == 3 ? logAxisValsFilt : retArg1)); axis.filter = fnOrSelf(axis.filter || ( sc.distr >= 3 ? logAxisValsFilt : retArg1));
axis.font = pxRatioFont(axis.font); axis.font = pxRatioFont(axis.font);
axis.labelFont = pxRatioFont(axis.labelFont); axis.labelFont = pxRatioFont(axis.labelFont);
@ -2750,6 +2801,8 @@ function uPlot(opts, data, then) {
else if (dataLen == 1) { else if (dataLen == 1) {
if (xScaleDistr == 3) if (xScaleDistr == 3)
[_min, _max] = rangeLog(_min, _min, scaleX.log, false); [_min, _max] = rangeLog(_min, _min, scaleX.log, false);
else if (xScaleDistr == 4)
[_min, _max] = rangeAsinh(_min, _min, scaleX.log, false);
else if (scaleX.time) else if (scaleX.time)
_max = _min + 86400 / ms; _max = _min + 86400 / ms;
else else
@ -2881,6 +2934,12 @@ function uPlot(opts, data, then) {
if (sc.min != wsc.min || sc.max != wsc.max) { if (sc.min != wsc.min || sc.max != wsc.max) {
sc.min = wsc.min; sc.min = wsc.min;
sc.max = wsc.max; sc.max = wsc.max;
let distr = sc.distr;
sc._min = distr == 3 ? log10(sc.min) : distr == 4 ? asinh(sc.min, sc.asinh) : sc.min;
sc._max = distr == 3 ? log10(sc.max) : distr == 4 ? asinh(sc.max, sc.asinh) : sc.max;
changed[k] = anyChanged = true; changed[k] = anyChanged = true;
} }
} }
@ -2897,7 +2956,7 @@ function uPlot(opts, data, then) {
fire("setScale", k); fire("setScale", k);
} }
if ( cursor.show) if (cursor.show)
shouldSetCursor = true; shouldSetCursor = true;
} }
@ -3453,7 +3512,7 @@ function uPlot(opts, data, then) {
// shouldSetSelect = false; // shouldSetSelect = false;
// } // }
if ( cursor.show && shouldSetCursor) { if (cursor.show && shouldSetCursor) {
updateCursor(); updateCursor();
shouldSetCursor = false; shouldSetCursor = false;
} }
@ -3558,7 +3617,7 @@ function uPlot(opts, data, then) {
let dragX = drag.x; let dragX = drag.x;
let dragY = drag.y; let dragY = drag.y;
if ( cursor.show) { if (cursor.show) {
if (cursor.x) if (cursor.x)
xCursor = placeDiv(CURSOR_X, over); xCursor = placeDiv(CURSOR_X, over);
if (cursor.y) if (cursor.y)
@ -3642,10 +3701,10 @@ function uPlot(opts, data, then) {
function _alpha(i, value) { function _alpha(i, value) {
series[i].alpha = value; series[i].alpha = value;
if ( cursor.show && cursorPts[i]) if (cursor.show && cursorPts[i])
cursorPts[i].style.opacity = value; cursorPts[i].style.opacity = value;
if ( showLegend && legendRows[i]) if (showLegend && legendRows[i])
legendRows[i][0].parentNode.style.opacity = value; legendRows[i][0].parentNode.style.opacity = value;
} }
@ -3700,17 +3759,19 @@ function uPlot(opts, data, then) {
if (sc.dir == -1) if (sc.dir == -1)
pos = dim - pos; pos = dim - pos;
let _min = sc.min, let _min = sc._min,
_max = sc.max, _max = sc._max,
pct = pos / dim; pct = pos / dim;
if (sc.distr == 3) { let sv = _min + (_max - _min) * pct;
_min = log10(_min);
_max = log10(_max); let distr = sc.distr;
return pow(10, _min + (_max - _min) * pct);
} return (
else distr == 3 ? pow(10, sv) :
return _min + (_max - _min) * pct; distr == 4 ? sinh(sv, sc.asinh) :
sv
);
} }
function closestIdxFromXpos(pos) { function closestIdxFromXpos(pos) {
@ -3945,7 +4006,7 @@ function uPlot(opts, data, then) {
let uni = drag.uni; let uni = drag.uni;
if (uni != null) { if (uni != null) {
// only calc drag status if they pass the dist thresh // only calc drag status if they pass the dist asinh
if (dragX && dragY) { if (dragX && dragY) {
dragX = rawDX >= uni; dragX = rawDX >= uni;
dragY = rawDY >= uni; dragY = rawDY >= uni;
@ -4279,7 +4340,7 @@ function uPlot(opts, data, then) {
let deb; let deb;
if ( cursor.show) { if (cursor.show) {
onMouse(mousedown, over, mouseDown); onMouse(mousedown, over, mouseDown);
onMouse(mousemove, over, mouseMove); onMouse(mousemove, over, mouseMove);
onMouse(mouseenter, over, syncRect); onMouse(mouseenter, over, syncRect);
@ -4319,7 +4380,7 @@ function uPlot(opts, data, then) {
const syncKey = syncOpts.key; const syncKey = syncOpts.key;
const sync = (syncKey != null ? (syncs[syncKey] = syncs[syncKey] || _sync()) : _sync()); const sync = _sync(syncKey);
sync.sub(self); sync.sub(self);
@ -4372,6 +4433,7 @@ uPlot.assign = assign;
uPlot.fmtNum = fmtNum; uPlot.fmtNum = fmtNum;
uPlot.rangeNum = rangeNum; uPlot.rangeNum = rangeNum;
uPlot.rangeLog = rangeLog; uPlot.rangeLog = rangeLog;
uPlot.rangeAsinh = rangeAsinh;
uPlot.orient = orient; uPlot.orient = orient;
{ {
@ -4383,6 +4445,10 @@ uPlot.orient = orient;
uPlot.tzDate = tzDate; uPlot.tzDate = tzDate;
} }
{
uPlot.sync = _sync;
}
{ {
uPlot.addGap = addGap; uPlot.addGap = addGap;
uPlot.clipGaps = clipGaps; uPlot.clipGaps = clipGaps;

View File

@ -4,7 +4,7 @@
* *
* uPlot.js (μPlot) * uPlot.js (μPlot)
* A small, fast chart for time series, lines, areas, ohlc & bars * A small, fast chart for time series, lines, areas, ohlc & bars
* https://github.com/leeoniya/uPlot (v1.6.4) * https://github.com/leeoniya/uPlot (v1.6.5)
*/ */
const FEAT_TIME = true; const FEAT_TIME = true;
@ -108,6 +108,7 @@ function fixIncr(minIncr, maxIncr, minExp, maxExp) {
} }
function rangeLog(min, max, base, fullMags) { function rangeLog(min, max, base, fullMags) {
let logFn = base == 10 ? log10 : log2; let logFn = base == 10 ? log10 : log2;
if (min == max) { if (min == max) {
@ -127,8 +128,8 @@ function rangeLog(min, max, base, fullMags) {
max = minMaxIncrs[1]; max = minMaxIncrs[1];
} }
else { else {
minExp = floor(logFn(min)); minExp = floor(logFn(abs(min)));
maxExp = floor(logFn(max)); maxExp = floor(logFn(abs(max)));
minMaxIncrs = fixIncr(pow(base, minExp), pow(base, maxExp), minExp, maxExp); minMaxIncrs = fixIncr(pow(base, minExp), pow(base, maxExp), minExp, maxExp);
@ -139,6 +140,18 @@ function rangeLog(min, max, base, fullMags) {
return [min, max]; return [min, max];
} }
function rangeAsinh(min, max, base, fullMags) {
let minMax = rangeLog(min, max, base, fullMags);
if (min == 0)
minMax[0] = 0;
if (max == 0)
minMax[1] = 0;
return minMax;
}
const _eqRangePart = { const _eqRangePart = {
pad: 0, pad: 0,
soft: null, soft: null,
@ -210,6 +223,7 @@ const fmtNum = new Intl.NumberFormat(navigator.language).format;
const M = Math; const M = Math;
const PI = M.PI;
const abs = M.abs; const abs = M.abs;
const floor = M.floor; const floor = M.floor;
const round = M.round; const round = M.round;
@ -220,7 +234,8 @@ const pow = M.pow;
const sqrt = M.sqrt; const sqrt = M.sqrt;
const log10 = M.log10; const log10 = M.log10;
const log2 = M.log2; const log2 = M.log2;
const PI = M.PI; const sinh = (v, linthresh = 1) => M.sinh(v / linthresh);
const asinh = (v, linthresh = 1) => M.asinh(v / linthresh);
const inf = Infinity; const inf = Infinity;
@ -1143,6 +1158,7 @@ function numAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace,
return splits; return splits;
} }
// this doesnt work for sin, which needs to come off from 0 independently in pos and neg dirs
function logAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) { function logAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) {
const splits = []; const splits = [];
@ -1171,6 +1187,18 @@ function logAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace,
return splits; return splits;
} }
function asinhAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) {
let sc = self.scales[self.axes[axisIdx].scale];
let linthresh = sc.asinh;
let posSplits = scaleMax > linthresh ? logAxisSplits(self, axisIdx, max(linthresh, scaleMin), scaleMax, foundIncr) : [linthresh];
let zero = scaleMax >= 0 && scaleMin <= 0 ? [0] : [];
let negSplits = scaleMin < -linthresh ? logAxisSplits(self, axisIdx, max(linthresh, -scaleMax), -scaleMin, foundIncr): [linthresh];
return negSplits.reverse().map(v => -v).concat(zero, posSplits);
}
const RE_ALL = /./; const RE_ALL = /./;
const RE_12357 = /[12357]/; const RE_12357 = /[12357]/;
const RE_125 = /[125]/; const RE_125 = /[125]/;
@ -1179,8 +1207,9 @@ const RE_1 = /1/;
function logAxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) { function logAxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) {
let axis = self.axes[axisIdx]; let axis = self.axes[axisIdx];
let scaleKey = axis.scale; let scaleKey = axis.scale;
let sc = self.scales[scaleKey];
if (self.scales[scaleKey].log == 2) if (sc.distr == 3 && sc.log == 2)
return splits; return splits;
let valToPos = self.valToPos; let valToPos = self.valToPos;
@ -1196,7 +1225,7 @@ function logAxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) {
RE_1 RE_1
); );
return splits.map(v => re.test(v) ? v : null); return splits.map(v => ((sc.distr == 4 && v == 0) || re.test(v)) ? v : null);
} }
function numSeriesVal(self, val) { function numSeriesVal(self, val) {
@ -1290,6 +1319,7 @@ const xScaleOpts = {
auto: true, auto: true,
distr: 1, distr: 1,
log: 10, log: 10,
asinh: 1,
min: null, min: null,
max: null, max: null,
dir: 1, dir: 1,
@ -1303,10 +1333,14 @@ const yScaleOpts = assign({}, xScaleOpts, {
const syncs = {}; const syncs = {};
function _sync(opts) { function _sync(key, opts) {
let s = syncs[key];
if (!s) {
let clients = []; let clients = [];
return { s = {
key,
sub(client) { sub(client) {
clients.push(client); clients.push(client);
}, },
@ -1314,13 +1348,16 @@ function _sync(opts) {
clients = clients.filter(c => c != client); clients = clients.filter(c => c != client);
}, },
pub(type, self, x, y, w, h, i) { pub(type, self, x, y, w, h, i) {
if (clients.length > 1) { for (let i = 0; i < clients.length; i++)
clients.forEach(client => { clients[i] != self && clients[i].pub(type, self, x, y, w, h, i);
client != self && client.pub(type, self, x, y, w, h, i);
});
}
} }
}; };
if (key != null)
syncs[key] = s;
}
return s;
} }
function orient(u, seriesIdx, cb) { function orient(u, seriesIdx, cb) {
@ -2010,6 +2047,12 @@ function snapLogY(self, dataMin, dataMax, scale) {
const snapLogX = snapLogY; const snapLogX = snapLogY;
function snapAsinhY(self, dataMin, dataMax, scale) {
return dataMin == null ? nullMinMax : rangeAsinh(dataMin, dataMax, self.scales[scale].log, false);
}
const snapAsinhX = snapAsinhY;
// dim is logical (getClientBoundingRect) pixels, not canvas pixels // dim is logical (getClientBoundingRect) pixels, not canvas pixels
function findIncr(min, max, incrs, dim, minSpace) { function findIncr(min, max, incrs, dim, minSpace) {
let pxPerUnit = dim / (max - min); let pxPerUnit = dim / (max - min);
@ -2037,12 +2080,15 @@ function pxRatioFont(font) {
function uPlot(opts, data, then) { function uPlot(opts, data, then) {
const self = {}; const self = {};
// TODO: cache denoms & mins scale.cache = {r, min, }
function getValPct(val, scale) { function getValPct(val, scale) {
return ( let _val = (
scale.distr == 3 scale.distr == 3 ? log10(val > 0 ? val : scale.clamp(self, val, scale.min, scale.max, scale.key)) :
? log10((val > 0 ? val : scale.clamp(self, val, scale.min, scale.max, scale.key)) / scale.min) / log10(scale.max / scale.min) scale.distr == 4 ? asinh(val, scale.asinh) :
: (val - scale.min) / (scale.max - scale.min) val
); );
return (_val - scale._min) / (scale._max - scale._min);
} }
function getHPos(val, scale, dim, off) { function getHPos(val, scale, dim, off) {
@ -2132,7 +2178,6 @@ function uPlot(opts, data, then) {
sc.key = scaleKey; sc.key = scaleKey;
let isTime = sc.time; let isTime = sc.time;
let isLog = sc.distr == 3;
let rn = sc.range; let rn = sc.range;
@ -2142,11 +2187,17 @@ function uPlot(opts, data, then) {
rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg); rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg);
} }
sc.range = fnOrSelf(rn || (isTime ? snapTimeX : scaleKey == xScaleKey ? (isLog ? snapLogX : snapNumX) : (isLog ? snapLogY : snapNumY))); sc.range = fnOrSelf(rn || (isTime ? snapTimeX : scaleKey == xScaleKey ?
(sc.distr == 3 ? snapLogX : sc.distr == 4 ? snapAsinhX : snapNumX) :
(sc.distr == 3 ? snapLogY : sc.distr == 4 ? snapAsinhY : snapNumY)
));
sc.auto = fnOrSelf(sc.auto); sc.auto = fnOrSelf(sc.auto);
sc.clamp = fnOrSelf(sc.clamp || clampScale); sc.clamp = fnOrSelf(sc.clamp || clampScale);
// caches for expensive ops like asinh() & log()
sc._min = sc._max = null;
} }
} }
} }
@ -2297,7 +2348,7 @@ function uPlot(opts, data, then) {
if (i > 0) { if (i > 0) {
onMouse("click", label, e => { onMouse("click", label, e => {
if ( cursor._lock) if (cursor._lock)
return; return;
setSeries(series.indexOf(s), {show: !s.show}, syncOpts.setSeries); setSeries(series.indexOf(s), {show: !s.show}, syncOpts.setSeries);
@ -2576,7 +2627,7 @@ function uPlot(opts, data, then) {
if (showLegend) if (showLegend)
legendRows.splice(i, 0, initLegendRow(s, i)); legendRows.splice(i, 0, initLegendRow(s, i));
if ( cursor.show) { if (cursor.show) {
let pt = initCursorPt(s, i); let pt = initCursorPt(s, i);
pt && cursorPts.splice(i, 0, pt); pt && cursorPts.splice(i, 0, pt);
} }
@ -2627,7 +2678,7 @@ function uPlot(opts, data, then) {
axis.space = fnOrSelf(axis.space); axis.space = fnOrSelf(axis.space);
axis.rotate = fnOrSelf(axis.rotate); axis.rotate = fnOrSelf(axis.rotate);
axis.incrs = fnOrSelf(axis.incrs || ( sc.distr == 2 ? wholeIncrs : (isTime ? (ms == 1 ? timeIncrsMs : timeIncrsS) : numIncrs))); axis.incrs = fnOrSelf(axis.incrs || ( sc.distr == 2 ? wholeIncrs : (isTime ? (ms == 1 ? timeIncrsMs : timeIncrsS) : numIncrs)));
axis.splits = fnOrSelf(axis.splits || (isTime && sc.distr == 1 ? _timeAxisSplits : sc.distr == 3 ? logAxisSplits : numAxisSplits)); axis.splits = fnOrSelf(axis.splits || (isTime && sc.distr == 1 ? _timeAxisSplits : sc.distr == 3 ? logAxisSplits : sc.distr == 4 ? asinhAxisSplits : numAxisSplits));
axis.stroke = fnOrSelf(axis.stroke); axis.stroke = fnOrSelf(axis.stroke);
axis.grid.stroke = fnOrSelf(axis.grid.stroke); axis.grid.stroke = fnOrSelf(axis.grid.stroke);
@ -2645,7 +2696,7 @@ function uPlot(opts, data, then) {
) : av || numAxisVals ) : av || numAxisVals
); );
axis.filter = fnOrSelf(axis.filter || ( sc.distr == 3 ? logAxisValsFilt : retArg1)); axis.filter = fnOrSelf(axis.filter || ( sc.distr >= 3 ? logAxisValsFilt : retArg1));
axis.font = pxRatioFont(axis.font); axis.font = pxRatioFont(axis.font);
axis.labelFont = pxRatioFont(axis.labelFont); axis.labelFont = pxRatioFont(axis.labelFont);
@ -2748,6 +2799,8 @@ function uPlot(opts, data, then) {
else if (dataLen == 1) { else if (dataLen == 1) {
if (xScaleDistr == 3) if (xScaleDistr == 3)
[_min, _max] = rangeLog(_min, _min, scaleX.log, false); [_min, _max] = rangeLog(_min, _min, scaleX.log, false);
else if (xScaleDistr == 4)
[_min, _max] = rangeAsinh(_min, _min, scaleX.log, false);
else if (scaleX.time) else if (scaleX.time)
_max = _min + 86400 / ms; _max = _min + 86400 / ms;
else else
@ -2879,6 +2932,12 @@ function uPlot(opts, data, then) {
if (sc.min != wsc.min || sc.max != wsc.max) { if (sc.min != wsc.min || sc.max != wsc.max) {
sc.min = wsc.min; sc.min = wsc.min;
sc.max = wsc.max; sc.max = wsc.max;
let distr = sc.distr;
sc._min = distr == 3 ? log10(sc.min) : distr == 4 ? asinh(sc.min, sc.asinh) : sc.min;
sc._max = distr == 3 ? log10(sc.max) : distr == 4 ? asinh(sc.max, sc.asinh) : sc.max;
changed[k] = anyChanged = true; changed[k] = anyChanged = true;
} }
} }
@ -2895,7 +2954,7 @@ function uPlot(opts, data, then) {
fire("setScale", k); fire("setScale", k);
} }
if ( cursor.show) if (cursor.show)
shouldSetCursor = true; shouldSetCursor = true;
} }
@ -3451,7 +3510,7 @@ function uPlot(opts, data, then) {
// shouldSetSelect = false; // shouldSetSelect = false;
// } // }
if ( cursor.show && shouldSetCursor) { if (cursor.show && shouldSetCursor) {
updateCursor(); updateCursor();
shouldSetCursor = false; shouldSetCursor = false;
} }
@ -3556,7 +3615,7 @@ function uPlot(opts, data, then) {
let dragX = drag.x; let dragX = drag.x;
let dragY = drag.y; let dragY = drag.y;
if ( cursor.show) { if (cursor.show) {
if (cursor.x) if (cursor.x)
xCursor = placeDiv(CURSOR_X, over); xCursor = placeDiv(CURSOR_X, over);
if (cursor.y) if (cursor.y)
@ -3640,10 +3699,10 @@ function uPlot(opts, data, then) {
function _alpha(i, value) { function _alpha(i, value) {
series[i].alpha = value; series[i].alpha = value;
if ( cursor.show && cursorPts[i]) if (cursor.show && cursorPts[i])
cursorPts[i].style.opacity = value; cursorPts[i].style.opacity = value;
if ( showLegend && legendRows[i]) if (showLegend && legendRows[i])
legendRows[i][0].parentNode.style.opacity = value; legendRows[i][0].parentNode.style.opacity = value;
} }
@ -3698,17 +3757,19 @@ function uPlot(opts, data, then) {
if (sc.dir == -1) if (sc.dir == -1)
pos = dim - pos; pos = dim - pos;
let _min = sc.min, let _min = sc._min,
_max = sc.max, _max = sc._max,
pct = pos / dim; pct = pos / dim;
if (sc.distr == 3) { let sv = _min + (_max - _min) * pct;
_min = log10(_min);
_max = log10(_max); let distr = sc.distr;
return pow(10, _min + (_max - _min) * pct);
} return (
else distr == 3 ? pow(10, sv) :
return _min + (_max - _min) * pct; distr == 4 ? sinh(sv, sc.asinh) :
sv
);
} }
function closestIdxFromXpos(pos) { function closestIdxFromXpos(pos) {
@ -3943,7 +4004,7 @@ function uPlot(opts, data, then) {
let uni = drag.uni; let uni = drag.uni;
if (uni != null) { if (uni != null) {
// only calc drag status if they pass the dist thresh // only calc drag status if they pass the dist asinh
if (dragX && dragY) { if (dragX && dragY) {
dragX = rawDX >= uni; dragX = rawDX >= uni;
dragY = rawDY >= uni; dragY = rawDY >= uni;
@ -4277,7 +4338,7 @@ function uPlot(opts, data, then) {
let deb; let deb;
if ( cursor.show) { if (cursor.show) {
onMouse(mousedown, over, mouseDown); onMouse(mousedown, over, mouseDown);
onMouse(mousemove, over, mouseMove); onMouse(mousemove, over, mouseMove);
onMouse(mouseenter, over, syncRect); onMouse(mouseenter, over, syncRect);
@ -4317,7 +4378,7 @@ function uPlot(opts, data, then) {
const syncKey = syncOpts.key; const syncKey = syncOpts.key;
const sync = (syncKey != null ? (syncs[syncKey] = syncs[syncKey] || _sync()) : _sync()); const sync = _sync(syncKey);
sync.sub(self); sync.sub(self);
@ -4370,6 +4431,7 @@ uPlot.assign = assign;
uPlot.fmtNum = fmtNum; uPlot.fmtNum = fmtNum;
uPlot.rangeNum = rangeNum; uPlot.rangeNum = rangeNum;
uPlot.rangeLog = rangeLog; uPlot.rangeLog = rangeLog;
uPlot.rangeAsinh = rangeAsinh;
uPlot.orient = orient; uPlot.orient = orient;
{ {
@ -4381,6 +4443,10 @@ uPlot.orient = orient;
uPlot.tzDate = tzDate; uPlot.tzDate = tzDate;
} }
{
uPlot.sync = _sync;
}
{ {
uPlot.addGap = addGap; uPlot.addGap = addGap;
uPlot.clipGaps = clipGaps; uPlot.clipGaps = clipGaps;

View File

@ -4,7 +4,7 @@
* *
* uPlot.js (μPlot) * uPlot.js (μPlot)
* A small, fast chart for time series, lines, areas, ohlc & bars * A small, fast chart for time series, lines, areas, ohlc & bars
* https://github.com/leeoniya/uPlot (v1.6.4) * https://github.com/leeoniya/uPlot (v1.6.5)
*/ */
var uPlot = (function () { var uPlot = (function () {
@ -110,6 +110,7 @@ var uPlot = (function () {
} }
function rangeLog(min, max, base, fullMags) { function rangeLog(min, max, base, fullMags) {
var logFn = base == 10 ? log10 : log2; var logFn = base == 10 ? log10 : log2;
if (min == max) { if (min == max) {
@ -129,8 +130,8 @@ var uPlot = (function () {
max = minMaxIncrs[1]; max = minMaxIncrs[1];
} }
else { else {
minExp = floor(logFn(min)); minExp = floor(logFn(abs(min)));
maxExp = floor(logFn(max)); maxExp = floor(logFn(abs(max)));
minMaxIncrs = fixIncr(pow(base, minExp), pow(base, maxExp), minExp, maxExp); minMaxIncrs = fixIncr(pow(base, minExp), pow(base, maxExp), minExp, maxExp);
@ -141,6 +142,18 @@ var uPlot = (function () {
return [min, max]; return [min, max];
} }
function rangeAsinh(min, max, base, fullMags) {
var minMax = rangeLog(min, max, base, fullMags);
if (min == 0)
{ minMax[0] = 0; }
if (max == 0)
{ minMax[1] = 0; }
return minMax;
}
var _eqRangePart = { var _eqRangePart = {
pad: 0, pad: 0,
soft: null, soft: null,
@ -212,6 +225,7 @@ var uPlot = (function () {
var M = Math; var M = Math;
var PI = M.PI;
var abs = M.abs; var abs = M.abs;
var floor = M.floor; var floor = M.floor;
var round = M.round; var round = M.round;
@ -222,7 +236,16 @@ var uPlot = (function () {
var sqrt = M.sqrt; var sqrt = M.sqrt;
var log10 = M.log10; var log10 = M.log10;
var log2 = M.log2; var log2 = M.log2;
var PI = M.PI; var sinh = (v, linthresh) => {
if ( linthresh === void 0 ) linthresh = 1;
return M.sinh(v / linthresh);
};
var asinh = (v, linthresh) => {
if ( linthresh === void 0 ) linthresh = 1;
return M.asinh(v / linthresh);
};
var inf = Infinity; var inf = Infinity;
@ -1146,6 +1169,7 @@ var uPlot = (function () {
return splits; return splits;
} }
// this doesnt work for sin, which needs to come off from 0 independently in pos and neg dirs
function logAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) { function logAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) {
var splits = []; var splits = [];
@ -1174,6 +1198,18 @@ var uPlot = (function () {
return splits; return splits;
} }
function asinhAxisSplits(self, axisIdx, scaleMin, scaleMax, foundIncr, foundSpace, forceMin) {
var sc = self.scales[self.axes[axisIdx].scale];
var linthresh = sc.asinh;
var posSplits = scaleMax > linthresh ? logAxisSplits(self, axisIdx, max(linthresh, scaleMin), scaleMax, foundIncr) : [linthresh];
var zero = scaleMax >= 0 && scaleMin <= 0 ? [0] : [];
var negSplits = scaleMin < -linthresh ? logAxisSplits(self, axisIdx, max(linthresh, -scaleMax), -scaleMin, foundIncr): [linthresh];
return negSplits.reverse().map(v => -v).concat(zero, posSplits);
}
var RE_ALL = /./; var RE_ALL = /./;
var RE_12357 = /[12357]/; var RE_12357 = /[12357]/;
var RE_125 = /[125]/; var RE_125 = /[125]/;
@ -1182,8 +1218,9 @@ var uPlot = (function () {
function logAxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) { function logAxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) {
var axis = self.axes[axisIdx]; var axis = self.axes[axisIdx];
var scaleKey = axis.scale; var scaleKey = axis.scale;
var sc = self.scales[scaleKey];
if (self.scales[scaleKey].log == 2) if (sc.distr == 3 && sc.log == 2)
{ return splits; } { return splits; }
var valToPos = self.valToPos; var valToPos = self.valToPos;
@ -1199,7 +1236,7 @@ var uPlot = (function () {
RE_1 RE_1
); );
return splits.map(v => re.test(v) ? v : null); return splits.map(v => ((sc.distr == 4 && v == 0) || re.test(v)) ? v : null);
} }
function numSeriesVal(self, val) { function numSeriesVal(self, val) {
@ -1293,6 +1330,7 @@ var uPlot = (function () {
auto: true, auto: true,
distr: 1, distr: 1,
log: 10, log: 10,
asinh: 1,
min: null, min: null,
max: null, max: null,
dir: 1, dir: 1,
@ -1306,10 +1344,14 @@ var uPlot = (function () {
var syncs = {}; var syncs = {};
function _sync(opts) { function _sync(key, opts) {
var s = syncs[key];
if (!s) {
var clients = []; var clients = [];
return { s = {
key: key,
sub: function sub(client) { sub: function sub(client) {
clients.push(client); clients.push(client);
}, },
@ -1317,13 +1359,16 @@ var uPlot = (function () {
clients = clients.filter(c => c != client); clients = clients.filter(c => c != client);
}, },
pub: function pub(type, self, x, y, w, h, i) { pub: function pub(type, self, x, y, w, h, i) {
if (clients.length > 1) { for (var i$1 = 0; i$1 < clients.length; i$1++)
clients.forEach(client => { { clients[i$1] != self && clients[i$1].pub(type, self, x, y, w, h, i$1); }
client != self && client.pub(type, self, x, y, w, h, i);
});
}
} }
}; };
if (key != null)
{ syncs[key] = s; }
}
return s;
} }
function orient(u, seriesIdx, cb) { function orient(u, seriesIdx, cb) {
@ -2006,6 +2051,12 @@ var uPlot = (function () {
var snapLogX = snapLogY; var snapLogX = snapLogY;
function snapAsinhY(self, dataMin, dataMax, scale) {
return dataMin == null ? nullMinMax : rangeAsinh(dataMin, dataMax, self.scales[scale].log, false);
}
var snapAsinhX = snapAsinhY;
// dim is logical (getClientBoundingRect) pixels, not canvas pixels // dim is logical (getClientBoundingRect) pixels, not canvas pixels
function findIncr(min, max, incrs, dim, minSpace) { function findIncr(min, max, incrs, dim, minSpace) {
var pxPerUnit = dim / (max - min); var pxPerUnit = dim / (max - min);
@ -2033,12 +2084,15 @@ var uPlot = (function () {
function uPlot(opts, data, then) { function uPlot(opts, data, then) {
var self = {}; var self = {};
// TODO: cache denoms & mins scale.cache = {r, min, }
function getValPct(val, scale) { function getValPct(val, scale) {
return ( var _val = (
scale.distr == 3 scale.distr == 3 ? log10(val > 0 ? val : scale.clamp(self, val, scale.min, scale.max, scale.key)) :
? log10((val > 0 ? val : scale.clamp(self, val, scale.min, scale.max, scale.key)) / scale.min) / log10(scale.max / scale.min) scale.distr == 4 ? asinh(val, scale.asinh) :
: (val - scale.min) / (scale.max - scale.min) val
); );
return (_val - scale._min) / (scale._max - scale._min);
} }
function getHPos(val, scale, dim, off) { function getHPos(val, scale, dim, off) {
@ -2128,7 +2182,6 @@ var uPlot = (function () {
sc.key = scaleKey; sc.key = scaleKey;
var isTime = sc.time; var isTime = sc.time;
var isLog = sc.distr == 3;
var rn = sc.range; var rn = sc.range;
@ -2138,11 +2191,17 @@ var uPlot = (function () {
rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg); rn = (self, dataMin, dataMax) => dataMin == null ? nullMinMax : rangeNum(dataMin, dataMax, cfg);
} }
sc.range = fnOrSelf(rn || (isTime ? snapTimeX : scaleKey == xScaleKey ? (isLog ? snapLogX : snapNumX) : (isLog ? snapLogY : snapNumY))); sc.range = fnOrSelf(rn || (isTime ? snapTimeX : scaleKey == xScaleKey ?
(sc.distr == 3 ? snapLogX : sc.distr == 4 ? snapAsinhX : snapNumX) :
(sc.distr == 3 ? snapLogY : sc.distr == 4 ? snapAsinhY : snapNumY)
));
sc.auto = fnOrSelf(sc.auto); sc.auto = fnOrSelf(sc.auto);
sc.clamp = fnOrSelf(sc.clamp || clampScale); sc.clamp = fnOrSelf(sc.clamp || clampScale);
// caches for expensive ops like asinh() & log()
sc._min = sc._max = null;
} }
} }
} }
@ -2293,7 +2352,7 @@ var uPlot = (function () {
if (i > 0) { if (i > 0) {
onMouse("click", label, e => { onMouse("click", label, e => {
if ( cursor._lock) if (cursor._lock)
{ return; } { return; }
setSeries(series.indexOf(s), {show: !s.show}, syncOpts.setSeries); setSeries(series.indexOf(s), {show: !s.show}, syncOpts.setSeries);
@ -2576,7 +2635,7 @@ var uPlot = (function () {
if (showLegend) if (showLegend)
{ legendRows.splice(i, 0, initLegendRow(s, i)); } { legendRows.splice(i, 0, initLegendRow(s, i)); }
if ( cursor.show) { if (cursor.show) {
var pt = initCursorPt(s, i); var pt = initCursorPt(s, i);
pt && cursorPts.splice(i, 0, pt); pt && cursorPts.splice(i, 0, pt);
} }
@ -2627,7 +2686,7 @@ var uPlot = (function () {
axis.space = fnOrSelf(axis.space); axis.space = fnOrSelf(axis.space);
axis.rotate = fnOrSelf(axis.rotate); axis.rotate = fnOrSelf(axis.rotate);
axis.incrs = fnOrSelf(axis.incrs || ( sc.distr == 2 ? wholeIncrs : (isTime ? (ms == 1 ? timeIncrsMs : timeIncrsS) : numIncrs))); axis.incrs = fnOrSelf(axis.incrs || ( sc.distr == 2 ? wholeIncrs : (isTime ? (ms == 1 ? timeIncrsMs : timeIncrsS) : numIncrs)));
axis.splits = fnOrSelf(axis.splits || (isTime && sc.distr == 1 ? _timeAxisSplits : sc.distr == 3 ? logAxisSplits : numAxisSplits)); axis.splits = fnOrSelf(axis.splits || (isTime && sc.distr == 1 ? _timeAxisSplits : sc.distr == 3 ? logAxisSplits : sc.distr == 4 ? asinhAxisSplits : numAxisSplits));
axis.stroke = fnOrSelf(axis.stroke); axis.stroke = fnOrSelf(axis.stroke);
axis.grid.stroke = fnOrSelf(axis.grid.stroke); axis.grid.stroke = fnOrSelf(axis.grid.stroke);
@ -2645,7 +2704,7 @@ var uPlot = (function () {
) : av || numAxisVals ) : av || numAxisVals
); );
axis.filter = fnOrSelf(axis.filter || ( sc.distr == 3 ? logAxisValsFilt : retArg1)); axis.filter = fnOrSelf(axis.filter || ( sc.distr >= 3 ? logAxisValsFilt : retArg1));
axis.font = pxRatioFont(axis.font); axis.font = pxRatioFont(axis.font);
axis.labelFont = pxRatioFont(axis.labelFont); axis.labelFont = pxRatioFont(axis.labelFont);
@ -2733,7 +2792,7 @@ var uPlot = (function () {
self.setData = setData; self.setData = setData;
function autoScaleX() { function autoScaleX() {
var assign, assign$1; var assign, assign$1, assign$2;
viaAutoScaleX = true; viaAutoScaleX = true;
@ -2753,10 +2812,12 @@ var uPlot = (function () {
else if (dataLen == 1) { else if (dataLen == 1) {
if (xScaleDistr == 3) if (xScaleDistr == 3)
{ (assign = rangeLog(_min, _min, scaleX.log, false), _min = assign[0], _max = assign[1]); } { (assign = rangeLog(_min, _min, scaleX.log, false), _min = assign[0], _max = assign[1]); }
else if (xScaleDistr == 4)
{ (assign$1 = rangeAsinh(_min, _min, scaleX.log, false), _min = assign$1[0], _max = assign$1[1]); }
else if (scaleX.time) else if (scaleX.time)
{ _max = _min + 86400 / ms; } { _max = _min + 86400 / ms; }
else else
{ (assign$1 = rangeNum(_min, _max, 0.1, true), _min = assign$1[0], _max = assign$1[1]); } { (assign$2 = rangeNum(_min, _max, 0.1, true), _min = assign$2[0], _max = assign$2[1]); }
} }
} }
else { else {
@ -2884,6 +2945,12 @@ var uPlot = (function () {
if (sc.min != wsc$3.min || sc.max != wsc$3.max) { if (sc.min != wsc$3.min || sc.max != wsc$3.max) {
sc.min = wsc$3.min; sc.min = wsc$3.min;
sc.max = wsc$3.max; sc.max = wsc$3.max;
var distr = sc.distr;
sc._min = distr == 3 ? log10(sc.min) : distr == 4 ? asinh(sc.min, sc.asinh) : sc.min;
sc._max = distr == 3 ? log10(sc.max) : distr == 4 ? asinh(sc.max, sc.asinh) : sc.max;
changed[k$3] = anyChanged = true; changed[k$3] = anyChanged = true;
} }
} }
@ -2900,7 +2967,7 @@ var uPlot = (function () {
fire("setScale", k$4); fire("setScale", k$4);
} }
if ( cursor.show) if (cursor.show)
{ shouldSetCursor = true; } { shouldSetCursor = true; }
} }
@ -3464,7 +3531,7 @@ var uPlot = (function () {
// shouldSetSelect = false; // shouldSetSelect = false;
// } // }
if ( cursor.show && shouldSetCursor) { if (cursor.show && shouldSetCursor) {
updateCursor(); updateCursor();
shouldSetCursor = false; shouldSetCursor = false;
} }
@ -3569,7 +3636,7 @@ var uPlot = (function () {
var dragX = drag.x; var dragX = drag.x;
var dragY = drag.y; var dragY = drag.y;
if ( cursor.show) { if (cursor.show) {
if (cursor.x) if (cursor.x)
{ xCursor = placeDiv(CURSOR_X, over); } { xCursor = placeDiv(CURSOR_X, over); }
if (cursor.y) if (cursor.y)
@ -3653,10 +3720,10 @@ var uPlot = (function () {
function _alpha(i, value) { function _alpha(i, value) {
series[i].alpha = value; series[i].alpha = value;
if ( cursor.show && cursorPts[i]) if (cursor.show && cursorPts[i])
{ cursorPts[i].style.opacity = value; } { cursorPts[i].style.opacity = value; }
if ( showLegend && legendRows[i]) if (showLegend && legendRows[i])
{ legendRows[i][0].parentNode.style.opacity = value; } { legendRows[i][0].parentNode.style.opacity = value; }
} }
@ -3711,17 +3778,19 @@ var uPlot = (function () {
if (sc.dir == -1) if (sc.dir == -1)
{ pos = dim - pos; } { pos = dim - pos; }
var _min = sc.min, var _min = sc._min,
_max = sc.max, _max = sc._max,
pct = pos / dim; pct = pos / dim;
if (sc.distr == 3) { var sv = _min + (_max - _min) * pct;
_min = log10(_min);
_max = log10(_max); var distr = sc.distr;
return pow(10, _min + (_max - _min) * pct);
} return (
else distr == 3 ? pow(10, sv) :
{ return _min + (_max - _min) * pct; } distr == 4 ? sinh(sv, sc.asinh) :
sv
);
} }
function closestIdxFromXpos(pos) { function closestIdxFromXpos(pos) {
@ -3964,7 +4033,7 @@ var uPlot = (function () {
var uni = drag.uni; var uni = drag.uni;
if (uni != null) { if (uni != null) {
// only calc drag status if they pass the dist thresh // only calc drag status if they pass the dist asinh
if (dragX && dragY) { if (dragX && dragY) {
dragX = rawDX >= uni; dragX = rawDX >= uni;
dragY = rawDY >= uni; dragY = rawDY >= uni;
@ -4305,7 +4374,7 @@ var uPlot = (function () {
var deb; var deb;
if ( cursor.show) { if (cursor.show) {
onMouse(mousedown, over, mouseDown); onMouse(mousedown, over, mouseDown);
onMouse(mousemove, over, mouseMove); onMouse(mousemove, over, mouseMove);
onMouse(mouseenter, over, syncRect); onMouse(mouseenter, over, syncRect);
@ -4345,7 +4414,7 @@ var uPlot = (function () {
var syncKey = syncOpts.key; var syncKey = syncOpts.key;
var sync = (syncKey != null ? (syncs[syncKey] = syncs[syncKey] || _sync()) : _sync()); var sync = _sync(syncKey);
sync.sub(self); sync.sub(self);
@ -4398,6 +4467,7 @@ var uPlot = (function () {
uPlot.fmtNum = fmtNum; uPlot.fmtNum = fmtNum;
uPlot.rangeNum = rangeNum; uPlot.rangeNum = rangeNum;
uPlot.rangeLog = rangeLog; uPlot.rangeLog = rangeLog;
uPlot.rangeAsinh = rangeAsinh;
uPlot.orient = orient; uPlot.orient = orient;
{ {
@ -4409,6 +4479,10 @@ var uPlot = (function () {
uPlot.tzDate = tzDate; uPlot.tzDate = tzDate;
} }
{
uPlot.sync = _sync;
}
{ {
uPlot.addGap = addGap; uPlot.addGap = addGap;
uPlot.clipGaps = clipGaps; uPlot.clipGaps = clipGaps;

File diff suppressed because one or more lines are too long