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;
@ -541,9 +556,9 @@ function slice3(str) {
return str.slice(0, 3); return str.slice(0, 3);
} }
const days3 = days.map(slice3); const days3 = days.map(slice3);
const months3 = months.map(slice3); const months3 = months.map(slice3);
const engNames = { const engNames = {
MMMM: months, MMMM: months,
@ -868,8 +883,8 @@ function genTimeStuffs(ms) {
]; ];
} }
const [ timeIncrsMs, _timeAxisStampsMs, timeAxisSplitsMs ] = genTimeStuffs(1); const [ timeIncrsMs, _timeAxisStampsMs, timeAxisSplitsMs ] = genTimeStuffs(1);
const [ timeIncrsS, _timeAxisStampsS, timeAxisSplitsS ] = genTimeStuffs(1e-3); const [ timeIncrsS, _timeAxisStampsS, timeAxisSplitsS ] = genTimeStuffs(1e-3);
// base 2 // base 2
genIncrs(2, -53, 53, [1]); genIncrs(2, -53, 53, [1]);
@ -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,24 +1335,31 @@ const yScaleOpts = assign({}, xScaleOpts, {
const syncs = {}; const syncs = {};
function _sync(opts) { function _sync(key, opts) {
let clients = []; let s = syncs[key];
return { if (!s) {
sub(client) { let clients = [];
clients.push(client);
}, s = {
unsub(client) { key,
clients = clients.filter(c => c != client); sub(client) {
}, clients.push(client);
pub(type, self, x, y, w, h, i) { },
if (clients.length > 1) { unsub(client) {
clients.forEach(client => { clients = clients.filter(c => c != client);
client != self && client.pub(type, self, x, y, w, h, i); },
}); pub(type, self, x, y, w, h, i) {
for (let i = 0; i < clients.length; i++)
clients[i] != self && clients[i].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) {
@ -1981,7 +2018,7 @@ function bars(opts) {
}; };
} }
const linearPath = linear() ; const linearPath = linear() ;
function setDefaults(d, xo, yo, initY) { function setDefaults(d, xo, yo, initY) {
let d2 = initY ? [d[0], d[1]].concat(d.slice(2)) : [d[0]].concat(d.slice(1)); let d2 = initY ? [d[0], d[1]].concat(d.slice(2)) : [d[0]].concat(d.slice(1));
@ -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) {
@ -2133,8 +2179,7 @@ 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;
} }
} }
} }
@ -2225,15 +2276,15 @@ function uPlot(opts, data, then) {
} }
// self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone; // self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone;
const _tzDate = (opts.tzDate || (ts => new Date(ts / ms))); const _tzDate = (opts.tzDate || (ts => new Date(ts / ms)));
const _fmtDate = (opts.fmtDate || fmtDate); const _fmtDate = (opts.fmtDate || fmtDate);
const _timeAxisSplits = (ms == 1 ? timeAxisSplitsMs(_tzDate) : timeAxisSplitsS(_tzDate)); const _timeAxisSplits = (ms == 1 ? timeAxisSplitsMs(_tzDate) : timeAxisSplitsS(_tzDate));
const _timeAxisVals = timeAxisVals(_tzDate, timeAxisStamps((ms == 1 ? _timeAxisStampsMs : _timeAxisStampsS), _fmtDate)); const _timeAxisVals = timeAxisVals(_tzDate, timeAxisStamps((ms == 1 ? _timeAxisStampsMs : _timeAxisStampsS), _fmtDate));
const _timeSeriesVal = timeSeriesVal(_tzDate, timeSeriesStamp(_timeSeriesStamp, _fmtDate)); const _timeSeriesVal = timeSeriesVal(_tzDate, timeSeriesStamp(_timeSeriesStamp, _fmtDate));
const legend = assign({show: true, live: true}, opts.legend); const legend = assign({show: true, live: true}, opts.legend);
const showLegend = legend.show; const showLegend = legend.show;
{ {
legend.width = fnOrSelf(ifNull(legend.width, legendWidth)); legend.width = fnOrSelf(ifNull(legend.width, legendWidth));
@ -2299,10 +2350,10 @@ 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);
}); });
if (cursorFocus) { if (cursorFocus) {
@ -2509,7 +2560,7 @@ function uPlot(opts, data, then) {
}); });
} }
const cursor = (self.cursor = assign({}, cursorOpts, opts.cursor)); const cursor = (self.cursor = assign({}, cursorOpts, opts.cursor));
{ {
cursor._lock = false; cursor._lock = false;
@ -2523,8 +2574,8 @@ function uPlot(opts, data, then) {
points.fill = fnOrSelf(points.fill); points.fill = fnOrSelf(points.fill);
} }
const focus = self.focus = assign({}, opts.focus || {alpha: 0.3}, cursor.focus); const focus = self.focus = assign({}, opts.focus || {alpha: 0.3}, cursor.focus);
const cursorFocus = focus.prox >= 0; const cursorFocus = focus.prox >= 0;
// series-intersection markers // series-intersection markers
let cursorPts = [null]; let cursorPts = [null];
@ -2545,7 +2596,7 @@ function uPlot(opts, data, then) {
} }
function initSeries(s, i) { function initSeries(s, i) {
let isTime = scales[s.scale].time; let isTime = scales[s.scale].time;
let sv = s.value; let sv = s.value;
s.value = isTime ? (isStr(sv) ? timeSeriesVal(_tzDate, timeSeriesStamp(sv, _fmtDate)) : sv || _timeSeriesVal) : sv || numSeriesVal; s.value = isTime ? (isStr(sv) ? timeSeriesVal(_tzDate, timeSeriesStamp(sv, _fmtDate)) : sv || _timeSeriesVal) : sv || numSeriesVal;
@ -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);
} }
@ -2596,8 +2647,8 @@ function uPlot(opts, data, then) {
function delSeries(i) { function delSeries(i) {
series.splice(i, 1); series.splice(i, 1);
showLegend && legendRows.splice(i, 1)[0][0].parentNode.remove(); showLegend && legendRows.splice(i, 1)[0][0].parentNode.remove();
cursorPts.length > 1 && cursorPts.splice(i, 1)[0].remove(); cursorPts.length > 1 && cursorPts.splice(i, 1)[0].remove();
// TODO: de-init no-longer-needed scales? // TODO: de-init no-longer-needed scales?
} }
@ -2623,13 +2674,13 @@ function uPlot(opts, data, then) {
} }
// also set defaults for incrs & values based on axis distr // also set defaults for incrs & values based on axis distr
let isTime = sc.time; let isTime = sc.time;
axis.size = fnOrSelf(axis.size); axis.size = fnOrSelf(axis.size);
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;
} }
@ -3012,10 +3071,10 @@ function uPlot(opts, data, then) {
series.forEach((s, i) => { series.forEach((s, i) => {
if (i > 0 && s.show) { if (i > 0 && s.show) {
if (s._paths) if (s._paths)
drawPath(i); drawPath(i);
if (s.points.show(self, i, i0, i1)) if (s.points.show(self, i, i0, i1))
drawPoints(i); drawPoints(i);
fire("drawSeries", i); fire("drawSeries", i);
} }
@ -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;
} }
@ -3553,12 +3612,12 @@ function uPlot(opts, data, then) {
let dragging = false; let dragging = false;
const drag = cursor.drag; const drag = cursor.drag;
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)
@ -3607,7 +3666,7 @@ function uPlot(opts, data, then) {
label && remClass(label, OFF); label && remClass(label, OFF);
else { else {
label && addClass(label, OFF); label && addClass(label, OFF);
cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss);
} }
} }
@ -3626,7 +3685,7 @@ function uPlot(opts, data, then) {
if (opts.show != null) { if (opts.show != null) {
s.show = opts.show; s.show = opts.show;
toggleDOM(i, opts.show); toggleDOM(i, opts.show);
_setScale(s.scale, null, null); _setScale(s.scale, null, null);
commit(); commit();
@ -3634,7 +3693,7 @@ function uPlot(opts, data, then) {
fire("setSeries", i, opts); fire("setSeries", i, opts);
pub && sync.pub("setSeries", self, i, opts); pub && sync.pub("setSeries", self, i, opts);
} }
self.setSeries = setSeries; self.setSeries = setSeries;
@ -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) {
@ -3741,7 +3802,7 @@ function uPlot(opts, data, then) {
self.batch = batch; self.batch = batch;
(self.setCursor = opts => { (self.setCursor = opts => {
mouseLeft1 = opts.left; mouseLeft1 = opts.left;
mouseTop1 = opts.top; mouseTop1 = opts.top;
// assign(cursor, opts); // assign(cursor, opts);
@ -3792,7 +3853,7 @@ function uPlot(opts, data, then) {
for (let i = 0; i < series.length; i++) { for (let i = 0; i < series.length; i++) {
if (i > 0) { if (i > 0) {
cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss);
} }
if (showLegend && legend.live) { if (showLegend && legend.live) {
@ -3849,7 +3910,7 @@ function uPlot(opts, data, then) {
vPos = xPos2; vPos = xPos2;
} }
cursorPts.length > 1 && trans(cursorPts[i], hPos, vPos, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i], hPos, vPos, plotWidCss, plotHgtCss);
} }
if (showLegend && legend.live) { if (showLegend && legend.live) {
@ -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);
@ -4311,28 +4372,28 @@ function uPlot(opts, data, then) {
hooks[evName] = (hooks[evName] || []).concat(p.hooks[evName]); hooks[evName] = (hooks[evName] || []).concat(p.hooks[evName]);
}); });
const syncOpts = assign({ const syncOpts = assign({
key: null, key: null,
setSeries: false, setSeries: false,
scales: [xScaleKey, null] scales: [xScaleKey, null]
}, cursor.sync); }, cursor.sync);
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);
function pub(type, src, x, y, w, h, i) { function pub(type, src, x, y, w, h, i) {
events[type](null, src, x, y, w, h, i); events[type](null, src, x, y, w, h, i);
} }
(self.pub = pub); (self.pub = pub);
function destroy() { function destroy() {
sync.unsub(self); sync.unsub(self);
off(resize, win, deb); off(resize, win, deb);
off(scroll, win, deb); off(scroll, win, deb);
root.remove(); root.remove();
fire("destroy"); fire("destroy");
} }
@ -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,16 +4445,20 @@ uPlot.orient = orient;
uPlot.tzDate = tzDate; uPlot.tzDate = tzDate;
} }
{
uPlot.sync = _sync;
}
{ {
uPlot.addGap = addGap; uPlot.addGap = addGap;
uPlot.clipGaps = clipGaps; uPlot.clipGaps = clipGaps;
let paths = uPlot.paths = {}; let paths = uPlot.paths = {};
(paths.linear = linear); (paths.linear = linear);
(paths.spline = spline); (paths.spline = spline);
(paths.stepped = stepped); (paths.stepped = stepped);
(paths.bars = bars); (paths.bars = bars);
} }
module.exports = uPlot; module.exports = uPlot;

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;
@ -539,9 +554,9 @@ function slice3(str) {
return str.slice(0, 3); return str.slice(0, 3);
} }
const days3 = days.map(slice3); const days3 = days.map(slice3);
const months3 = months.map(slice3); const months3 = months.map(slice3);
const engNames = { const engNames = {
MMMM: months, MMMM: months,
@ -866,8 +881,8 @@ function genTimeStuffs(ms) {
]; ];
} }
const [ timeIncrsMs, _timeAxisStampsMs, timeAxisSplitsMs ] = genTimeStuffs(1); const [ timeIncrsMs, _timeAxisStampsMs, timeAxisSplitsMs ] = genTimeStuffs(1);
const [ timeIncrsS, _timeAxisStampsS, timeAxisSplitsS ] = genTimeStuffs(1e-3); const [ timeIncrsS, _timeAxisStampsS, timeAxisSplitsS ] = genTimeStuffs(1e-3);
// base 2 // base 2
genIncrs(2, -53, 53, [1]); genIncrs(2, -53, 53, [1]);
@ -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,24 +1333,31 @@ const yScaleOpts = assign({}, xScaleOpts, {
const syncs = {}; const syncs = {};
function _sync(opts) { function _sync(key, opts) {
let clients = []; let s = syncs[key];
return { if (!s) {
sub(client) { let clients = [];
clients.push(client);
}, s = {
unsub(client) { key,
clients = clients.filter(c => c != client); sub(client) {
}, clients.push(client);
pub(type, self, x, y, w, h, i) { },
if (clients.length > 1) { unsub(client) {
clients.forEach(client => { clients = clients.filter(c => c != client);
client != self && client.pub(type, self, x, y, w, h, i); },
}); pub(type, self, x, y, w, h, i) {
for (let i = 0; i < clients.length; i++)
clients[i] != self && clients[i].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) {
@ -1979,7 +2016,7 @@ function bars(opts) {
}; };
} }
const linearPath = linear() ; const linearPath = linear() ;
function setDefaults(d, xo, yo, initY) { function setDefaults(d, xo, yo, initY) {
let d2 = initY ? [d[0], d[1]].concat(d.slice(2)) : [d[0]].concat(d.slice(1)); let d2 = initY ? [d[0], d[1]].concat(d.slice(2)) : [d[0]].concat(d.slice(1));
@ -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) {
@ -2131,8 +2177,7 @@ 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;
} }
} }
} }
@ -2223,15 +2274,15 @@ function uPlot(opts, data, then) {
} }
// self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone; // self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone;
const _tzDate = (opts.tzDate || (ts => new Date(ts / ms))); const _tzDate = (opts.tzDate || (ts => new Date(ts / ms)));
const _fmtDate = (opts.fmtDate || fmtDate); const _fmtDate = (opts.fmtDate || fmtDate);
const _timeAxisSplits = (ms == 1 ? timeAxisSplitsMs(_tzDate) : timeAxisSplitsS(_tzDate)); const _timeAxisSplits = (ms == 1 ? timeAxisSplitsMs(_tzDate) : timeAxisSplitsS(_tzDate));
const _timeAxisVals = timeAxisVals(_tzDate, timeAxisStamps((ms == 1 ? _timeAxisStampsMs : _timeAxisStampsS), _fmtDate)); const _timeAxisVals = timeAxisVals(_tzDate, timeAxisStamps((ms == 1 ? _timeAxisStampsMs : _timeAxisStampsS), _fmtDate));
const _timeSeriesVal = timeSeriesVal(_tzDate, timeSeriesStamp(_timeSeriesStamp, _fmtDate)); const _timeSeriesVal = timeSeriesVal(_tzDate, timeSeriesStamp(_timeSeriesStamp, _fmtDate));
const legend = assign({show: true, live: true}, opts.legend); const legend = assign({show: true, live: true}, opts.legend);
const showLegend = legend.show; const showLegend = legend.show;
{ {
legend.width = fnOrSelf(ifNull(legend.width, legendWidth)); legend.width = fnOrSelf(ifNull(legend.width, legendWidth));
@ -2297,10 +2348,10 @@ 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);
}); });
if (cursorFocus) { if (cursorFocus) {
@ -2507,7 +2558,7 @@ function uPlot(opts, data, then) {
}); });
} }
const cursor = (self.cursor = assign({}, cursorOpts, opts.cursor)); const cursor = (self.cursor = assign({}, cursorOpts, opts.cursor));
{ {
cursor._lock = false; cursor._lock = false;
@ -2521,8 +2572,8 @@ function uPlot(opts, data, then) {
points.fill = fnOrSelf(points.fill); points.fill = fnOrSelf(points.fill);
} }
const focus = self.focus = assign({}, opts.focus || {alpha: 0.3}, cursor.focus); const focus = self.focus = assign({}, opts.focus || {alpha: 0.3}, cursor.focus);
const cursorFocus = focus.prox >= 0; const cursorFocus = focus.prox >= 0;
// series-intersection markers // series-intersection markers
let cursorPts = [null]; let cursorPts = [null];
@ -2543,7 +2594,7 @@ function uPlot(opts, data, then) {
} }
function initSeries(s, i) { function initSeries(s, i) {
let isTime = scales[s.scale].time; let isTime = scales[s.scale].time;
let sv = s.value; let sv = s.value;
s.value = isTime ? (isStr(sv) ? timeSeriesVal(_tzDate, timeSeriesStamp(sv, _fmtDate)) : sv || _timeSeriesVal) : sv || numSeriesVal; s.value = isTime ? (isStr(sv) ? timeSeriesVal(_tzDate, timeSeriesStamp(sv, _fmtDate)) : sv || _timeSeriesVal) : sv || numSeriesVal;
@ -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);
} }
@ -2594,8 +2645,8 @@ function uPlot(opts, data, then) {
function delSeries(i) { function delSeries(i) {
series.splice(i, 1); series.splice(i, 1);
showLegend && legendRows.splice(i, 1)[0][0].parentNode.remove(); showLegend && legendRows.splice(i, 1)[0][0].parentNode.remove();
cursorPts.length > 1 && cursorPts.splice(i, 1)[0].remove(); cursorPts.length > 1 && cursorPts.splice(i, 1)[0].remove();
// TODO: de-init no-longer-needed scales? // TODO: de-init no-longer-needed scales?
} }
@ -2621,13 +2672,13 @@ function uPlot(opts, data, then) {
} }
// also set defaults for incrs & values based on axis distr // also set defaults for incrs & values based on axis distr
let isTime = sc.time; let isTime = sc.time;
axis.size = fnOrSelf(axis.size); axis.size = fnOrSelf(axis.size);
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;
} }
@ -3010,10 +3069,10 @@ function uPlot(opts, data, then) {
series.forEach((s, i) => { series.forEach((s, i) => {
if (i > 0 && s.show) { if (i > 0 && s.show) {
if (s._paths) if (s._paths)
drawPath(i); drawPath(i);
if (s.points.show(self, i, i0, i1)) if (s.points.show(self, i, i0, i1))
drawPoints(i); drawPoints(i);
fire("drawSeries", i); fire("drawSeries", i);
} }
@ -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;
} }
@ -3551,12 +3610,12 @@ function uPlot(opts, data, then) {
let dragging = false; let dragging = false;
const drag = cursor.drag; const drag = cursor.drag;
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)
@ -3605,7 +3664,7 @@ function uPlot(opts, data, then) {
label && remClass(label, OFF); label && remClass(label, OFF);
else { else {
label && addClass(label, OFF); label && addClass(label, OFF);
cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss);
} }
} }
@ -3624,7 +3683,7 @@ function uPlot(opts, data, then) {
if (opts.show != null) { if (opts.show != null) {
s.show = opts.show; s.show = opts.show;
toggleDOM(i, opts.show); toggleDOM(i, opts.show);
_setScale(s.scale, null, null); _setScale(s.scale, null, null);
commit(); commit();
@ -3632,7 +3691,7 @@ function uPlot(opts, data, then) {
fire("setSeries", i, opts); fire("setSeries", i, opts);
pub && sync.pub("setSeries", self, i, opts); pub && sync.pub("setSeries", self, i, opts);
} }
self.setSeries = setSeries; self.setSeries = setSeries;
@ -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) {
@ -3739,7 +3800,7 @@ function uPlot(opts, data, then) {
self.batch = batch; self.batch = batch;
(self.setCursor = opts => { (self.setCursor = opts => {
mouseLeft1 = opts.left; mouseLeft1 = opts.left;
mouseTop1 = opts.top; mouseTop1 = opts.top;
// assign(cursor, opts); // assign(cursor, opts);
@ -3790,7 +3851,7 @@ function uPlot(opts, data, then) {
for (let i = 0; i < series.length; i++) { for (let i = 0; i < series.length; i++) {
if (i > 0) { if (i > 0) {
cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss);
} }
if (showLegend && legend.live) { if (showLegend && legend.live) {
@ -3847,7 +3908,7 @@ function uPlot(opts, data, then) {
vPos = xPos2; vPos = xPos2;
} }
cursorPts.length > 1 && trans(cursorPts[i], hPos, vPos, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i], hPos, vPos, plotWidCss, plotHgtCss);
} }
if (showLegend && legend.live) { if (showLegend && legend.live) {
@ -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);
@ -4309,28 +4370,28 @@ function uPlot(opts, data, then) {
hooks[evName] = (hooks[evName] || []).concat(p.hooks[evName]); hooks[evName] = (hooks[evName] || []).concat(p.hooks[evName]);
}); });
const syncOpts = assign({ const syncOpts = assign({
key: null, key: null,
setSeries: false, setSeries: false,
scales: [xScaleKey, null] scales: [xScaleKey, null]
}, cursor.sync); }, cursor.sync);
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);
function pub(type, src, x, y, w, h, i) { function pub(type, src, x, y, w, h, i) {
events[type](null, src, x, y, w, h, i); events[type](null, src, x, y, w, h, i);
} }
(self.pub = pub); (self.pub = pub);
function destroy() { function destroy() {
sync.unsub(self); sync.unsub(self);
off(resize, win, deb); off(resize, win, deb);
off(scroll, win, deb); off(scroll, win, deb);
root.remove(); root.remove();
fire("destroy"); fire("destroy");
} }
@ -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,16 +4443,20 @@ uPlot.orient = orient;
uPlot.tzDate = tzDate; uPlot.tzDate = tzDate;
} }
{
uPlot.sync = _sync;
}
{ {
uPlot.addGap = addGap; uPlot.addGap = addGap;
uPlot.clipGaps = clipGaps; uPlot.clipGaps = clipGaps;
let paths = uPlot.paths = {}; let paths = uPlot.paths = {};
(paths.linear = linear); (paths.linear = linear);
(paths.spline = spline); (paths.spline = spline);
(paths.stepped = stepped); (paths.stepped = stepped);
(paths.bars = bars); (paths.bars = bars);
} }
export default uPlot; export default uPlot;

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;
@ -539,9 +562,9 @@ var uPlot = (function () {
return str.slice(0, 3); return str.slice(0, 3);
} }
var days3 = days.map(slice3); var days3 = days.map(slice3);
var months3 = months.map(slice3); var months3 = months.map(slice3);
var engNames = { var engNames = {
MMMM: months, MMMM: months,
@ -863,11 +886,11 @@ var uPlot = (function () {
timeAxisSplits ]; timeAxisSplits ];
} }
var ref = genTimeStuffs(1); var ref = genTimeStuffs(1);
var timeIncrsMs = ref[0]; var timeIncrsMs = ref[0];
var _timeAxisStampsMs = ref[1]; var _timeAxisStampsMs = ref[1];
var timeAxisSplitsMs = ref[2]; var timeAxisSplitsMs = ref[2];
var ref$1 = genTimeStuffs(1e-3); var ref$1 = genTimeStuffs(1e-3);
var timeIncrsS = ref$1[0]; var timeIncrsS = ref$1[0];
var _timeAxisStampsS = ref$1[1]; var _timeAxisStampsS = ref$1[1];
var timeAxisSplitsS = ref$1[2]; var timeAxisSplitsS = ref$1[2];
@ -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,24 +1344,31 @@ var uPlot = (function () {
var syncs = {}; var syncs = {};
function _sync(opts) { function _sync(key, opts) {
var clients = []; var s = syncs[key];
return { if (!s) {
sub: function sub(client) { var clients = [];
clients.push(client);
}, s = {
unsub: function unsub(client) { key: key,
clients = clients.filter(c => c != client); sub: function sub(client) {
}, clients.push(client);
pub: function pub(type, self, x, y, w, h, i) { },
if (clients.length > 1) { unsub: function unsub(client) {
clients.forEach(client => { clients = clients.filter(c => c != client);
client != self && client.pub(type, self, x, y, w, h, i); },
}); pub: function pub(type, self, x, y, w, h, i) {
for (var i$1 = 0; i$1 < clients.length; i$1++)
{ clients[i$1] != self && clients[i$1].pub(type, self, x, y, w, h, i$1); }
} }
} };
};
if (key != null)
{ syncs[key] = s; }
}
return s;
} }
function orient(u, seriesIdx, cb) { function orient(u, seriesIdx, cb) {
@ -1975,7 +2020,7 @@ var uPlot = (function () {
}; };
} }
var linearPath = linear() ; var linearPath = linear() ;
function setDefaults(d, xo, yo, initY) { function setDefaults(d, xo, yo, initY) {
var d2 = initY ? [d[0], d[1]].concat(d.slice(2)) : [d[0]].concat(d.slice(1)); var d2 = initY ? [d[0], d[1]].concat(d.slice(2)) : [d[0]].concat(d.slice(1));
@ -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) {
@ -2127,8 +2181,7 @@ 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;
} }
} }
} }
@ -2219,15 +2278,15 @@ var uPlot = (function () {
} }
// self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone; // self.tz = opts.tz || Intl.DateTimeFormat().resolvedOptions().timeZone;
var _tzDate = (opts.tzDate || (ts => new Date(ts / ms))); var _tzDate = (opts.tzDate || (ts => new Date(ts / ms)));
var _fmtDate = (opts.fmtDate || fmtDate); var _fmtDate = (opts.fmtDate || fmtDate);
var _timeAxisSplits = (ms == 1 ? timeAxisSplitsMs(_tzDate) : timeAxisSplitsS(_tzDate)); var _timeAxisSplits = (ms == 1 ? timeAxisSplitsMs(_tzDate) : timeAxisSplitsS(_tzDate));
var _timeAxisVals = timeAxisVals(_tzDate, timeAxisStamps((ms == 1 ? _timeAxisStampsMs : _timeAxisStampsS), _fmtDate)); var _timeAxisVals = timeAxisVals(_tzDate, timeAxisStamps((ms == 1 ? _timeAxisStampsMs : _timeAxisStampsS), _fmtDate));
var _timeSeriesVal = timeSeriesVal(_tzDate, timeSeriesStamp(_timeSeriesStamp, _fmtDate)); var _timeSeriesVal = timeSeriesVal(_tzDate, timeSeriesStamp(_timeSeriesStamp, _fmtDate));
var legend = assign({show: true, live: true}, opts.legend); var legend = assign({show: true, live: true}, opts.legend);
var showLegend = legend.show; var showLegend = legend.show;
{ {
legend.width = fnOrSelf(ifNull(legend.width, legendWidth)); legend.width = fnOrSelf(ifNull(legend.width, legendWidth));
@ -2293,10 +2352,10 @@ 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);
}); });
if (cursorFocus) { if (cursorFocus) {
@ -2507,7 +2566,7 @@ var uPlot = (function () {
}); });
} }
var cursor = (self.cursor = assign({}, cursorOpts, opts.cursor)); var cursor = (self.cursor = assign({}, cursorOpts, opts.cursor));
{ {
cursor._lock = false; cursor._lock = false;
@ -2521,8 +2580,8 @@ var uPlot = (function () {
points.fill = fnOrSelf(points.fill); points.fill = fnOrSelf(points.fill);
} }
var focus = self.focus = assign({}, opts.focus || {alpha: 0.3}, cursor.focus); var focus = self.focus = assign({}, opts.focus || {alpha: 0.3}, cursor.focus);
var cursorFocus = focus.prox >= 0; var cursorFocus = focus.prox >= 0;
// series-intersection markers // series-intersection markers
var cursorPts = [null]; var cursorPts = [null];
@ -2543,7 +2602,7 @@ var uPlot = (function () {
} }
function initSeries(s, i) { function initSeries(s, i) {
var isTime = scales[s.scale].time; var isTime = scales[s.scale].time;
var sv = s.value; var sv = s.value;
s.value = isTime ? (isStr(sv) ? timeSeriesVal(_tzDate, timeSeriesStamp(sv, _fmtDate)) : sv || _timeSeriesVal) : sv || numSeriesVal; s.value = isTime ? (isStr(sv) ? timeSeriesVal(_tzDate, timeSeriesStamp(sv, _fmtDate)) : sv || _timeSeriesVal) : sv || numSeriesVal;
@ -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);
} }
@ -2594,8 +2653,8 @@ var uPlot = (function () {
function delSeries(i) { function delSeries(i) {
series.splice(i, 1); series.splice(i, 1);
showLegend && legendRows.splice(i, 1)[0][0].parentNode.remove(); showLegend && legendRows.splice(i, 1)[0][0].parentNode.remove();
cursorPts.length > 1 && cursorPts.splice(i, 1)[0].remove(); cursorPts.length > 1 && cursorPts.splice(i, 1)[0].remove();
// TODO: de-init no-longer-needed scales? // TODO: de-init no-longer-needed scales?
} }
@ -2621,13 +2680,13 @@ var uPlot = (function () {
} }
// also set defaults for incrs & values based on axis distr // also set defaults for incrs & values based on axis distr
var isTime = sc.time; var isTime = sc.time;
axis.size = fnOrSelf(axis.size); axis.size = fnOrSelf(axis.size);
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; }
} }
@ -3015,10 +3082,10 @@ var uPlot = (function () {
series.forEach((s, i) => { series.forEach((s, i) => {
if (i > 0 && s.show) { if (i > 0 && s.show) {
if (s._paths) if (s._paths)
{ drawPath(i); } { drawPath(i); }
if (s.points.show(self, i, i0, i1)) if (s.points.show(self, i, i0, i1))
{ drawPoints(i); } { drawPoints(i); }
fire("drawSeries", i); fire("drawSeries", i);
} }
@ -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;
} }
@ -3564,12 +3631,12 @@ var uPlot = (function () {
var dragging = false; var dragging = false;
var drag = cursor.drag; var drag = cursor.drag;
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)
@ -3618,7 +3685,7 @@ var uPlot = (function () {
{ label && remClass(label, OFF); } { label && remClass(label, OFF); }
else { else {
label && addClass(label, OFF); label && addClass(label, OFF);
cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss);
} }
} }
@ -3637,7 +3704,7 @@ var uPlot = (function () {
if (opts.show != null) { if (opts.show != null) {
s.show = opts.show; s.show = opts.show;
toggleDOM(i, opts.show); toggleDOM(i, opts.show);
_setScale(s.scale, null, null); _setScale(s.scale, null, null);
commit(); commit();
@ -3645,7 +3712,7 @@ var uPlot = (function () {
fire("setSeries", i, opts); fire("setSeries", i, opts);
pub && sync.pub("setSeries", self, i, opts); pub && sync.pub("setSeries", self, i, opts);
} }
self.setSeries = setSeries; self.setSeries = setSeries;
@ -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) {
@ -3752,7 +3821,7 @@ var uPlot = (function () {
self.batch = batch; self.batch = batch;
(self.setCursor = opts => { (self.setCursor = opts => {
mouseLeft1 = opts.left; mouseLeft1 = opts.left;
mouseTop1 = opts.top; mouseTop1 = opts.top;
// assign(cursor, opts); // assign(cursor, opts);
@ -3805,7 +3874,7 @@ var uPlot = (function () {
for (var i = 0; i < series.length; i++) { for (var i = 0; i < series.length; i++) {
if (i > 0) { if (i > 0) {
cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i], -10, -10, plotWidCss, plotHgtCss);
} }
if (showLegend && legend.live) { if (showLegend && legend.live) {
@ -3862,7 +3931,7 @@ var uPlot = (function () {
vPos = xPos2; vPos = xPos2;
} }
cursorPts.length > 1 && trans(cursorPts[i$1], hPos, vPos, plotWidCss, plotHgtCss); cursorPts.length > 1 && trans(cursorPts[i$1], hPos, vPos, plotWidCss, plotHgtCss);
} }
if (showLegend && legend.live) { if (showLegend && legend.live) {
@ -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);
@ -4337,28 +4406,28 @@ var uPlot = (function () {
{ hooks[evName] = (hooks[evName] || []).concat(p.hooks[evName]); } { hooks[evName] = (hooks[evName] || []).concat(p.hooks[evName]); }
}); });
var syncOpts = assign({ var syncOpts = assign({
key: null, key: null,
setSeries: false, setSeries: false,
scales: [xScaleKey, null] scales: [xScaleKey, null]
}, cursor.sync); }, cursor.sync);
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);
function pub(type, src, x, y, w, h, i) { function pub(type, src, x, y, w, h, i) {
events[type](null, src, x, y, w, h, i); events[type](null, src, x, y, w, h, i);
} }
(self.pub = pub); (self.pub = pub);
function destroy() { function destroy() {
sync.unsub(self); sync.unsub(self);
off(resize, win, deb); off(resize, win, deb);
off(scroll, win, deb); off(scroll, win, deb);
root.remove(); root.remove();
fire("destroy"); fire("destroy");
} }
@ -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,16 +4479,20 @@ var uPlot = (function () {
uPlot.tzDate = tzDate; uPlot.tzDate = tzDate;
} }
{
uPlot.sync = _sync;
}
{ {
uPlot.addGap = addGap; uPlot.addGap = addGap;
uPlot.clipGaps = clipGaps; uPlot.clipGaps = clipGaps;
var paths = uPlot.paths = {}; var paths = uPlot.paths = {};
(paths.linear = linear); (paths.linear = linear);
(paths.spline = spline); (paths.spline = spline);
(paths.stepped = stepped); (paths.stepped = stepped);
(paths.bars = bars); (paths.bars = bars);
} }
return uPlot; return uPlot;

File diff suppressed because one or more lines are too long