update plugin files

This commit is contained in:
REJack
2021-02-10 08:13:13 +01:00
parent c8fdba0831
commit 966a9b0178
16 changed files with 17016 additions and 2963 deletions

View File

@@ -4,7 +4,7 @@
*
* uPlot.js (μPlot)
* A small, fast chart for time series, lines, areas, ohlc & bars
* https://github.com/leeoniya/uPlot (v1.6.3)
* https://github.com/leeoniya/uPlot (v1.6.4)
*/
'use strict';
@@ -336,13 +336,13 @@ function assign(targ) {
}
// nullModes
const NULL_IGNORE = 0; // all nulls are ignored, converted to undefined (e.g. spanGaps: true)
const NULL_GAP = 1; // nulls are retained, alignment artifacts = undefined values (default)
const NULL_EXPAND = 2; // nulls are expanded to include adjacent alignment artifacts (undefined values)
const NULL_REMOVE = 0; // nulls are converted to undefined (e.g. for spanGaps: true)
const NULL_RETAIN = 1; // nulls are retained, with alignment artifacts set to undefined (default)
const NULL_EXPAND = 2; // nulls are expanded to include any adjacent alignment artifacts
// mark all filler nulls as explicit when adjacent to existing explicit nulls (minesweeper)
// sets undefined values to nulls when adjacent to existing nulls (minesweeper)
function nullExpand(yVals, nullIdxs, alignedLen) {
for (let i = 0, xi, lastNullIdx = -inf; i < nullIdxs.length; i++) {
for (let i = 0, xi, lastNullIdx = -1; i < nullIdxs.length; i++) {
let nullIdx = nullIdxs[i];
if (nullIdx > lastNullIdx) {
@@ -358,10 +358,8 @@ function nullExpand(yVals, nullIdxs, alignedLen) {
}
// nullModes is a tables-matched array indicating how to treat nulls in each series
// output is sorted ASC on the joined field (table[0]) and duplicate join values are collapsed
function join(tables, nullModes) {
if (tables.length == 1)
return tables[0];
let xVals = new Set();
for (let ti = 0; ti < tables.length; ti++) {
@@ -391,7 +389,7 @@ function join(tables, nullModes) {
let yVals = Array(alignedLen).fill(undefined);
let nullMode = nullModes ? nullModes[ti][si] : NULL_GAP;
let nullMode = nullModes ? nullModes[ti][si] : NULL_RETAIN;
let nullIdxs = [];
@@ -400,7 +398,7 @@ function join(tables, nullModes) {
let alignedIdx = xIdxs.get(xs[i]);
if (yVal == null) {
if (nullMode != NULL_IGNORE) {
if (nullMode != NULL_REMOVE) {
yVals[alignedIdx] = yVal;
if (nullMode == NULL_EXPAND)
@@ -874,7 +872,7 @@ const [ timeIncrsMs, _timeAxisStampsMs, timeAxisSplitsMs ] = genTimeStuffs(1);
const [ timeIncrsS, _timeAxisStampsS, timeAxisSplitsS ] = genTimeStuffs(1e-3);
// base 2
const binIncrs = genIncrs(2, -53, 53, [1]);
genIncrs(2, -53, 53, [1]);
/*
console.log({
@@ -1468,9 +1466,11 @@ function bezierCurveToH(p, bp1x, bp1y, bp2x, bp2y, p2x, p2y) { p.bezierCurveTo(b
function _drawAcc(lineTo) {
return (stroke, accX, minY, maxY, outY) => {
lineTo(stroke, accX, minY);
lineTo(stroke, accX, maxY);
lineTo(stroke, accX, outY);
if (minY != maxY) {
lineTo(stroke, accX, minY);
lineTo(stroke, accX, maxY);
lineTo(stroke, accX, outY);
}
};
}
@@ -2089,6 +2089,8 @@ function uPlot(opts, data, then) {
opts = copy(opts);
const pxAlign = ifNull(opts.pxAlign, true);
(opts.plugins || []).forEach(p => {
if (p.opts)
opts = p.opts(self, opts) || opts;
@@ -2553,10 +2555,11 @@ function uPlot(opts, data, then) {
s.width = s.width == null ? 1 : s.width;
s.paths = s.paths || linearPath || retNull;
s.fillTo = fnOrSelf(s.fillTo || seriesFillTo);
s.pxAlign = ifNull(s.pxAlign, true);
s.stroke = fnOrSelf(s.stroke || null);
s.fill = fnOrSelf(s.fill || null);
s._stroke = s._fill = s._paths = null;
s._stroke = s._fill = s._paths = s._focus = null;
let _ptDia = ptDia(s.width, 1);
let points = s.points = assign({}, {
@@ -2916,7 +2919,9 @@ function uPlot(opts, data, then) {
let rad = (p.size - p.width) / 2 * pxRatio;
let dia = roundDec(rad * 2, 3);
ctx.translate(offset, offset);
const _pxAlign = pxAlign && s.pxAlign;
_pxAlign && ctx.translate(offset, offset);
ctx.save();
@@ -2978,7 +2983,7 @@ function uPlot(opts, data, then) {
ctx.restore();
ctx.translate(-offset, -offset);
_pxAlign && ctx.translate(-offset, -offset);
}
// grabs the nearest indices with y data outside of x-scale limits
@@ -3025,14 +3030,14 @@ function uPlot(opts, data, then) {
const width = roundDec(s.width * pxRatio, 3);
const offset = (width % 2) / 2;
const _stroke = s._stroke = s.stroke(self, si);
const _fill = s._fill = s.fill(self, si);
setCtxStyle(_stroke, width, s.dash, s.cap, _fill);
const strokeStyle = s._stroke = s.stroke(self, si);
const fillStyle = s._fill = s.fill(self, si);
ctx.globalAlpha = s.alpha;
ctx.translate(offset, offset);
const _pxAlign = pxAlign && s.pxAlign;
_pxAlign && ctx.translate(offset, offset);
ctx.save();
@@ -3057,43 +3062,53 @@ function uPlot(opts, data, then) {
clip && ctx.clip(clip);
let isUpperEdge = fillBands(si, _fill);
!isUpperEdge && _fill && fill && ctx.fill(fill);
width && _stroke && stroke && ctx.stroke(stroke);
fillStroke(si, strokeStyle, width, s.dash, s.cap, fillStyle, stroke, fill);
ctx.restore();
ctx.translate(-offset, -offset);
_pxAlign && ctx.translate(-offset, -offset);
ctx.globalAlpha = 1;
}
function fillBands(si, seriesFill) {
let isUpperEdge = false;
let s = series[si];
function fillStroke(si, strokeStyle, lineWidth, lineDash, lineCap, fillStyle, strokePath, fillPath) {
let didStrokeFill = false;
// for all bands where this series is the top edge, create upwards clips using the bottom edges
// and apply clips + fill with band fill or dfltFill
bands.forEach((b, bi) => {
// isUpperEdge?
if (b.series[0] == si) {
isUpperEdge = true;
let lowerEdge = series[b.series[1]];
let clip = (lowerEdge._paths || EMPTY_OBJ).band;
ctx.save();
let _fillStyle = null;
// hasLowerEdge?
if (lowerEdge.show && clip) {
ctx.save();
setCtxStyle(null, null, null, null, b.fill(self, bi) || seriesFill);
_fillStyle = b.fill(self, bi) || fillStyle;
ctx.clip(clip);
ctx.fill(s._paths.fill);
ctx.restore();
}
strokeFill(strokeStyle, lineWidth, lineDash, lineCap, _fillStyle, strokePath, fillPath);
ctx.restore();
didStrokeFill = true;
}
});
return isUpperEdge;
if (!didStrokeFill)
strokeFill(strokeStyle, lineWidth, lineDash, lineCap, fillStyle, strokePath, fillPath);
}
function strokeFill(strokeStyle, lineWidth, lineDash, lineCap, fillStyle, strokePath, fillPath) {
setCtxStyle(strokeStyle, lineWidth, lineDash, lineCap, fillStyle);
fillStyle && fillPath && ctx.fill(fillPath);
strokeStyle && strokePath && lineWidth && ctx.stroke(strokePath);
}
function getIncrSpace(axisIdx, min, max, fullDim) {
@@ -3115,7 +3130,7 @@ function uPlot(opts, data, then) {
function drawOrthoLines(offs, filts, ori, side, pos0, len, width, stroke, dash, cap) {
let offset = (width % 2) / 2;
ctx.translate(offset, offset);
pxAlign && ctx.translate(offset, offset);
setCtxStyle(stroke, width, dash, cap);
@@ -3147,7 +3162,7 @@ function uPlot(opts, data, then) {
ctx.stroke();
ctx.translate(-offset, -offset);
pxAlign && ctx.translate(-offset, -offset);
}
function axesCalc(cycleNum) {
@@ -3197,7 +3212,7 @@ function uPlot(opts, data, then) {
let splits = scale.distr == 2 ? _splits.map(i => data0[i]) : _splits;
let incr = scale.distr == 2 ? data0[_splits[1]] - data0[_splits[0]] : _incr;
let values = axis._values = axis.values(self, axis.filter(self, splits, i, _space, incr), i, _space, incr);
let values = axis._values = axis.values(self, axis.filter(self, splits, i, _space, incr), i, _space, incr);
// rotating of labels only supported on bottom x axis
axis._rotate = side == 2 ? axis.rotate(self, values, i, _space) : 0;
@@ -3240,7 +3255,7 @@ function uPlot(opts, data, then) {
let plotDim = ori == 0 ? plotWid : plotHgt;
let plotOff = ori == 0 ? plotLft : plotTop;
let axisGap = round(axis.gap * pxRatio);
let axisGap = round(axis.gap * pxRatio);
let ticks = axis.ticks;
let tickSize = ticks.show ? round(ticks.size * pxRatio) : 0;
@@ -3273,7 +3288,7 @@ function uPlot(opts, data, then) {
ctx.textBaseline = angle ||
ori == 1 ? "middle" : side == 2 ? TOP : BOTTOM;
let lineHeight = axis.font[1] * lineMult;
let lineHeight = axis.font[1] * lineMult;
let canOffs = _splits.map(val => round(getPos(val, scale, plotDim, plotOff)));
@@ -3464,7 +3479,9 @@ function uPlot(opts, data, then) {
queuedCommit = false;
}
self.redraw = rebuildPaths => {
self.redraw = (rebuildPaths, recalcAxes) => {
shouldConvergeSize = recalcAxes || false;
if (rebuildPaths !== false)
_setScale(xScaleKey, scaleX.min, scaleX.max);
else
@@ -3563,10 +3580,10 @@ function uPlot(opts, data, then) {
const select = self.select = assign({
show: true,
over: true,
left: 0,
width: 0,
top: 0,
height: 0,
left: 0,
width: 0,
top: 0,
height: 0,
}, opts.select);
const selectDiv = select.show ? placeDiv(SELECT, select.over ? over : under) : null;
@@ -3648,8 +3665,12 @@ function uPlot(opts, data, then) {
if (i != focusedSeries) {
// log("setFocus()", arguments);
let allFocused = i == null;
series.forEach((s, i2) => {
_setAlpha(i2, i == null || i2 == 0 || i2 == i ? 1 : focus.alpha);
let isFocused = allFocused || i2 == 0 || i2 == i;
s._focus = allFocused ? null : isFocused;
_setAlpha(i2, isFocused ? 1 : focus.alpha);
});
focusedSeries = i;