From d74aafd83485ad42ef4bbf834fd71c037e26b5a0 Mon Sep 17 00:00:00 2001 From: will Farrell Date: Sat, 10 Aug 2024 18:51:28 -0600 Subject: [PATCH] feat: add in localization override for time and num Fixes #474 --- demos/index.html | 2 +- demos/{months-ru.html => localize-fr-ca.html} | 17 +- dist/uPlot.cjs.js | 474 +++++++----------- dist/uPlot.d.ts | 22 +- dist/uPlot.esm.js | 474 +++++++----------- dist/uPlot.iife.js | 474 +++++++----------- dist/uPlot.iife.min.js | 2 +- src/fmtDate.js | 146 ------ src/opts.js | 46 +- src/tzDate.js | 19 + src/uPlot.js | 22 +- src/utils.js | 8 +- 12 files changed, 593 insertions(+), 1113 deletions(-) rename demos/{months-ru.html => localize-fr-ca.html} (55%) delete mode 100644 src/fmtDate.js create mode 100644 src/tzDate.js diff --git a/demos/index.html b/demos/index.html index b1d35fd2..3c63b017 100644 --- a/demos/index.html +++ b/demos/index.html @@ -84,7 +84,7 @@

μPlot Demos

Discrete & shifted series w/sync Maintains location of cursor/select/hoverPts during resize (test) - Russian month names on date/time axis + Override default localization (French Canada) Dynamically add or delete series Sync chart position when inside a scrollable container diff --git a/demos/months-ru.html b/demos/localize-fr-ca.html similarity index 55% rename from demos/months-ru.html rename to demos/localize-fr-ca.html index 621aab7e..22667d83 100644 --- a/demos/months-ru.html +++ b/demos/localize-fr-ca.html @@ -2,7 +2,7 @@ - Months (Russian) + Localize Time & Measure (French Canadian) @@ -23,26 +23,19 @@ }) }); - let vals = [0,1,2,3,4,5,6,7,8,9,10]; + let vals = [1000.1,1100.1,1200.2,1300.3,1400.4,1500.5,1600.6,1700.7,1800.8,1900.9,2000.10]; let data = [ ts, - ts.map((t, i) => i == 0 ? 5 : vals[Math.floor(Math.random() * vals.length)]), + ts.map((t, i) => i == 0 ? 1500 : vals[Math.floor(Math.random() * vals.length)]), ]; - const ruNames = { - MMMM: ["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"], - MMM: ["Янв","Февр","Март","Апр","Май","Июнь","Июль","Авг","Сент","Окт","Нояб","Дек"], - WWWW: ["Воскресенье","Понедельник","Вторник","Среда","Четверг","Пятница","Суббота"], - WWW: ["Вск","Пнд","Втр","Срд","Чтв","Птн","Сбт"], - }; - const opts = { width: 1920, height: 600, title: "Months", + locale: 'fr-CA', tzDate: ts => uPlot.tzDate(new Date(ts * 1e3), 'Etc/UTC'), - fmtDate: tpl => uPlot.fmtDate(tpl, ruNames), series: [ {}, { @@ -54,4 +47,4 @@ let u = new uPlot(opts, data, document.body); - \ No newline at end of file + diff --git a/dist/uPlot.cjs.js b/dist/uPlot.cjs.js index 30520317..b3df10be 100644 --- a/dist/uPlot.cjs.js +++ b/dist/uPlot.cjs.js @@ -11,168 +11,7 @@ const FEAT_TIME = true; -const pre = "u-"; - -const UPLOT = "uplot"; -const ORI_HZ = pre + "hz"; -const ORI_VT = pre + "vt"; -const TITLE = pre + "title"; -const WRAP = pre + "wrap"; -const UNDER = pre + "under"; -const OVER = pre + "over"; -const AXIS = pre + "axis"; -const OFF = pre + "off"; -const SELECT = pre + "select"; -const CURSOR_X = pre + "cursor-x"; -const CURSOR_Y = pre + "cursor-y"; -const CURSOR_PT = pre + "cursor-pt"; -const LEGEND = pre + "legend"; -const LEGEND_LIVE = pre + "live"; -const LEGEND_INLINE = pre + "inline"; -const LEGEND_SERIES = pre + "series"; -const LEGEND_MARKER = pre + "marker"; -const LEGEND_LABEL = pre + "label"; -const LEGEND_VALUE = pre + "value"; - -const WIDTH = "width"; -const HEIGHT = "height"; -const TOP = "top"; -const BOTTOM = "bottom"; -const LEFT = "left"; -const RIGHT = "right"; -const hexBlack = "#000"; -const transparent = hexBlack + "0"; - -const mousemove = "mousemove"; -const mousedown = "mousedown"; -const mouseup = "mouseup"; -const mouseenter = "mouseenter"; -const mouseleave = "mouseleave"; -const dblclick = "dblclick"; -const resize = "resize"; -const scroll = "scroll"; - -const change = "change"; -const dppxchange = "dppxchange"; - -const LEGEND_DISP = "--"; - -const domEnv = typeof window != 'undefined'; - -const doc = domEnv ? document : null; -const win = domEnv ? window : null; -const nav = domEnv ? navigator : null; - -let pxRatio; - -//export const canHover = domEnv && !win.matchMedia('(hover: none)').matches; - -let query; - -function setPxRatio() { - let _pxRatio = devicePixelRatio; - - // during print preview, Chrome fires off these dppx queries even without changes - if (pxRatio != _pxRatio) { - pxRatio = _pxRatio; - - query && off(change, query, setPxRatio); - query = matchMedia(`(min-resolution: ${pxRatio - 0.001}dppx) and (max-resolution: ${pxRatio + 0.001}dppx)`); - on(change, query, setPxRatio); - - win.dispatchEvent(new CustomEvent(dppxchange)); - } -} - -function addClass(el, c) { - if (c != null) { - let cl = el.classList; - !cl.contains(c) && cl.add(c); - } -} - -function remClass(el, c) { - let cl = el.classList; - cl.contains(c) && cl.remove(c); -} - -function setStylePx(el, name, value) { - el.style[name] = value + "px"; -} - -function placeTag(tag, cls, targ, refEl) { - let el = doc.createElement(tag); - - if (cls != null) - addClass(el, cls); - - if (targ != null) - targ.insertBefore(el, refEl); - - return el; -} - -function placeDiv(cls, targ) { - return placeTag("div", cls, targ); -} - -const xformCache = new WeakMap(); - -function elTrans(el, xPos, yPos, xMax, yMax) { - let xform = "translate(" + xPos + "px," + yPos + "px)"; - let xformOld = xformCache.get(el); - - if (xform != xformOld) { - el.style.transform = xform; - xformCache.set(el, xform); - - if (xPos < 0 || yPos < 0 || xPos > xMax || yPos > yMax) - addClass(el, OFF); - else - remClass(el, OFF); - } -} - -const colorCache = new WeakMap(); - -function elColor(el, background, borderColor) { - let newColor = background + borderColor; - let oldColor = colorCache.get(el); - - if (newColor != oldColor) { - colorCache.set(el, newColor); - el.style.background = background; - el.style.borderColor = borderColor; - } -} - -const sizeCache = new WeakMap(); - -function elSize(el, newWid, newHgt, centered) { - let newSize = newWid + "" + newHgt; - let oldSize = sizeCache.get(el); - - if (newSize != oldSize) { - sizeCache.set(el, newSize); - el.style.height = newHgt + "px"; - el.style.width = newWid + "px"; - el.style.marginLeft = centered ? -newWid/2 + "px" : 0; - el.style.marginTop = centered ? -newHgt/2 + "px" : 0; - } -} - -const evOpts = {passive: true}; -const evOpts2 = {...evOpts, capture: true}; - -function on(ev, el, cb, capt) { - el.addEventListener(ev, cb, capt ? evOpts2 : evOpts); -} - -function off(ev, el, cb, capt) { - el.removeEventListener(ev, cb, capt ? evOpts2 : evOpts); -} - -domEnv && setPxRatio(); +const browserLocale = new Intl.DateTimeFormat().resolvedOptions().locale; // binary search for index of closest value function closestIdx(num, arr, lo, hi) { @@ -431,10 +270,6 @@ function _rangeNum(_min, _max, cfg) { return [minLim, maxLim]; } -// alternative: https://stackoverflow.com/a/2254896 -const numFormatter = new Intl.NumberFormat(domEnv ? nav.language : 'en-US'); -const fmtNum = val => numFormatter.format(val); - const M = Math; const PI = M.PI; @@ -820,130 +655,168 @@ function isAsc(vals, samples = 100) { return true; } -const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", -]; - -const days = [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", -]; - -function slice3(str) { - return str.slice(0, 3); -} +const WIDTH = "width"; +const HEIGHT = "height"; +const TOP = "top"; +const BOTTOM = "bottom"; +const LEFT = "left"; +const RIGHT = "right"; +const hexBlack = "#000"; +const transparent = hexBlack + "0"; + +const mousemove = "mousemove"; +const mousedown = "mousedown"; +const mouseup = "mouseup"; +const mouseenter = "mouseenter"; +const mouseleave = "mouseleave"; +const dblclick = "dblclick"; +const resize = "resize"; +const scroll = "scroll"; -const days3 = days.map(slice3); +const change = "change"; +const dppxchange = "dppxchange"; -const months3 = months.map(slice3); +const LEGEND_DISP = "--"; -const engNames = { - MMMM: months, - MMM: months3, - WWWW: days, - WWW: days3, -}; +const pre = "u-"; -function zeroPad2(int) { - return (int < 10 ? '0' : '') + int; +const UPLOT = "uplot"; +const ORI_HZ = pre + "hz"; +const ORI_VT = pre + "vt"; +const TITLE = pre + "title"; +const WRAP = pre + "wrap"; +const UNDER = pre + "under"; +const OVER = pre + "over"; +const AXIS = pre + "axis"; +const OFF = pre + "off"; +const SELECT = pre + "select"; +const CURSOR_X = pre + "cursor-x"; +const CURSOR_Y = pre + "cursor-y"; +const CURSOR_PT = pre + "cursor-pt"; +const LEGEND = pre + "legend"; +const LEGEND_LIVE = pre + "live"; +const LEGEND_INLINE = pre + "inline"; +const LEGEND_SERIES = pre + "series"; +const LEGEND_MARKER = pre + "marker"; +const LEGEND_LABEL = pre + "label"; +const LEGEND_VALUE = pre + "value"; + +const domEnv = typeof window != 'undefined'; + +const doc = domEnv ? document : null; +const win = domEnv ? window : null; + +let pxRatio; + +//export const canHover = domEnv && !win.matchMedia('(hover: none)').matches; + +let query; + +function setPxRatio() { + let _pxRatio = devicePixelRatio; + + // during print preview, Chrome fires off these dppx queries even without changes + if (pxRatio != _pxRatio) { + pxRatio = _pxRatio; + + query && off(change, query, setPxRatio); + query = matchMedia(`(min-resolution: ${pxRatio - 0.001}dppx) and (max-resolution: ${pxRatio + 0.001}dppx)`); + on(change, query, setPxRatio); + + win.dispatchEvent(new CustomEvent(dppxchange)); + } } -function zeroPad3(int) { - return (int < 10 ? '00' : int < 100 ? '0' : '') + int; +function addClass(el, c) { + if (c != null) { + let cl = el.classList; + !cl.contains(c) && cl.add(c); + } } -/* -function suffix(int) { - let mod10 = int % 10; +function remClass(el, c) { + let cl = el.classList; + cl.contains(c) && cl.remove(c); +} - return int + ( - mod10 == 1 && int != 11 ? "st" : - mod10 == 2 && int != 12 ? "nd" : - mod10 == 3 && int != 13 ? "rd" : "th" - ); +function setStylePx(el, name, value) { + el.style[name] = value + "px"; } -*/ -const subs = { - // 2019 - YYYY: d => d.getFullYear(), - // 19 - YY: d => (d.getFullYear()+'').slice(2), - // July - MMMM: (d, names) => names.MMMM[d.getMonth()], - // Jul - MMM: (d, names) => names.MMM[d.getMonth()], - // 07 - MM: d => zeroPad2(d.getMonth()+1), - // 7 - M: d => d.getMonth()+1, - // 09 - DD: d => zeroPad2(d.getDate()), - // 9 - D: d => d.getDate(), - // Monday - WWWW: (d, names) => names.WWWW[d.getDay()], - // Mon - WWW: (d, names) => names.WWW[d.getDay()], - // 03 - HH: d => zeroPad2(d.getHours()), - // 3 - H: d => d.getHours(), - // 9 (12hr, unpadded) - h: d => {let h = d.getHours(); return h == 0 ? 12 : h > 12 ? h - 12 : h;}, - // AM - AA: d => d.getHours() >= 12 ? 'PM' : 'AM', - // am - aa: d => d.getHours() >= 12 ? 'pm' : 'am', - // a - a: d => d.getHours() >= 12 ? 'p' : 'a', - // 09 - mm: d => zeroPad2(d.getMinutes()), - // 9 - m: d => d.getMinutes(), - // 09 - ss: d => zeroPad2(d.getSeconds()), - // 9 - s: d => d.getSeconds(), - // 374 - fff: d => zeroPad3(d.getMilliseconds()), -}; +function placeTag(tag, cls, targ, refEl) { + let el = doc.createElement(tag); + + if (cls != null) + addClass(el, cls); + + if (targ != null) + targ.insertBefore(el, refEl); + + return el; +} + +function placeDiv(cls, targ) { + return placeTag("div", cls, targ); +} + +const xformCache = new WeakMap(); + +function elTrans(el, xPos, yPos, xMax, yMax) { + let xform = "translate(" + xPos + "px," + yPos + "px)"; + let xformOld = xformCache.get(el); + + if (xform != xformOld) { + el.style.transform = xform; + xformCache.set(el, xform); + + if (xPos < 0 || yPos < 0 || xPos > xMax || yPos > yMax) + addClass(el, OFF); + else + remClass(el, OFF); + } +} -function fmtDate(tpl, names) { - names = names || engNames; - let parts = []; +const colorCache = new WeakMap(); - let R = /\{([a-z]+)\}|[^{]+/gi, m; +function elColor(el, background, borderColor) { + let newColor = background + borderColor; + let oldColor = colorCache.get(el); - while (m = R.exec(tpl)) - parts.push(m[0][0] == '{' ? subs[m[1]] : m[0]); + if (newColor != oldColor) { + colorCache.set(el, newColor); + el.style.background = background; + el.style.borderColor = borderColor; + } +} - return d => { - let out = ''; +const sizeCache = new WeakMap(); - for (let i = 0; i < parts.length; i++) - out += typeof parts[i] == "string" ? parts[i] : parts[i](d, names); +function elSize(el, newWid, newHgt, centered) { + let newSize = newWid + "" + newHgt; + let oldSize = sizeCache.get(el); - return out; + if (newSize != oldSize) { + sizeCache.set(el, newSize); + el.style.height = newHgt + "px"; + el.style.width = newWid + "px"; + el.style.marginLeft = centered ? -newWid/2 + "px" : 0; + el.style.marginTop = centered ? -newHgt/2 + "px" : 0; } } +const evOpts = {passive: true}; +const evOpts2 = {...evOpts, capture: true}; + +function on(ev, el, cb, capt) { + el.addEventListener(ev, cb, capt ? evOpts2 : evOpts); +} + +function off(ev, el, cb, capt) { + el.removeEventListener(ev, cb, evOpts); +} + +domEnv && setPxRatio(); + const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; // https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 @@ -982,19 +855,14 @@ const wholeIncrs = oneIncrs.filter(onlyWhole); const numIncrs = decIncrs.concat(oneIncrs); -const NL = "\n"; - -const yyyy = "{YYYY}"; -const NLyyyy = NL + yyyy; -const md = "{M}/{D}"; -const NLmd = NL + md; -const NLmdyy = NLmd + "/{YY}"; - -const aa = "{aa}"; -const hmm = "{h}:{mm}"; -const hmmaa = hmm + aa; -const NLhmmaa = NL + hmmaa; -const ss = ":{ss}"; +let YYYY = {year: 'numeric'}; +let MM = {month: 'numeric'}; +let MMM = {month: 'short'}; +let dd = {day: 'numeric'}; +let hh = {hour: 'numeric'}; +let mm = {minute: 'numeric'}; +let ss = {second: 'numeric'}; +let fff = { fractionalSecondDigits: 3}; const _ = null; @@ -1063,16 +931,16 @@ function genTimeStuffs(ms) { // [2-7]: rollover tick formats // [8]: mode: 0: replace [1] -> [2-7], 1: concat [1] + [2-7] const _timeAxisStamps = [ - // tick incr default year month day hour min sec mode - [y, yyyy, _, _, _, _, _, _, 1], - [d * 28, "{MMM}", NLyyyy, _, _, _, _, _, 1], - [d, md, NLyyyy, _, _, _, _, _, 1], - [h, "{h}" + aa, NLmdyy, _, NLmd, _, _, _, 1], - [m, hmmaa, NLmdyy, _, NLmd, _, _, _, 1], - [s, ss, NLmdyy + " " + hmmaa, _, NLmd + " " + hmmaa, _, NLhmmaa, _, 1], - [ms, ss + ".{fff}", NLmdyy + " " + hmmaa, _, NLmd + " " + hmmaa, _, NLhmmaa, _, 1], + // tick incr default year month day hour min sec mode + [y, { ...YYYY }, _, _, _, _, _, _, 1], + [d * 28, { ...MMM }, {...YYYY}, _, _, _, _, _, 1], + [d, { ...MM, ...dd }, {...YYYY}, _, _, _, _, _, 1], + [h, { ...hh }, { ...YYYY, ...MM, ...dd}, _, {...MM, ...dd}, _, _, _, 1], + [m, { ...hh, ...mm }, { ...YYYY, ...MM, ...dd}, _, {...MM, ...dd}, _, _, _, 1], + [s, { ...ss }, { ...YYYY, ...MM, ...dd, ...hh, ...mm}, _, {...MM, ...dd, ...hh, ...mm}, _, {...hh, ...mm}, _, 1], + [ms, { ...ss, ...fff }, { ...YYYY, ...MM, ...dd, ...hh, ...mm}, _, {...MM, ...dd, ...hh, ...mm}, _, {...hh, ...mm}, _, 1], ]; - + // the ensures that axis ticks, values & grid are aligned to logical temporal breakpoints and not an arbitrary timestamp // https://www.timeanddate.com/time/dst/ // https://www.timeanddate.com/time/dst/2019.html @@ -1460,7 +1328,7 @@ const xSeriesOpts = { idxs: [], }; -function numAxisVals(self, splits, axisIdx, foundSpace, foundIncr) { +function numAxisVals(self, splits, axisIdx, foundSpace, foundIncr, fmtNum) { return splits.map(v => v == null ? "" : fmtNum(v)); } @@ -1583,7 +1451,7 @@ function log2AxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) { return splits; } -function numSeriesVal(self, val, seriesIdx, dataIdx) { +function numSeriesVal(self, val, seriesIdx, dataIdx, fmtNum) { return dataIdx == null ? LEGEND_DISP : val == null ? "" : fmtNum(val); } @@ -2857,7 +2725,17 @@ function uPlot(opts, data, then) { }; const mode = self.mode; - + + // alternative: https://stackoverflow.com/a/2254896 + const numFormatter = new Intl.NumberFormat(opts.locale || browserLocale); + const fmtNum = val => numFormatter.format(val); + self.fmtNum = fmtNum; + + const fmtDate = (tsOpts) => new Intl.DateTimeFormat(opts.locale || browserLocale, tsOpts).format; + { + self.fmtDate = fmtDate; + } + // TODO: cache denoms & mins scale.cache = {r, min, } function getValPct(val, scale) { let _val = ( @@ -4432,7 +4310,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, fmtNum); // rotating of labels only supported on bottom x axis axis._rotate = side == 2 ? axis.rotate(self, values, i, _space) : 0; @@ -5207,7 +5085,7 @@ function uPlot(opts, data, then) { if (multiValLegend) val = s.values(self, sidx, idx) ?? NULL_LEGEND_VALUES; else { - val = s.value(self, idx == null ? null : src[idx], sidx, idx); + val = s.value(self, idx == null ? null : src[idx], sidx, idx, fmtNum); val = val == null ? NULL_LEGEND_VALUES : {_: val}; } @@ -6019,7 +5897,6 @@ function uPlot(opts, data, then) { } uPlot.assign = assign; -uPlot.fmtNum = fmtNum; uPlot.rangeNum = rangeNum; uPlot.rangeLog = rangeLog; uPlot.rangeAsinh = rangeAsinh; @@ -6031,7 +5908,6 @@ uPlot.pxRatio = pxRatio; } { - uPlot.fmtDate = fmtDate; uPlot.tzDate = tzDate; } diff --git a/dist/uPlot.d.ts b/dist/uPlot.d.ts index 75e73e8d..86207b55 100644 --- a/dist/uPlot.d.ts +++ b/dist/uPlot.d.ts @@ -60,6 +60,9 @@ declare class uPlot { /** .u-under dom element */ readonly under: HTMLDivElement; + + /* + readonly locale: string; /** clears and redraws the canvas. if rebuildPaths = false, uses cached series' Path2D objects */ redraw(rebuildPaths?: boolean, recalcAxes?: boolean): void; @@ -138,11 +141,11 @@ declare class uPlot { /** re-ranges a given min/max outwards to nearest 10% of given min/max's magnitudes, unless fullMags = true */ static rangeAsinh(min: number, max: number, base: uPlot.Scale.LogBase, fullMags: boolean): uPlot.Range.MinMax; - /** default numeric formatter using browser's locale: new Intl.NumberFormat(navigator.language).format */ + /** default numeric formatter using browser's locale: new Intl.NumberFormat(defaultLocale).format */ static fmtNum(val: number): string; - /** creates an efficient formatter for Date objects from a template string, e.g. {YYYY}-{MM}-{DD} */ - static fmtDate(tpl: string, names?: uPlot.DateNames): (date: Date) => string; + /** default DateTime formatter using browser's locale: new Intl.DateTimeFormat(defaultLocale, opts).format */ + static fmtDate(opts: string, locale?: string): (date: Date) => string; /** converts a Date into new Date that's time-adjusted for the given IANA Time Zone Name */ static tzDate(date: Date, tzName: string): Date; @@ -222,19 +225,6 @@ declare namespace uPlot { ...yValues: ((number | null | undefined)[] | TypedArray)[], ] - export interface DateNames { - /** long month names */ - MMMM: string[]; - - /** short month names */ - MMM: string[]; - - /** long weekday names (0: Sunday) */ - WWWW: string[]; - - /** short weekday names (0: Sun) */ - WWW: string[]; - } export namespace Range { export type MinMax = [min: number | null, max: number | null]; diff --git a/dist/uPlot.esm.js b/dist/uPlot.esm.js index b574dd5b..caed48a8 100644 --- a/dist/uPlot.esm.js +++ b/dist/uPlot.esm.js @@ -9,168 +9,7 @@ const FEAT_TIME = true; -const pre = "u-"; - -const UPLOT = "uplot"; -const ORI_HZ = pre + "hz"; -const ORI_VT = pre + "vt"; -const TITLE = pre + "title"; -const WRAP = pre + "wrap"; -const UNDER = pre + "under"; -const OVER = pre + "over"; -const AXIS = pre + "axis"; -const OFF = pre + "off"; -const SELECT = pre + "select"; -const CURSOR_X = pre + "cursor-x"; -const CURSOR_Y = pre + "cursor-y"; -const CURSOR_PT = pre + "cursor-pt"; -const LEGEND = pre + "legend"; -const LEGEND_LIVE = pre + "live"; -const LEGEND_INLINE = pre + "inline"; -const LEGEND_SERIES = pre + "series"; -const LEGEND_MARKER = pre + "marker"; -const LEGEND_LABEL = pre + "label"; -const LEGEND_VALUE = pre + "value"; - -const WIDTH = "width"; -const HEIGHT = "height"; -const TOP = "top"; -const BOTTOM = "bottom"; -const LEFT = "left"; -const RIGHT = "right"; -const hexBlack = "#000"; -const transparent = hexBlack + "0"; - -const mousemove = "mousemove"; -const mousedown = "mousedown"; -const mouseup = "mouseup"; -const mouseenter = "mouseenter"; -const mouseleave = "mouseleave"; -const dblclick = "dblclick"; -const resize = "resize"; -const scroll = "scroll"; - -const change = "change"; -const dppxchange = "dppxchange"; - -const LEGEND_DISP = "--"; - -const domEnv = typeof window != 'undefined'; - -const doc = domEnv ? document : null; -const win = domEnv ? window : null; -const nav = domEnv ? navigator : null; - -let pxRatio; - -//export const canHover = domEnv && !win.matchMedia('(hover: none)').matches; - -let query; - -function setPxRatio() { - let _pxRatio = devicePixelRatio; - - // during print preview, Chrome fires off these dppx queries even without changes - if (pxRatio != _pxRatio) { - pxRatio = _pxRatio; - - query && off(change, query, setPxRatio); - query = matchMedia(`(min-resolution: ${pxRatio - 0.001}dppx) and (max-resolution: ${pxRatio + 0.001}dppx)`); - on(change, query, setPxRatio); - - win.dispatchEvent(new CustomEvent(dppxchange)); - } -} - -function addClass(el, c) { - if (c != null) { - let cl = el.classList; - !cl.contains(c) && cl.add(c); - } -} - -function remClass(el, c) { - let cl = el.classList; - cl.contains(c) && cl.remove(c); -} - -function setStylePx(el, name, value) { - el.style[name] = value + "px"; -} - -function placeTag(tag, cls, targ, refEl) { - let el = doc.createElement(tag); - - if (cls != null) - addClass(el, cls); - - if (targ != null) - targ.insertBefore(el, refEl); - - return el; -} - -function placeDiv(cls, targ) { - return placeTag("div", cls, targ); -} - -const xformCache = new WeakMap(); - -function elTrans(el, xPos, yPos, xMax, yMax) { - let xform = "translate(" + xPos + "px," + yPos + "px)"; - let xformOld = xformCache.get(el); - - if (xform != xformOld) { - el.style.transform = xform; - xformCache.set(el, xform); - - if (xPos < 0 || yPos < 0 || xPos > xMax || yPos > yMax) - addClass(el, OFF); - else - remClass(el, OFF); - } -} - -const colorCache = new WeakMap(); - -function elColor(el, background, borderColor) { - let newColor = background + borderColor; - let oldColor = colorCache.get(el); - - if (newColor != oldColor) { - colorCache.set(el, newColor); - el.style.background = background; - el.style.borderColor = borderColor; - } -} - -const sizeCache = new WeakMap(); - -function elSize(el, newWid, newHgt, centered) { - let newSize = newWid + "" + newHgt; - let oldSize = sizeCache.get(el); - - if (newSize != oldSize) { - sizeCache.set(el, newSize); - el.style.height = newHgt + "px"; - el.style.width = newWid + "px"; - el.style.marginLeft = centered ? -newWid/2 + "px" : 0; - el.style.marginTop = centered ? -newHgt/2 + "px" : 0; - } -} - -const evOpts = {passive: true}; -const evOpts2 = {...evOpts, capture: true}; - -function on(ev, el, cb, capt) { - el.addEventListener(ev, cb, capt ? evOpts2 : evOpts); -} - -function off(ev, el, cb, capt) { - el.removeEventListener(ev, cb, capt ? evOpts2 : evOpts); -} - -domEnv && setPxRatio(); +const browserLocale = new Intl.DateTimeFormat().resolvedOptions().locale; // binary search for index of closest value function closestIdx(num, arr, lo, hi) { @@ -429,10 +268,6 @@ function _rangeNum(_min, _max, cfg) { return [minLim, maxLim]; } -// alternative: https://stackoverflow.com/a/2254896 -const numFormatter = new Intl.NumberFormat(domEnv ? nav.language : 'en-US'); -const fmtNum = val => numFormatter.format(val); - const M = Math; const PI = M.PI; @@ -818,130 +653,168 @@ function isAsc(vals, samples = 100) { return true; } -const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", -]; - -const days = [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", -]; - -function slice3(str) { - return str.slice(0, 3); -} +const WIDTH = "width"; +const HEIGHT = "height"; +const TOP = "top"; +const BOTTOM = "bottom"; +const LEFT = "left"; +const RIGHT = "right"; +const hexBlack = "#000"; +const transparent = hexBlack + "0"; + +const mousemove = "mousemove"; +const mousedown = "mousedown"; +const mouseup = "mouseup"; +const mouseenter = "mouseenter"; +const mouseleave = "mouseleave"; +const dblclick = "dblclick"; +const resize = "resize"; +const scroll = "scroll"; -const days3 = days.map(slice3); +const change = "change"; +const dppxchange = "dppxchange"; -const months3 = months.map(slice3); +const LEGEND_DISP = "--"; -const engNames = { - MMMM: months, - MMM: months3, - WWWW: days, - WWW: days3, -}; +const pre = "u-"; -function zeroPad2(int) { - return (int < 10 ? '0' : '') + int; +const UPLOT = "uplot"; +const ORI_HZ = pre + "hz"; +const ORI_VT = pre + "vt"; +const TITLE = pre + "title"; +const WRAP = pre + "wrap"; +const UNDER = pre + "under"; +const OVER = pre + "over"; +const AXIS = pre + "axis"; +const OFF = pre + "off"; +const SELECT = pre + "select"; +const CURSOR_X = pre + "cursor-x"; +const CURSOR_Y = pre + "cursor-y"; +const CURSOR_PT = pre + "cursor-pt"; +const LEGEND = pre + "legend"; +const LEGEND_LIVE = pre + "live"; +const LEGEND_INLINE = pre + "inline"; +const LEGEND_SERIES = pre + "series"; +const LEGEND_MARKER = pre + "marker"; +const LEGEND_LABEL = pre + "label"; +const LEGEND_VALUE = pre + "value"; + +const domEnv = typeof window != 'undefined'; + +const doc = domEnv ? document : null; +const win = domEnv ? window : null; + +let pxRatio; + +//export const canHover = domEnv && !win.matchMedia('(hover: none)').matches; + +let query; + +function setPxRatio() { + let _pxRatio = devicePixelRatio; + + // during print preview, Chrome fires off these dppx queries even without changes + if (pxRatio != _pxRatio) { + pxRatio = _pxRatio; + + query && off(change, query, setPxRatio); + query = matchMedia(`(min-resolution: ${pxRatio - 0.001}dppx) and (max-resolution: ${pxRatio + 0.001}dppx)`); + on(change, query, setPxRatio); + + win.dispatchEvent(new CustomEvent(dppxchange)); + } } -function zeroPad3(int) { - return (int < 10 ? '00' : int < 100 ? '0' : '') + int; +function addClass(el, c) { + if (c != null) { + let cl = el.classList; + !cl.contains(c) && cl.add(c); + } } -/* -function suffix(int) { - let mod10 = int % 10; +function remClass(el, c) { + let cl = el.classList; + cl.contains(c) && cl.remove(c); +} - return int + ( - mod10 == 1 && int != 11 ? "st" : - mod10 == 2 && int != 12 ? "nd" : - mod10 == 3 && int != 13 ? "rd" : "th" - ); +function setStylePx(el, name, value) { + el.style[name] = value + "px"; } -*/ -const subs = { - // 2019 - YYYY: d => d.getFullYear(), - // 19 - YY: d => (d.getFullYear()+'').slice(2), - // July - MMMM: (d, names) => names.MMMM[d.getMonth()], - // Jul - MMM: (d, names) => names.MMM[d.getMonth()], - // 07 - MM: d => zeroPad2(d.getMonth()+1), - // 7 - M: d => d.getMonth()+1, - // 09 - DD: d => zeroPad2(d.getDate()), - // 9 - D: d => d.getDate(), - // Monday - WWWW: (d, names) => names.WWWW[d.getDay()], - // Mon - WWW: (d, names) => names.WWW[d.getDay()], - // 03 - HH: d => zeroPad2(d.getHours()), - // 3 - H: d => d.getHours(), - // 9 (12hr, unpadded) - h: d => {let h = d.getHours(); return h == 0 ? 12 : h > 12 ? h - 12 : h;}, - // AM - AA: d => d.getHours() >= 12 ? 'PM' : 'AM', - // am - aa: d => d.getHours() >= 12 ? 'pm' : 'am', - // a - a: d => d.getHours() >= 12 ? 'p' : 'a', - // 09 - mm: d => zeroPad2(d.getMinutes()), - // 9 - m: d => d.getMinutes(), - // 09 - ss: d => zeroPad2(d.getSeconds()), - // 9 - s: d => d.getSeconds(), - // 374 - fff: d => zeroPad3(d.getMilliseconds()), -}; +function placeTag(tag, cls, targ, refEl) { + let el = doc.createElement(tag); + + if (cls != null) + addClass(el, cls); + + if (targ != null) + targ.insertBefore(el, refEl); + + return el; +} + +function placeDiv(cls, targ) { + return placeTag("div", cls, targ); +} + +const xformCache = new WeakMap(); + +function elTrans(el, xPos, yPos, xMax, yMax) { + let xform = "translate(" + xPos + "px," + yPos + "px)"; + let xformOld = xformCache.get(el); + + if (xform != xformOld) { + el.style.transform = xform; + xformCache.set(el, xform); + + if (xPos < 0 || yPos < 0 || xPos > xMax || yPos > yMax) + addClass(el, OFF); + else + remClass(el, OFF); + } +} -function fmtDate(tpl, names) { - names = names || engNames; - let parts = []; +const colorCache = new WeakMap(); - let R = /\{([a-z]+)\}|[^{]+/gi, m; +function elColor(el, background, borderColor) { + let newColor = background + borderColor; + let oldColor = colorCache.get(el); - while (m = R.exec(tpl)) - parts.push(m[0][0] == '{' ? subs[m[1]] : m[0]); + if (newColor != oldColor) { + colorCache.set(el, newColor); + el.style.background = background; + el.style.borderColor = borderColor; + } +} - return d => { - let out = ''; +const sizeCache = new WeakMap(); - for (let i = 0; i < parts.length; i++) - out += typeof parts[i] == "string" ? parts[i] : parts[i](d, names); +function elSize(el, newWid, newHgt, centered) { + let newSize = newWid + "" + newHgt; + let oldSize = sizeCache.get(el); - return out; + if (newSize != oldSize) { + sizeCache.set(el, newSize); + el.style.height = newHgt + "px"; + el.style.width = newWid + "px"; + el.style.marginLeft = centered ? -newWid/2 + "px" : 0; + el.style.marginTop = centered ? -newHgt/2 + "px" : 0; } } +const evOpts = {passive: true}; +const evOpts2 = {...evOpts, capture: true}; + +function on(ev, el, cb, capt) { + el.addEventListener(ev, cb, capt ? evOpts2 : evOpts); +} + +function off(ev, el, cb, capt) { + el.removeEventListener(ev, cb, evOpts); +} + +domEnv && setPxRatio(); + const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; // https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 @@ -980,19 +853,14 @@ const wholeIncrs = oneIncrs.filter(onlyWhole); const numIncrs = decIncrs.concat(oneIncrs); -const NL = "\n"; - -const yyyy = "{YYYY}"; -const NLyyyy = NL + yyyy; -const md = "{M}/{D}"; -const NLmd = NL + md; -const NLmdyy = NLmd + "/{YY}"; - -const aa = "{aa}"; -const hmm = "{h}:{mm}"; -const hmmaa = hmm + aa; -const NLhmmaa = NL + hmmaa; -const ss = ":{ss}"; +let YYYY = {year: 'numeric'}; +let MM = {month: 'numeric'}; +let MMM = {month: 'short'}; +let dd = {day: 'numeric'}; +let hh = {hour: 'numeric'}; +let mm = {minute: 'numeric'}; +let ss = {second: 'numeric'}; +let fff = { fractionalSecondDigits: 3}; const _ = null; @@ -1061,16 +929,16 @@ function genTimeStuffs(ms) { // [2-7]: rollover tick formats // [8]: mode: 0: replace [1] -> [2-7], 1: concat [1] + [2-7] const _timeAxisStamps = [ - // tick incr default year month day hour min sec mode - [y, yyyy, _, _, _, _, _, _, 1], - [d * 28, "{MMM}", NLyyyy, _, _, _, _, _, 1], - [d, md, NLyyyy, _, _, _, _, _, 1], - [h, "{h}" + aa, NLmdyy, _, NLmd, _, _, _, 1], - [m, hmmaa, NLmdyy, _, NLmd, _, _, _, 1], - [s, ss, NLmdyy + " " + hmmaa, _, NLmd + " " + hmmaa, _, NLhmmaa, _, 1], - [ms, ss + ".{fff}", NLmdyy + " " + hmmaa, _, NLmd + " " + hmmaa, _, NLhmmaa, _, 1], + // tick incr default year month day hour min sec mode + [y, { ...YYYY }, _, _, _, _, _, _, 1], + [d * 28, { ...MMM }, {...YYYY}, _, _, _, _, _, 1], + [d, { ...MM, ...dd }, {...YYYY}, _, _, _, _, _, 1], + [h, { ...hh }, { ...YYYY, ...MM, ...dd}, _, {...MM, ...dd}, _, _, _, 1], + [m, { ...hh, ...mm }, { ...YYYY, ...MM, ...dd}, _, {...MM, ...dd}, _, _, _, 1], + [s, { ...ss }, { ...YYYY, ...MM, ...dd, ...hh, ...mm}, _, {...MM, ...dd, ...hh, ...mm}, _, {...hh, ...mm}, _, 1], + [ms, { ...ss, ...fff }, { ...YYYY, ...MM, ...dd, ...hh, ...mm}, _, {...MM, ...dd, ...hh, ...mm}, _, {...hh, ...mm}, _, 1], ]; - + // the ensures that axis ticks, values & grid are aligned to logical temporal breakpoints and not an arbitrary timestamp // https://www.timeanddate.com/time/dst/ // https://www.timeanddate.com/time/dst/2019.html @@ -1458,7 +1326,7 @@ const xSeriesOpts = { idxs: [], }; -function numAxisVals(self, splits, axisIdx, foundSpace, foundIncr) { +function numAxisVals(self, splits, axisIdx, foundSpace, foundIncr, fmtNum) { return splits.map(v => v == null ? "" : fmtNum(v)); } @@ -1581,7 +1449,7 @@ function log2AxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) { return splits; } -function numSeriesVal(self, val, seriesIdx, dataIdx) { +function numSeriesVal(self, val, seriesIdx, dataIdx, fmtNum) { return dataIdx == null ? LEGEND_DISP : val == null ? "" : fmtNum(val); } @@ -2855,7 +2723,17 @@ function uPlot(opts, data, then) { }; const mode = self.mode; - + + // alternative: https://stackoverflow.com/a/2254896 + const numFormatter = new Intl.NumberFormat(opts.locale || browserLocale); + const fmtNum = val => numFormatter.format(val); + self.fmtNum = fmtNum; + + const fmtDate = (tsOpts) => new Intl.DateTimeFormat(opts.locale || browserLocale, tsOpts).format; + { + self.fmtDate = fmtDate; + } + // TODO: cache denoms & mins scale.cache = {r, min, } function getValPct(val, scale) { let _val = ( @@ -4430,7 +4308,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, fmtNum); // rotating of labels only supported on bottom x axis axis._rotate = side == 2 ? axis.rotate(self, values, i, _space) : 0; @@ -5205,7 +5083,7 @@ function uPlot(opts, data, then) { if (multiValLegend) val = s.values(self, sidx, idx) ?? NULL_LEGEND_VALUES; else { - val = s.value(self, idx == null ? null : src[idx], sidx, idx); + val = s.value(self, idx == null ? null : src[idx], sidx, idx, fmtNum); val = val == null ? NULL_LEGEND_VALUES : {_: val}; } @@ -6017,7 +5895,6 @@ function uPlot(opts, data, then) { } uPlot.assign = assign; -uPlot.fmtNum = fmtNum; uPlot.rangeNum = rangeNum; uPlot.rangeLog = rangeLog; uPlot.rangeAsinh = rangeAsinh; @@ -6029,7 +5906,6 @@ uPlot.pxRatio = pxRatio; } { - uPlot.fmtDate = fmtDate; uPlot.tzDate = tzDate; } diff --git a/dist/uPlot.iife.js b/dist/uPlot.iife.js index e204d8ad..7e37f0da 100644 --- a/dist/uPlot.iife.js +++ b/dist/uPlot.iife.js @@ -12,168 +12,7 @@ var uPlot = (function () { const FEAT_TIME = true; - const pre = "u-"; - - const UPLOT = "uplot"; - const ORI_HZ = pre + "hz"; - const ORI_VT = pre + "vt"; - const TITLE = pre + "title"; - const WRAP = pre + "wrap"; - const UNDER = pre + "under"; - const OVER = pre + "over"; - const AXIS = pre + "axis"; - const OFF = pre + "off"; - const SELECT = pre + "select"; - const CURSOR_X = pre + "cursor-x"; - const CURSOR_Y = pre + "cursor-y"; - const CURSOR_PT = pre + "cursor-pt"; - const LEGEND = pre + "legend"; - const LEGEND_LIVE = pre + "live"; - const LEGEND_INLINE = pre + "inline"; - const LEGEND_SERIES = pre + "series"; - const LEGEND_MARKER = pre + "marker"; - const LEGEND_LABEL = pre + "label"; - const LEGEND_VALUE = pre + "value"; - - const WIDTH = "width"; - const HEIGHT = "height"; - const TOP = "top"; - const BOTTOM = "bottom"; - const LEFT = "left"; - const RIGHT = "right"; - const hexBlack = "#000"; - const transparent = hexBlack + "0"; - - const mousemove = "mousemove"; - const mousedown = "mousedown"; - const mouseup = "mouseup"; - const mouseenter = "mouseenter"; - const mouseleave = "mouseleave"; - const dblclick = "dblclick"; - const resize = "resize"; - const scroll = "scroll"; - - const change = "change"; - const dppxchange = "dppxchange"; - - const LEGEND_DISP = "--"; - - const domEnv = typeof window != 'undefined'; - - const doc = domEnv ? document : null; - const win = domEnv ? window : null; - const nav = domEnv ? navigator : null; - - let pxRatio; - - //export const canHover = domEnv && !win.matchMedia('(hover: none)').matches; - - let query; - - function setPxRatio() { - let _pxRatio = devicePixelRatio; - - // during print preview, Chrome fires off these dppx queries even without changes - if (pxRatio != _pxRatio) { - pxRatio = _pxRatio; - - query && off(change, query, setPxRatio); - query = matchMedia(`(min-resolution: ${pxRatio - 0.001}dppx) and (max-resolution: ${pxRatio + 0.001}dppx)`); - on(change, query, setPxRatio); - - win.dispatchEvent(new CustomEvent(dppxchange)); - } - } - - function addClass(el, c) { - if (c != null) { - let cl = el.classList; - !cl.contains(c) && cl.add(c); - } - } - - function remClass(el, c) { - let cl = el.classList; - cl.contains(c) && cl.remove(c); - } - - function setStylePx(el, name, value) { - el.style[name] = value + "px"; - } - - function placeTag(tag, cls, targ, refEl) { - let el = doc.createElement(tag); - - if (cls != null) - addClass(el, cls); - - if (targ != null) - targ.insertBefore(el, refEl); - - return el; - } - - function placeDiv(cls, targ) { - return placeTag("div", cls, targ); - } - - const xformCache = new WeakMap(); - - function elTrans(el, xPos, yPos, xMax, yMax) { - let xform = "translate(" + xPos + "px," + yPos + "px)"; - let xformOld = xformCache.get(el); - - if (xform != xformOld) { - el.style.transform = xform; - xformCache.set(el, xform); - - if (xPos < 0 || yPos < 0 || xPos > xMax || yPos > yMax) - addClass(el, OFF); - else - remClass(el, OFF); - } - } - - const colorCache = new WeakMap(); - - function elColor(el, background, borderColor) { - let newColor = background + borderColor; - let oldColor = colorCache.get(el); - - if (newColor != oldColor) { - colorCache.set(el, newColor); - el.style.background = background; - el.style.borderColor = borderColor; - } - } - - const sizeCache = new WeakMap(); - - function elSize(el, newWid, newHgt, centered) { - let newSize = newWid + "" + newHgt; - let oldSize = sizeCache.get(el); - - if (newSize != oldSize) { - sizeCache.set(el, newSize); - el.style.height = newHgt + "px"; - el.style.width = newWid + "px"; - el.style.marginLeft = centered ? -newWid/2 + "px" : 0; - el.style.marginTop = centered ? -newHgt/2 + "px" : 0; - } - } - - const evOpts = {passive: true}; - const evOpts2 = {...evOpts, capture: true}; - - function on(ev, el, cb, capt) { - el.addEventListener(ev, cb, capt ? evOpts2 : evOpts); - } - - function off(ev, el, cb, capt) { - el.removeEventListener(ev, cb, capt ? evOpts2 : evOpts); - } - - domEnv && setPxRatio(); + const browserLocale = new Intl.DateTimeFormat().resolvedOptions().locale; // binary search for index of closest value function closestIdx(num, arr, lo, hi) { @@ -432,10 +271,6 @@ var uPlot = (function () { return [minLim, maxLim]; } - // alternative: https://stackoverflow.com/a/2254896 - const numFormatter = new Intl.NumberFormat(domEnv ? nav.language : 'en-US'); - const fmtNum = val => numFormatter.format(val); - const M = Math; const PI = M.PI; @@ -821,130 +656,168 @@ var uPlot = (function () { return true; } - const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", - ]; - - const days = [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", - ]; - - function slice3(str) { - return str.slice(0, 3); - } + const WIDTH = "width"; + const HEIGHT = "height"; + const TOP = "top"; + const BOTTOM = "bottom"; + const LEFT = "left"; + const RIGHT = "right"; + const hexBlack = "#000"; + const transparent = hexBlack + "0"; + + const mousemove = "mousemove"; + const mousedown = "mousedown"; + const mouseup = "mouseup"; + const mouseenter = "mouseenter"; + const mouseleave = "mouseleave"; + const dblclick = "dblclick"; + const resize = "resize"; + const scroll = "scroll"; - const days3 = days.map(slice3); + const change = "change"; + const dppxchange = "dppxchange"; - const months3 = months.map(slice3); + const LEGEND_DISP = "--"; - const engNames = { - MMMM: months, - MMM: months3, - WWWW: days, - WWW: days3, - }; + const pre = "u-"; - function zeroPad2(int) { - return (int < 10 ? '0' : '') + int; + const UPLOT = "uplot"; + const ORI_HZ = pre + "hz"; + const ORI_VT = pre + "vt"; + const TITLE = pre + "title"; + const WRAP = pre + "wrap"; + const UNDER = pre + "under"; + const OVER = pre + "over"; + const AXIS = pre + "axis"; + const OFF = pre + "off"; + const SELECT = pre + "select"; + const CURSOR_X = pre + "cursor-x"; + const CURSOR_Y = pre + "cursor-y"; + const CURSOR_PT = pre + "cursor-pt"; + const LEGEND = pre + "legend"; + const LEGEND_LIVE = pre + "live"; + const LEGEND_INLINE = pre + "inline"; + const LEGEND_SERIES = pre + "series"; + const LEGEND_MARKER = pre + "marker"; + const LEGEND_LABEL = pre + "label"; + const LEGEND_VALUE = pre + "value"; + + const domEnv = typeof window != 'undefined'; + + const doc = domEnv ? document : null; + const win = domEnv ? window : null; + + let pxRatio; + + //export const canHover = domEnv && !win.matchMedia('(hover: none)').matches; + + let query; + + function setPxRatio() { + let _pxRatio = devicePixelRatio; + + // during print preview, Chrome fires off these dppx queries even without changes + if (pxRatio != _pxRatio) { + pxRatio = _pxRatio; + + query && off(change, query, setPxRatio); + query = matchMedia(`(min-resolution: ${pxRatio - 0.001}dppx) and (max-resolution: ${pxRatio + 0.001}dppx)`); + on(change, query, setPxRatio); + + win.dispatchEvent(new CustomEvent(dppxchange)); + } } - function zeroPad3(int) { - return (int < 10 ? '00' : int < 100 ? '0' : '') + int; + function addClass(el, c) { + if (c != null) { + let cl = el.classList; + !cl.contains(c) && cl.add(c); + } } - /* - function suffix(int) { - let mod10 = int % 10; + function remClass(el, c) { + let cl = el.classList; + cl.contains(c) && cl.remove(c); + } - return int + ( - mod10 == 1 && int != 11 ? "st" : - mod10 == 2 && int != 12 ? "nd" : - mod10 == 3 && int != 13 ? "rd" : "th" - ); + function setStylePx(el, name, value) { + el.style[name] = value + "px"; } - */ - const subs = { - // 2019 - YYYY: d => d.getFullYear(), - // 19 - YY: d => (d.getFullYear()+'').slice(2), - // July - MMMM: (d, names) => names.MMMM[d.getMonth()], - // Jul - MMM: (d, names) => names.MMM[d.getMonth()], - // 07 - MM: d => zeroPad2(d.getMonth()+1), - // 7 - M: d => d.getMonth()+1, - // 09 - DD: d => zeroPad2(d.getDate()), - // 9 - D: d => d.getDate(), - // Monday - WWWW: (d, names) => names.WWWW[d.getDay()], - // Mon - WWW: (d, names) => names.WWW[d.getDay()], - // 03 - HH: d => zeroPad2(d.getHours()), - // 3 - H: d => d.getHours(), - // 9 (12hr, unpadded) - h: d => {let h = d.getHours(); return h == 0 ? 12 : h > 12 ? h - 12 : h;}, - // AM - AA: d => d.getHours() >= 12 ? 'PM' : 'AM', - // am - aa: d => d.getHours() >= 12 ? 'pm' : 'am', - // a - a: d => d.getHours() >= 12 ? 'p' : 'a', - // 09 - mm: d => zeroPad2(d.getMinutes()), - // 9 - m: d => d.getMinutes(), - // 09 - ss: d => zeroPad2(d.getSeconds()), - // 9 - s: d => d.getSeconds(), - // 374 - fff: d => zeroPad3(d.getMilliseconds()), - }; + function placeTag(tag, cls, targ, refEl) { + let el = doc.createElement(tag); + + if (cls != null) + addClass(el, cls); + + if (targ != null) + targ.insertBefore(el, refEl); + + return el; + } + + function placeDiv(cls, targ) { + return placeTag("div", cls, targ); + } + + const xformCache = new WeakMap(); + + function elTrans(el, xPos, yPos, xMax, yMax) { + let xform = "translate(" + xPos + "px," + yPos + "px)"; + let xformOld = xformCache.get(el); + + if (xform != xformOld) { + el.style.transform = xform; + xformCache.set(el, xform); + + if (xPos < 0 || yPos < 0 || xPos > xMax || yPos > yMax) + addClass(el, OFF); + else + remClass(el, OFF); + } + } - function fmtDate(tpl, names) { - names = names || engNames; - let parts = []; + const colorCache = new WeakMap(); - let R = /\{([a-z]+)\}|[^{]+/gi, m; + function elColor(el, background, borderColor) { + let newColor = background + borderColor; + let oldColor = colorCache.get(el); - while (m = R.exec(tpl)) - parts.push(m[0][0] == '{' ? subs[m[1]] : m[0]); + if (newColor != oldColor) { + colorCache.set(el, newColor); + el.style.background = background; + el.style.borderColor = borderColor; + } + } - return d => { - let out = ''; + const sizeCache = new WeakMap(); - for (let i = 0; i < parts.length; i++) - out += typeof parts[i] == "string" ? parts[i] : parts[i](d, names); + function elSize(el, newWid, newHgt, centered) { + let newSize = newWid + "" + newHgt; + let oldSize = sizeCache.get(el); - return out; + if (newSize != oldSize) { + sizeCache.set(el, newSize); + el.style.height = newHgt + "px"; + el.style.width = newWid + "px"; + el.style.marginLeft = centered ? -newWid/2 + "px" : 0; + el.style.marginTop = centered ? -newHgt/2 + "px" : 0; } } + const evOpts = {passive: true}; + const evOpts2 = {...evOpts, capture: true}; + + function on(ev, el, cb, capt) { + el.addEventListener(ev, cb, capt ? evOpts2 : evOpts); + } + + function off(ev, el, cb, capt) { + el.removeEventListener(ev, cb, evOpts); + } + + domEnv && setPxRatio(); + const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; // https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 @@ -983,19 +856,14 @@ var uPlot = (function () { const numIncrs = decIncrs.concat(oneIncrs); - const NL = "\n"; - - const yyyy = "{YYYY}"; - const NLyyyy = NL + yyyy; - const md = "{M}/{D}"; - const NLmd = NL + md; - const NLmdyy = NLmd + "/{YY}"; - - const aa = "{aa}"; - const hmm = "{h}:{mm}"; - const hmmaa = hmm + aa; - const NLhmmaa = NL + hmmaa; - const ss = ":{ss}"; + let YYYY = {year: 'numeric'}; + let MM = {month: 'numeric'}; + let MMM = {month: 'short'}; + let dd = {day: 'numeric'}; + let hh = {hour: 'numeric'}; + let mm = {minute: 'numeric'}; + let ss = {second: 'numeric'}; + let fff = { fractionalSecondDigits: 3}; const _ = null; @@ -1064,16 +932,16 @@ var uPlot = (function () { // [2-7]: rollover tick formats // [8]: mode: 0: replace [1] -> [2-7], 1: concat [1] + [2-7] const _timeAxisStamps = [ - // tick incr default year month day hour min sec mode - [y, yyyy, _, _, _, _, _, _, 1], - [d * 28, "{MMM}", NLyyyy, _, _, _, _, _, 1], - [d, md, NLyyyy, _, _, _, _, _, 1], - [h, "{h}" + aa, NLmdyy, _, NLmd, _, _, _, 1], - [m, hmmaa, NLmdyy, _, NLmd, _, _, _, 1], - [s, ss, NLmdyy + " " + hmmaa, _, NLmd + " " + hmmaa, _, NLhmmaa, _, 1], - [ms, ss + ".{fff}", NLmdyy + " " + hmmaa, _, NLmd + " " + hmmaa, _, NLhmmaa, _, 1], + // tick incr default year month day hour min sec mode + [y, { ...YYYY }, _, _, _, _, _, _, 1], + [d * 28, { ...MMM }, {...YYYY}, _, _, _, _, _, 1], + [d, { ...MM, ...dd }, {...YYYY}, _, _, _, _, _, 1], + [h, { ...hh }, { ...YYYY, ...MM, ...dd}, _, {...MM, ...dd}, _, _, _, 1], + [m, { ...hh, ...mm }, { ...YYYY, ...MM, ...dd}, _, {...MM, ...dd}, _, _, _, 1], + [s, { ...ss }, { ...YYYY, ...MM, ...dd, ...hh, ...mm}, _, {...MM, ...dd, ...hh, ...mm}, _, {...hh, ...mm}, _, 1], + [ms, { ...ss, ...fff }, { ...YYYY, ...MM, ...dd, ...hh, ...mm}, _, {...MM, ...dd, ...hh, ...mm}, _, {...hh, ...mm}, _, 1], ]; - + // the ensures that axis ticks, values & grid are aligned to logical temporal breakpoints and not an arbitrary timestamp // https://www.timeanddate.com/time/dst/ // https://www.timeanddate.com/time/dst/2019.html @@ -1461,7 +1329,7 @@ var uPlot = (function () { idxs: [], }; - function numAxisVals(self, splits, axisIdx, foundSpace, foundIncr) { + function numAxisVals(self, splits, axisIdx, foundSpace, foundIncr, fmtNum) { return splits.map(v => v == null ? "" : fmtNum(v)); } @@ -1584,7 +1452,7 @@ var uPlot = (function () { return splits; } - function numSeriesVal(self, val, seriesIdx, dataIdx) { + function numSeriesVal(self, val, seriesIdx, dataIdx, fmtNum) { return dataIdx == null ? LEGEND_DISP : val == null ? "" : fmtNum(val); } @@ -2858,7 +2726,17 @@ var uPlot = (function () { }; const mode = self.mode; - + + // alternative: https://stackoverflow.com/a/2254896 + const numFormatter = new Intl.NumberFormat(opts.locale || browserLocale); + const fmtNum = val => numFormatter.format(val); + self.fmtNum = fmtNum; + + const fmtDate = (tsOpts) => new Intl.DateTimeFormat(opts.locale || browserLocale, tsOpts).format; + { + self.fmtDate = fmtDate; + } + // TODO: cache denoms & mins scale.cache = {r, min, } function getValPct(val, scale) { let _val = ( @@ -4433,7 +4311,7 @@ var uPlot = (function () { 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, fmtNum); // rotating of labels only supported on bottom x axis axis._rotate = side == 2 ? axis.rotate(self, values, i, _space) : 0; @@ -5208,7 +5086,7 @@ var uPlot = (function () { if (multiValLegend) val = s.values(self, sidx, idx) ?? NULL_LEGEND_VALUES; else { - val = s.value(self, idx == null ? null : src[idx], sidx, idx); + val = s.value(self, idx == null ? null : src[idx], sidx, idx, fmtNum); val = val == null ? NULL_LEGEND_VALUES : {_: val}; } @@ -6020,7 +5898,6 @@ var uPlot = (function () { } uPlot.assign = assign; - uPlot.fmtNum = fmtNum; uPlot.rangeNum = rangeNum; uPlot.rangeLog = rangeLog; uPlot.rangeAsinh = rangeAsinh; @@ -6032,7 +5909,6 @@ var uPlot = (function () { } { - uPlot.fmtDate = fmtDate; uPlot.tzDate = tzDate; } diff --git a/dist/uPlot.iife.min.js b/dist/uPlot.iife.min.js index d0ee6fa3..a06510e6 100644 --- a/dist/uPlot.iife.min.js +++ b/dist/uPlot.iife.min.js @@ -1,2 +1,2 @@ /*! https://github.com/leeoniya/uPlot (v1.6.30) */ -var uPlot=function(){"use strict";const e="u-off",l="u-label",t="width",n="height",i="top",o="bottom",s="left",r="right",u="#000",a=u+"0",f="mousemove",c="mousedown",h="mouseup",d="mouseenter",p="mouseleave",m="dblclick",g="change",x="dppxchange",w="--",_="undefined"!=typeof window,b=_?document:null,v=_?window:null,k=_?navigator:null;let y,M;function S(e,l){if(null!=l){let t=e.classList;!t.contains(l)&&t.add(l)}}function E(e,l){let t=e.classList;t.contains(l)&&t.remove(l)}function T(e,l,t){e.style[l]=t+"px"}function z(e,l,t,n){let i=b.createElement(e);return null!=l&&S(i,l),null!=t&&t.insertBefore(i,n),i}function D(e,l){return z("div",e,l)}const P=new WeakMap;function A(l,t,n,i,o){let s="translate("+t+"px,"+n+"px)";s!=P.get(l)&&(l.style.transform=s,P.set(l,s),0>t||0>n||t>i||n>o?S(l,e):E(l,e))}const W=new WeakMap;function Y(e,l,t){let n=l+t;n!=W.get(e)&&(W.set(e,n),e.style.background=l,e.style.borderColor=t)}const C=new WeakMap;function F(e,l,t,n){let i=l+""+t;i!=C.get(e)&&(C.set(e,i),e.style.height=t+"px",e.style.width=l+"px",e.style.marginLeft=n?-l/2+"px":0,e.style.marginTop=n?-t/2+"px":0)}const H={passive:!0},R={...H,capture:!0};function G(e,l,t,n){l.addEventListener(e,t,n?R:H)}function I(e,l,t,n){l.removeEventListener(e,t,n?R:H)}function O(e,l,t,n){let i;t=t||0;let o=2147483647>=(n=n||l.length-1);for(;n-t>1;)i=o?t+n>>1:te((t+n)/2),e>l[i]?t=i:n=i;return e-l[t]>l[n]-e?n:t}function L(e,l,t,n){for(let i=1==n?l:t;i>=l&&t>=i;i+=n)if(null!=e[i])return i;return-1}function N(e,l,t,n){let i=ue(e),o=ue(l);e==l&&(-1==i?(e*=t,l/=t):(e/=t,l*=t));let s=10==t?ae:fe,r=1==o?ie:te,u=(1==i?te:ie)(s(le(e))),a=r(s(le(l))),f=re(t,u),c=re(t,a);return 10==t&&(0>u&&(f=Ee(f,-u)),0>a&&(c=Ee(c,-a))),n||2==t?(e=f*i,l=c*o):(e=Se(e,f),l=Me(l,c)),[e,l]}function j(e,l,t,n){let i=N(e,l,t,n);return 0==e&&(i[0]=0),0==l&&(i[1]=0),i}_&&function e(){let l=devicePixelRatio;y!=l&&(y=l,M&&I(g,M,e),M=matchMedia(`(min-resolution: ${y-.001}dppx) and (max-resolution: ${y+.001}dppx)`),G(g,M,e),v.dispatchEvent(new CustomEvent(x)))}();const U=.1,B={mode:3,pad:U},V={pad:0,soft:null,mode:0},$={min:V,max:V};function J(e,l,t,n){return He(t)?K(e,l,t):(V.pad=t,V.soft=n?0:null,V.mode=n?3:0,K(e,l,$))}function q(e,l){return null==e?l:e}function K(e,l,t){let n=t.min,i=t.max,o=q(n.pad,0),s=q(i.pad,0),r=q(n.hard,-he),u=q(i.hard,he),a=q(n.soft,he),f=q(i.soft,-he),c=q(n.mode,0),h=q(i.mode,0),d=l-e,p=ae(d),m=se(le(e),le(l)),g=ae(m),x=le(g-p);(1e-9>d||x>10)&&(d=0,0!=e&&0!=l||(d=1e-9,2==c&&a!=he&&(o=0),2==h&&f!=-he&&(s=0)));let w=d||m||1e3,_=ae(w),b=re(10,te(_)),v=Ee(Se(e-w*(0==d?0==e?.1:1:o),b/10),9),k=a>e||1!=c&&(3!=c||v>a)&&(2!=c||a>v)?he:a,y=se(r,k>v&&e>=k?k:oe(k,v)),M=Ee(Me(l+w*(0==d?0==l?.1:1:s),b/10),9),S=l>f||1!=h&&(3!=h||f>M)&&(2!=h||M>f)?-he:f,E=oe(u,M>S&&S>=l?S:se(S,M));return y==E&&0==y&&(E=100),[y,E]}const X=new Intl.NumberFormat(_?k.language:"en-US"),Z=e=>X.format(e),Q=Math,ee=Q.PI,le=Q.abs,te=Q.floor,ne=Q.round,ie=Q.ceil,oe=Q.min,se=Q.max,re=Q.pow,ue=Q.sign,ae=Q.log10,fe=Q.log2,ce=(e,l=1)=>Q.asinh(e/l),he=1/0;function de(e){return 1+(0|ae((e^e>>31)-(e>>31)))}function pe(e,l,t){return oe(se(e,l),t)}function me(e){return"function"==typeof e?e:()=>e}const ge=e=>e,xe=(e,l)=>l,we=()=>null,_e=()=>!0,be=(e,l)=>e==l,ve=/\.\d*?(?=9{6,}|0{6,})/gm,ke=e=>{if(Ce(e)||Te.has(e))return e;const l=""+e,t=l.match(ve);if(null==t)return e;let n=t[0].length-1;if(-1!=l.indexOf("e-")){let[e,t]=l.split("e");return+`${ke(e)}e${t}`}return Ee(e,n)};function ye(e,l){return ke(Ee(ke(e/l))*l)}function Me(e,l){return ke(ie(ke(e/l))*l)}function Se(e,l){return ke(te(ke(e/l))*l)}function Ee(e,l=0){if(Ce(e))return e;let t=10**l;return ne(e*t*(1+Number.EPSILON))/t}const Te=new Map;function ze(e){return((""+e).split(".")[1]||"").length}function De(e,l,t,n){let i=[],o=n.map(ze);for(let s=l;t>s;s++){let l=le(s),t=Ee(re(e,s),l);for(let r=0;n.length>r;r++){let u=10==e?+`${n[r]}e${s}`:n[r]*t,a=(0>s?l:0)+(o[r]>s?o[r]:0),f=10==e?u:Ee(u,a);i.push(f),Te.set(f,a)}}return i}const Pe={},Ae=[],We=[null,null],Ye=Array.isArray,Ce=Number.isInteger;function Fe(e){return"string"==typeof e}function He(e){let l=!1;if(null!=e){let t=e.constructor;l=null==t||t==Object}return l}function Re(e){return null!=e&&"object"==typeof e}const Ge=Object.getPrototypeOf(Uint8Array),Ie="__proto__";function Oe(e,l=He){let t;if(Ye(e)){let n=e.find((e=>null!=e));if(Ye(n)||l(n)){t=Array(e.length);for(let n=0;e.length>n;n++)t[n]=Oe(e[n],l)}else t=e.slice()}else if(e instanceof Ge)t=e.slice();else if(l(e)){t={};for(let n in e)n!=Ie&&(t[n]=Oe(e[n],l))}else t=e;return t}function Le(e){let l=arguments;for(let t=1;l.length>t;t++){let n=l[t];for(let l in n)l!=Ie&&(He(e[l])?Le(e[l],Oe(n[l])):e[l]=Oe(n[l]))}return e}function Ne(e,l,t){for(let n,i=0,o=-1;l.length>i;i++){let s=l[i];if(s>o){for(n=s-1;n>=0&&null==e[n];)e[n--]=null;for(n=s+1;t>n&&null==e[n];)e[o=n++]=null}}}const je="undefined"==typeof queueMicrotask?e=>Promise.resolve().then(e):queueMicrotask,Ue=["January","February","March","April","May","June","July","August","September","October","November","December"],Be=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"];function Ve(e){return e.slice(0,3)}const $e=Be.map(Ve),Je=Ue.map(Ve),qe={MMMM:Ue,MMM:Je,WWWW:Be,WWW:$e};function Ke(e){return(10>e?"0":"")+e}const Xe={YYYY:e=>e.getFullYear(),YY:e=>(e.getFullYear()+"").slice(2),MMMM:(e,l)=>l.MMMM[e.getMonth()],MMM:(e,l)=>l.MMM[e.getMonth()],MM:e=>Ke(e.getMonth()+1),M:e=>e.getMonth()+1,DD:e=>Ke(e.getDate()),D:e=>e.getDate(),WWWW:(e,l)=>l.WWWW[e.getDay()],WWW:(e,l)=>l.WWW[e.getDay()],HH:e=>Ke(e.getHours()),H:e=>e.getHours(),h:e=>{let l=e.getHours();return 0==l?12:l>12?l-12:l},AA:e=>12>e.getHours()?"AM":"PM",aa:e=>12>e.getHours()?"am":"pm",a:e=>12>e.getHours()?"a":"p",mm:e=>Ke(e.getMinutes()),m:e=>e.getMinutes(),ss:e=>Ke(e.getSeconds()),s:e=>e.getSeconds(),fff:e=>function(e){return(10>e?"00":100>e?"0":"")+e}(e.getMilliseconds())};function Ze(e,l){l=l||qe;let t,n=[],i=/\{([a-z]+)\}|[^{]+/gi;for(;t=i.exec(e);)n.push("{"==t[0][0]?Xe[t[1]]:t[0]);return e=>{let t="";for(let i=0;n.length>i;i++)t+="string"==typeof n[i]?n[i]:n[i](e,l);return t}}const Qe=(new Intl.DateTimeFormat).resolvedOptions().timeZone,el=e=>e%1==0,ll=[1,2,2.5,5],tl=De(10,-32,0,ll),nl=De(10,0,32,ll),il=nl.filter(el),ol=tl.concat(nl),sl="{YYYY}",rl="\n"+sl,ul="{M}/{D}",al="\n"+ul,fl=al+"/{YY}",cl="{aa}",hl="{h}:{mm}"+cl,dl="\n"+hl,pl=":{ss}",ml=null;function gl(e){let l=1e3*e,t=60*l,n=60*t,i=24*n,o=30*i,s=365*i;return[(1==e?De(10,0,3,ll).filter(el):De(10,-3,0,ll)).concat([l,5*l,10*l,15*l,30*l,t,5*t,10*t,15*t,30*t,n,2*n,3*n,4*n,6*n,8*n,12*n,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,o,2*o,3*o,4*o,6*o,s,2*s,5*s,10*s,25*s,50*s,100*s]),[[s,sl,ml,ml,ml,ml,ml,ml,1],[28*i,"{MMM}",rl,ml,ml,ml,ml,ml,1],[i,ul,rl,ml,ml,ml,ml,ml,1],[n,"{h}"+cl,fl,ml,al,ml,ml,ml,1],[t,hl,fl,ml,al,ml,ml,ml,1],[l,pl,fl+" "+hl,ml,al+" "+hl,ml,dl,ml,1],[e,pl+".{fff}",fl+" "+hl,ml,al+" "+hl,ml,dl,ml,1]],function(l){return(r,u,a,f,c,h)=>{let d=[],p=c>=s,m=c>=o&&s>c,g=l(a),x=Ee(g*e,3),w=Sl(g.getFullYear(),p?0:g.getMonth(),m||p?1:g.getDate()),_=Ee(w*e,3);if(m||p){let t=m?c/o:0,n=p?c/s:0,i=x==_?x:Ee(Sl(w.getFullYear()+n,w.getMonth()+t,1)*e,3),r=new Date(ne(i/e)),u=r.getFullYear(),a=r.getMonth();for(let o=0;f>=i;o++){let s=Sl(u+n*o,a+t*o,1),r=s-l(Ee(s*e,3));i=Ee((+s+r)*e,3),i>f||d.push(i)}}else{let o=i>c?c:i,s=_+(te(a)-te(x))+Me(x-_,o);d.push(s);let p=l(s),m=p.getHours()+p.getMinutes()/t+p.getSeconds()/n,g=c/n,w=h/r.axes[u]._space;for(;s=Ee(s+c,1==e?0:3),f>=s;)if(g>1){let e=te(Ee(m+g,6))%24,t=l(s).getHours()-e;t>1&&(t=-1),s-=t*n,m=(m+g)%24,.7>Ee((s-d[d.length-1])/c,3)*w||d.push(s)}else d.push(s)}return d}}]}const[xl,wl,_l]=gl(1),[bl,vl,kl]=gl(.001);function yl(e,l){return e.map((e=>e.map(((t,n)=>0==n||8==n||null==t?t:l(1==n||0==e[8]?t:e[1]+t)))))}function Ml(e,l){return(t,n,i,o,s)=>{let r,u,a,f,c,h,d=l.find((e=>s>=e[0]))||l[l.length-1];return n.map((l=>{let t=e(l),n=t.getFullYear(),i=t.getMonth(),o=t.getDate(),s=t.getHours(),p=t.getMinutes(),m=t.getSeconds(),g=n!=r&&d[2]||i!=u&&d[3]||o!=a&&d[4]||s!=f&&d[5]||p!=c&&d[6]||m!=h&&d[7]||d[1];return r=n,u=i,a=o,f=s,c=p,h=m,g(t)}))}}function Sl(e,l,t){return new Date(e,l,t)}function El(e,l){return l(e)}function Tl(e,l){return(t,n,i,o)=>null==o?w:l(e(n))}De(2,-53,53,[1]);const zl={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(e,l){let t=e.series[l];return t.width?t.stroke(e,l):t.points.width?t.points.stroke(e,l):null},fill:function(e,l){return e.series[l].fill(e,l)},dash:"solid"},idx:null,idxs:null,values:[]},Dl=[0,0];function Pl(e,l,t,n=!0){return e=>{0==e.button&&(!n||e.target==l)&&t(e)}}function Al(e,l,t,n=!0){return e=>{(!n||e.target==l)&&t(e)}}const Wl={show:!0,x:!0,y:!0,lock:!1,move:function(e,l,t){return Dl[0]=l,Dl[1]=t,Dl},points:{one:!1,show:function(e,l){let i=e.cursor.points,o=D(),s=i.size(e,l);T(o,t,s),T(o,n,s);let r=s/-2;T(o,"marginLeft",r),T(o,"marginTop",r);let u=i.width(e,l,s);return u&&T(o,"borderWidth",u),o},size:function(e,l){return e.series[l].points.size},width:0,stroke:function(e,l){let t=e.series[l].points;return t._stroke||t._fill},fill:function(e,l){let t=e.series[l].points;return t._fill||t._stroke}},bind:{mousedown:Pl,mouseup:Pl,click:Pl,dblclick:Pl,mousemove:Al,mouseleave:Al,mouseenter:Al},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(e,l)=>{l.stopPropagation(),l.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(e,l,t,n,i)=>n-i,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},Yl={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},Cl=Le({},Yl,{filter:xe}),Fl=Le({},Cl,{size:10}),Hl=Le({},Yl,{show:!1}),Rl='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',Gl="bold "+Rl,Il={show:!0,scale:"x",stroke:u,space:50,gap:5,size:50,labelGap:0,labelSize:30,labelFont:Gl,side:2,grid:Cl,ticks:Fl,border:Hl,font:Rl,lineGap:1.5,rotate:0},Ol={show:!0,scale:"x",auto:!1,sorted:1,min:he,max:-he,idxs:[]};function Ll(e,l){return l.map((e=>null==e?"":Z(e)))}function Nl(e,l,t,n,i,o,s){let r=[],u=Te.get(i)||0;for(let e=t=s?t:Ee(Me(t,i),u);n>=e;e=Ee(e+i,u))r.push(Object.is(e,-0)?0:e);return r}function jl(e,l,t,n,i){const o=[],s=e.scales[e.axes[l].scale].log,r=te((10==s?ae:fe)(t));i=re(s,r),10==s&&(i=ol[O(i,ol)]);let u=t,a=i*s;10==s&&(a=ol[O(a,ol)]);do{o.push(u),u+=i,10!=s||Te.has(u)||(u=Ee(u,Te.get(i))),a>u||(a=(i=u)*s,10==s&&(a=ol[O(a,ol)]))}while(n>=u);return o}function Ul(e,l,t,n,i){let o=e.scales[e.axes[l].scale].asinh,s=n>o?jl(e,l,se(o,t),n,i):[o],r=0>n||t>0?[]:[0];return(-o>t?jl(e,l,se(o,-n),-t,i):[o]).reverse().map((e=>-e)).concat(r,s)}const Bl=/./,Vl=/[12357]/,$l=/[125]/,Jl=/1/,ql=(e,l,t,n)=>e.map(((e,i)=>4==l&&0==e||i%n==0&&t.test(e.toExponential()[0>e?1:0])?e:null));function Kl(e,l,t){let n=e.axes[t],i=n.scale,o=e.scales[i],s=e.valToPos,r=n._space,u=s(10,i),a=s(9,i)-ue)return ql(l.slice().reverse(),o.distr,a,ie(r/e)).reverse()}return ql(l,o.distr,a,1)}function Xl(e,l,t){let n=e.axes[t],i=n.scale,o=n._space,s=e.valToPos,r=le(s(1,i)-s(2,i));return o>r?ql(l.slice().reverse(),3,Bl,ie(o/r)).reverse():l}function Zl(e,l,t,n){return null==n?w:null==l?"":Z(l)}const Ql={show:!0,scale:"y",stroke:u,space:30,gap:5,size:50,labelGap:0,labelSize:30,labelFont:Gl,side:3,grid:Cl,ticks:Fl,border:Hl,font:Rl,lineGap:1.5,rotate:0},et={scale:null,auto:!0,sorted:0,min:he,max:-he},lt=(e,l,t,n,i)=>i,tt={show:!0,auto:!0,sorted:0,gaps:lt,alpha:1,facets:[Le({},et,{scale:"x"}),Le({},et,{scale:"y"})]},nt={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:lt,alpha:1,points:{show:function(e,l){let{scale:t,idxs:n}=e.series[0],i=e._data[0],o=e.valToPos(i[n[0]],t,!0),s=e.valToPos(i[n[1]],t,!0);return le(s-o)/(e.series[l].points.space*y)>=n[1]-n[0]},filter:null},values:null,min:he,max:-he,idxs:[],path:null,clip:null};function it(e,l,t){return t/10}const ot={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},st=Le({},ot,{time:!1,ori:1}),rt={};function ut(e){let l=rt[e];return l||(l={key:e,plots:[],sub(e){l.plots.push(e)},unsub(e){l.plots=l.plots.filter((l=>l!=e))},pub(e,t,n,i,o,s,r){for(let u=0;l.plots.length>u;u++)l.plots[u]!=t&&l.plots[u].pub(e,t,n,i,o,s,r)}},null!=e&&(rt[e]=l)),l}function at(e,l,t){const n=e.mode,i=e.series[l],o=2==n?e._data[l]:e._data,s=e.scales,r=e.bbox;let u=o[0],a=2==n?o[1]:o[l],f=2==n?s[i.facets[0].scale]:s[e.series[0].scale],c=2==n?s[i.facets[1].scale]:s[i.scale],h=r.left,d=r.top,p=r.width,m=r.height,g=e.valToPosH,x=e.valToPosV;return 0==f.ori?t(i,u,a,f,c,g,x,h,d,p,m,xt,_t,vt,yt,St):t(i,u,a,f,c,x,g,d,h,m,p,wt,bt,kt,Mt,Et)}function ft(e,l){let t=0,n=0,i=q(e.bands,Ae);for(let e=0;i.length>e;e++){let o=i[e];o.series[0]==l?t=o.dir:o.series[1]==l&&(n|=1==o.dir?1:2)}return[t,1==n?-1:2==n?1:3==n?2:0]}function ct(e,l,t,n,i){let o=e.series[l],s=e.scales[2==e.mode?o.facets[1].scale:o.scale];return-1==i?s.min:1==i?s.max:3==s.distr?1==s.dir?s.min:s.max:0}function ht(e,l,t,n,i,o){return at(e,l,((e,l,s,r,u,a,f,c,h,d,p)=>{let m=e.pxRound;const g=0==r.ori?_t:bt;let x,w;1==r.dir*(0==r.ori?1:-1)?(x=t,w=n):(x=n,w=t);let _=m(a(l[x],r,d,c)),b=m(f(s[x],u,p,h)),v=m(a(l[w],r,d,c)),k=m(f(1==o?u.max:u.min,u,p,h)),y=new Path2D(i);return g(y,v,k),g(y,_,k),g(y,_,b),y}))}function dt(e,l,t,n,i,o){let s=null;if(e.length>0){s=new Path2D;const r=0==l?vt:kt;let u=t;for(let l=0;e.length>l;l++){let t=e[l];if(t[1]>t[0]){let e=t[0]-u;e>0&&r(s,u,n,e,n+o),u=t[1]}}let a=t+i-u,f=10;a>0&&r(s,u,n-f/2,a,n+o+f)}return s}function pt(e,l,t,n,i,o,s){let r=[],u=e.length;for(let a=1==i?t:n;a>=t&&n>=a;a+=i)if(null===l[a]){let f=a,c=a;if(1==i)for(;++a<=n&&null===l[a];)c=a;else for(;--a>=t&&null===l[a];)c=a;let h=o(e[f]),d=c==f?h:o(e[c]),p=f-i;h=s>0||0>p||p>=u?h:o(e[p]);let m=c+i;d=0>s||0>m||m>=u?d:o(e[m]),h>d||r.push([h,d])}return r}function mt(e){return 0==e?ge:1==e?ne:l=>ye(l,e)}function gt(e){let l=0==e?xt:wt,t=0==e?(e,l,t,n,i,o)=>{e.arcTo(l,t,n,i,o)}:(e,l,t,n,i,o)=>{e.arcTo(t,l,i,n,o)},n=0==e?(e,l,t,n,i)=>{e.rect(l,t,n,i)}:(e,l,t,n,i)=>{e.rect(t,l,i,n)};return(e,i,o,s,r,u=0,a=0)=>{0==u&&0==a?n(e,i,o,s,r):(u=oe(u,s/2,r/2),a=oe(a,s/2,r/2),l(e,i+u,o),t(e,i+s,o,i+s,o+r,u),t(e,i+s,o+r,i,o+r,a),t(e,i,o+r,i,o,a),t(e,i,o,i+s,o,u),e.closePath())}}const xt=(e,l,t)=>{e.moveTo(l,t)},wt=(e,l,t)=>{e.moveTo(t,l)},_t=(e,l,t)=>{e.lineTo(l,t)},bt=(e,l,t)=>{e.lineTo(t,l)},vt=gt(0),kt=gt(1),yt=(e,l,t,n,i,o)=>{e.arc(l,t,n,i,o)},Mt=(e,l,t,n,i,o)=>{e.arc(t,l,n,i,o)},St=(e,l,t,n,i,o,s)=>{e.bezierCurveTo(l,t,n,i,o,s)},Et=(e,l,t,n,i,o,s)=>{e.bezierCurveTo(t,l,i,n,s,o)};function Tt(){return(e,l,t,n,i)=>at(e,l,((l,o,s,r,u,a,f,c,h,d,p)=>{let m,g,{pxRound:x,points:w}=l;0==r.ori?(m=xt,g=yt):(m=wt,g=Mt);const _=Ee(w.width*y,3);let b=(w.size-w.width)/2*y,v=Ee(2*b,3),k=new Path2D,M=new Path2D,{left:S,top:E,width:T,height:z}=e.bbox;vt(M,S-v,E-v,T+2*v,z+2*v);const D=e=>{if(null!=s[e]){let l=x(a(o[e],r,d,c)),t=x(f(s[e],u,p,h));m(k,l+b,t),g(k,l,t,b,0,2*ee)}};if(i)i.forEach(D);else for(let e=t;n>=e;e++)D(e);return{stroke:_>0?k:null,fill:k,clip:M,flags:3}}))}function zt(e){return(l,t,n,i,o,s)=>{n!=i&&(o!=n&&s!=n&&e(l,t,n),o!=i&&s!=i&&e(l,t,i),e(l,t,s))}}const Dt=zt(_t),Pt=zt(bt);function At(e){const l=q(e?.alignGaps,0);return(e,t,n,i)=>at(e,t,((o,s,r,u,a,f,c,h,d,p,m)=>{let g,x,w=o.pxRound,_=e=>w(f(e,u,p,h)),b=e=>w(c(e,a,m,d));0==u.ori?(g=_t,x=Dt):(g=bt,x=Pt);const v=u.dir*(0==u.ori?1:-1),k={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},y=k.stroke;let M,S,E,T=he,z=-he,D=_(s[1==v?n:i]),P=L(r,n,i,1*v),A=L(r,n,i,-1*v),W=_(s[P]),Y=_(s[A]),C=!1;for(let e=1==v?n:i;e>=n&&i>=e;e+=v){let l=_(s[e]),t=r[e];l==D?null!=t?(S=b(t),T==he&&(g(y,l,S),M=S),T=oe(S,T),z=se(S,z)):null===t&&(C=!0):(T!=he&&(x(y,D,T,z,M,S),E=D),null!=t?(S=b(t),g(y,l,S),T=z=M=S):(T=he,z=-he,null===t&&(C=!0)),D=l)}T!=he&&T!=z&&E!=D&&x(y,D,T,z,M,S);let[F,H]=ft(e,t);if(null!=o.fill||0!=F){let l=k.fill=new Path2D(y),n=b(o.fillTo(e,t,o.min,o.max,F));g(l,Y,n),g(l,W,n)}if(!o.spanGaps){let a=[];C&&a.push(...pt(s,r,n,i,v,_,l)),k.gaps=a=o.gaps(e,t,n,i,a),k.clip=dt(a,u.ori,h,d,p,m)}return 0!=H&&(k.band=2==H?[ht(e,t,n,i,y,-1),ht(e,t,n,i,y,1)]:ht(e,t,n,i,y,H)),k}))}function Wt(e,l,t,n,i,o,s=he){if(e.length>1){let r=null;for(let u=0,a=1/0;e.length>u;u++)if(void 0!==l[u]){if(null!=r){let l=le(e[u]-e[r]);a>l&&(a=l,s=le(t(e[u],n,i,o)-t(e[r],n,i,o)))}r=u}}return s}function Yt(e,l,t,n,i){const o=e.length;if(2>o)return null;const s=new Path2D;if(t(s,e[0],l[0]),2==o)n(s,e[1],l[1]);else{let t=Array(o),n=Array(o-1),r=Array(o-1),u=Array(o-1);for(let t=0;o-1>t;t++)r[t]=l[t+1]-l[t],u[t]=e[t+1]-e[t],n[t]=r[t]/u[t];t[0]=n[0];for(let e=1;o-1>e;e++)0===n[e]||0===n[e-1]||n[e-1]>0!=n[e]>0?t[e]=0:(t[e]=3*(u[e-1]+u[e])/((2*u[e]+u[e-1])/n[e-1]+(u[e]+2*u[e-1])/n[e]),isFinite(t[e])||(t[e]=0));t[o-1]=n[o-2];for(let n=0;o-1>n;n++)i(s,e[n]+u[n]/3,l[n]+t[n]*u[n]/3,e[n+1]-u[n]/3,l[n+1]-t[n+1]*u[n]/3,e[n+1],l[n+1])}return s}const Ct=new Set;function Ft(){for(let e of Ct)e.syncRect(!0)}_&&(G("resize",v,Ft),G("scroll",v,Ft,!0),G(x,v,(()=>{Kt.pxRatio=y})));const Ht=At(),Rt=Tt();function Gt(e,l,t,n){return(n?[e[0],e[1]].concat(e.slice(2)):[e[0]].concat(e.slice(1))).map(((e,n)=>It(e,n,l,t)))}function It(e,l,t,n){return Le({},0==l?t:n,e)}function Ot(e,l,t){return null==l?We:[l,t]}const Lt=Ot;function Nt(e,l,t){return null==l?We:J(l,t,U,!0)}function jt(e,l,t,n){return null==l?We:N(l,t,e.scales[n].log,!1)}const Ut=jt;function Bt(e,l,t,n){return null==l?We:j(l,t,e.scales[n].log,!1)}const Vt=Bt;function $t(e,l,t,n,i){let o=se(de(e),de(l)),s=l-e,r=O(i/n*s,t);do{let e=t[r],l=n*e/s;if(l>=i&&17>=o+(5>e?Te.get(e):0))return[e,l]}while(++r(l=ne((t=+n)*y))+"px")),l,t]}function qt(e){e.show&&[e.font,e.labelFont].forEach((e=>{let l=Ee(e[2]*y,1);e[0]=e[0].replace(/[0-9.]+px/,l+"px"),e[1]=l}))}function Kt(u,g,_){const k={mode:q(u.mode,1)},M=k.mode;function P(e,l){return((3==l.distr?ae(e>0?e:l.clamp(k,e,l.min,l.max,l.key)):4==l.distr?ce(e,l.asinh):100==l.distr?l.fwd(e):e)-l._min)/(l._max-l._min)}function W(e,l,t,n){let i=P(e,l);return n+t*(-1==l.dir?1-i:i)}function C(e,l,t,n){let i=P(e,l);return n+t*(-1==l.dir?i:1-i)}function H(e,l,t,n){return 0==l.ori?W(e,l,t,n):C(e,l,t,n)}k.valToPosH=W,k.valToPosV=C;let R=!1;k.status=0;const L=k.root=D("uplot");null!=u.id&&(L.id=u.id),S(L,u.class),u.title&&(D("u-title",L).textContent=u.title);const V=z("canvas"),$=k.ctx=V.getContext("2d"),K=D("u-wrap",L);G("click",K,(e=>{e.target===Z&&(Hn!=Wn||Rn!=Yn)&&Vn.click(k,e)}),!0);const X=k.under=D("u-under",K);K.appendChild(V);const Z=k.over=D("u-over",K),te=+q((u=Oe(u)).pxAlign,1),ue=mt(te);(u.plugins||[]).forEach((e=>{e.opts&&(u=e.opts(k,u)||u)}));const fe=u.ms||.001,de=k.series=1==M?Gt(u.series||[],Ol,nt,!1):function(e,l){return e.map(((e,t)=>0==t?{}:Le({},l,e)))}(u.series||[null],tt),ge=k.axes=Gt(u.axes||[],Il,Ql,!0),ve=k.scales={},ke=k.bands=u.bands||[];ke.forEach((e=>{e.fill=me(e.fill||null),e.dir=q(e.dir,-1)}));const Me=2==M?de[1].facets[0].scale:de[0].scale,Se={axes:function(){for(let e=0;ge.length>e;e++){let l=ge[e];if(!l.show||!l._show)continue;let t,n,u=l.side,a=u%2,f=l.stroke(k,e),c=0==u||3==u?-1:1;if(l.label){let e=ne((l._lpos+l.labelGap*c)*y);dn(l.labelFont[0],f,"center",2==u?i:o),$.save(),1==a?(t=n=0,$.translate(e,ne($l+ql/2)),$.rotate((3==u?-ee:ee)/2)):(t=ne(Vl+Jl/2),n=e),$.fillText(l.label,t,n),$.restore()}let[h,d]=l._found;if(0==d)continue;let p=ve[l.scale],m=0==a?Jl:ql,g=0==a?Vl:$l,x=ne(l.gap*y),w=l._splits,_=2==p.distr?w.map((e=>un[e])):w,b=2==p.distr?un[w[1]]-un[w[0]]:h,v=l.ticks,M=l.border,S=v.show?ne(v.size*y):0,E=l._rotate*-ee/180,T=ue(l._pos*y),z=T+(S+x)*c;n=0==a?z:0,t=1==a?z:0,dn(l.font[0],f,1==l.align?s:2==l.align?r:E>0?s:0>E?r:0==a?"center":3==u?r:s,E||1==a?"middle":2==u?i:o);let D=l.font[1]*l.lineGap,P=w.map((e=>ue(H(e,p,m,g)))),A=l._values;for(let e=0;A.length>e;e++){let l=A[e];if(null!=l){0==a?t=P[e]:n=P[e],l=""+l;let i=-1==l.indexOf("\n")?[l]:l.split(/\n/gm);for(let e=0;i.length>e;e++){let l=i[e];E?($.save(),$.translate(t,n+e*D),$.rotate(E),$.fillText(l,0,0),$.restore()):$.fillText(l,t,n+e*D)}}}v.show&&kn(P,v.filter(k,_,e,d,b),a,u,T,S,Ee(v.width*y,3),v.stroke(k,e),v.dash,v.cap);let W=l.grid;W.show&&kn(P,W.filter(k,_,e,d,b),a,0==a?2:1,0==a?$l:Vl,0==a?ql:Jl,Ee(W.width*y,3),W.stroke(k,e),W.dash,W.cap),M.show&&kn([T],[1],0==a?1:0,0==a?1:2,1==a?$l:Vl,1==a?ql:Jl,Ee(M.width*y,3),M.stroke(k,e),M.dash,M.cap)}zi("drawAxes")},series:function(){Wt>0&&(de.forEach(((e,l)=>{if(l>0&&e.show&&(gn(l,!1),gn(l,!0),null==e._paths)){rn!=e.alpha&&($.globalAlpha=rn=e.alpha);let t=2==M?[0,g[l][0].length-1]:function(e){let l=pe(Yt-1,0,Wt-1),t=pe(Ft+1,0,Wt-1);for(;null==e[l]&&l>0;)l--;for(;null==e[t]&&Wt-1>t;)t++;return[l,t]}(g[l]);e._paths=e.paths(k,l,t[0],t[1]),1!=rn&&($.globalAlpha=rn=1)}})),de.forEach(((e,l)=>{if(l>0&&e.show){rn!=e.alpha&&($.globalAlpha=rn=e.alpha),null!=e._paths&&xn(l,!1);{let t=null!=e._paths?e._paths.gaps:null,n=e.points.show(k,l,Yt,Ft,t),i=e.points.filter(k,l,n,t);(n||i)&&(e.points._paths=e.points.paths(k,l,Yt,Ft,i),xn(l,!0))}1!=rn&&($.globalAlpha=rn=1),zi("drawSeries",l)}})))}},De=(u.drawOrder||["axes","series"]).map((e=>Se[e]));function Ce(e){let l=ve[e];if(null==l){let t=(u.scales||Pe)[e]||Pe;if(null!=t.from)Ce(t.from),ve[e]=Le({},ve[t.from],t,{key:e});else{l=ve[e]=Le({},e==Me?ot:st,t),l.key=e;let n=l.time,i=l.range,o=Ye(i);if((e!=Me||2==M&&!n)&&(!o||null!=i[0]&&null!=i[1]||(i={min:null==i[0]?B:{mode:1,hard:i[0],soft:i[0]},max:null==i[1]?B:{mode:1,hard:i[1],soft:i[1]}},o=!1),!o&&He(i))){let e=i;i=(l,t,n)=>null==t?We:J(t,n,e)}l.range=me(i||(n?Lt:e==Me?3==l.distr?Ut:4==l.distr?Vt:Ot:3==l.distr?jt:4==l.distr?Bt:Nt)),l.auto=me(!o&&l.auto),l.clamp=me(l.clamp||it),l._min=l._max=null}}}Ce("x"),Ce("y"),1==M&&de.forEach((e=>{Ce(e.scale)})),ge.forEach((e=>{Ce(e.scale)}));for(let e in u.scales)Ce(e);const Ge=ve[Me],Ie=Ge.distr;let Ne,Ue;0==Ge.ori?(S(L,"u-hz"),Ne=W,Ue=C):(S(L,"u-vt"),Ne=C,Ue=W);const Be={};for(let e in ve){let l=ve[e];null==l.min&&null==l.max||(Be[e]={min:l.min,max:l.max},l.min=l.max=null)}const Ve=u.tzDate||(e=>new Date(ne(e/fe))),$e=u.fmtDate||Ze,Je=1==fe?_l(Ve):kl(Ve),qe=Ml(Ve,yl(1==fe?wl:vl,$e)),Ke=Tl(Ve,El("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",$e)),Xe=[],Qe=k.legend=Le({},zl,u.legend),el=Qe.show,ll=Qe.markers;let tl,nl,sl;Qe.idxs=Xe,ll.width=me(ll.width),ll.dash=me(ll.dash),ll.stroke=me(ll.stroke),ll.fill=me(ll.fill);let rl,ul=[],al=[],fl=!1,cl={};if(Qe.live){const e=de[1]?de[1].values:null;fl=null!=e,rl=fl?e(k,1,0):{_:0};for(let e in rl)cl[e]=w}if(el)if(tl=z("table","u-legend",L),sl=z("tbody",null,tl),Qe.mount(k,tl),fl){nl=z("thead",null,tl,sl);let e=z("tr",null,nl);for(var hl in z("th",null,e),rl)z("th",l,e).textContent=hl}else S(tl,"u-inline"),Qe.live&&S(tl,"u-live");const dl={show:!0},pl={show:!1},ml=new Map;function gl(e,l,t,n=!0){const i=ml.get(l)||{},o=xt.bind[e](k,l,t,n);o&&(G(e,l,i[e]=o),ml.set(l,i))}function Sl(e,l){const t=ml.get(l)||{};for(let n in t)null!=e&&n!=e||(I(n,l,t[n]),delete t[n]);null==e&&ml.delete(l)}let Dl=0,Pl=0,Al=0,Yl=0,Cl=0,Fl=0,Hl=Cl,Rl=Fl,Gl=Al,Bl=Yl,Vl=0,$l=0,Jl=0,ql=0;k.bbox={};let et=!1,lt=!1,rt=!1,at=!1,ft=!1,ht=!1;function dt(e,l,t){(t||e!=k.width||l!=k.height)&&pt(e,l),Sn(!1),rt=!0,lt=!0,Nn()}function pt(e,l){k.width=Dl=Al=e,k.height=Pl=Yl=l,Cl=Fl=0,function(){let e=!1,l=!1,t=!1,n=!1;ge.forEach((i=>{if(i.show&&i._show){let{side:o,_size:s}=i,r=s+(null!=i.label?i.labelSize:0);r>0&&(o%2?(Al-=r,3==o?(Cl+=r,n=!0):t=!0):(Yl-=r,0==o?(Fl+=r,e=!0):l=!0))}})),zt[0]=e,zt[1]=t,zt[2]=l,zt[3]=n,Al-=At[1]+At[3],Cl+=At[3],Yl-=At[2]+At[0],Fl+=At[0]}(),function(){let e=Cl+Al,l=Fl+Yl,t=Cl,n=Fl;function i(i,o){switch(i){case 1:return e+=o,e-o;case 2:return l+=o,l-o;case 3:return t-=o,t+o;case 0:return n-=o,n+o}}ge.forEach((e=>{if(e.show&&e._show){let l=e.side;e._pos=i(l,e._size),null!=e.label&&(e._lpos=i(l,e.labelSize))}}))}();let t=k.bbox;Vl=t.left=ye(Cl*y,.5),$l=t.top=ye(Fl*y,.5),Jl=t.width=ye(Al*y,.5),ql=t.height=ye(Yl*y,.5)}const gt=3;k.setSize=function({width:e,height:l}){dt(e,l)};const xt=k.cursor=Le({},Wl,{drag:{y:2==M}},u.cursor);if(null==xt.dataIdx){let e=xt.hover,l=e.skip=new Set(e.skip??[]);l.add(void 0);let t=e.prox=me(e.prox),n=e.bias??=0;xt.dataIdx=(e,i,o,s)=>{if(0==i)return o;let r=o,u=t(e,i,o,s)??he,a=u>=0&&he>u,f=0==Ge.ori?Al:Yl,c=xt.left,h=g[0],d=g[i];if(l.has(d[o])){r=null;let e,t=null,i=null;if(0==n||-1==n)for(e=o;null==t&&e-- >0;)l.has(d[e])||(t=e);if(0==n||1==n)for(e=o;null==i&&e++l?l>u||(r=i):e>u||(r=t)}else r=null==i?t:null==t||o-t>i-o?i:t}else a&&le(c-Ne(h[o],Ge,f,0))>u&&(r=null);return r}}const wt=e=>{xt.event=e};xt.idxs=Xe,xt._lock=!1;let _t=xt.points;_t.show=me(_t.show),_t.size=me(_t.size),_t.stroke=me(_t.stroke),_t.width=me(_t.width),_t.fill=me(_t.fill);const bt=k.focus=Le({},u.focus||{alpha:.3},xt.focus),vt=bt.prox>=0,kt=vt&&_t.one;let yt=[],Mt=[],St=[];function Et(e,l){let t=_t.show(k,l);if(t)return S(t,"u-cursor-pt"),S(t,e.class),A(t,-10,-10,Al,Yl),Z.insertBefore(t,yt[l]),t}function Tt(t,n){if(1==M||n>0){let e=1==M&&ve[t.scale].time,l=t.value;t.value=e?Fe(l)?Tl(Ve,El(l,$e)):l||Ke:l||Zl,t.label=t.label||(e?"Time":"Value")}if(kt||n>0){t.width=null==t.width?1:t.width,t.paths=t.paths||Ht||we,t.fillTo=me(t.fillTo||ct),t.pxAlign=+q(t.pxAlign,te),t.pxRound=mt(t.pxAlign),t.stroke=me(t.stroke||null),t.fill=me(t.fill||null),t._stroke=t._fill=t._paths=t._focus=null;let e=function(e){return Ee(1*(3+2*(e||1)),3)}(se(1,t.width)),l=t.points=Le({},{size:e,width:se(1,.2*e),stroke:t.stroke,space:2*e,paths:Rt,_stroke:null,_fill:null},t.points);l.show=me(l.show),l.filter=me(l.filter),l.fill=me(l.fill),l.stroke=me(l.stroke),l.paths=me(l.paths),l.pxAlign=t.pxAlign}if(el){let i=function(t,n){if(0==n&&(fl||!Qe.live||2==M))return We;let i=[],o=z("tr","u-series",sl,sl.childNodes[n]);S(o,t.class),t.show||S(o,e);let s=z("th",null,o);if(ll.show){let e=D("u-marker",s);if(n>0){let l=ll.width(k,n);l&&(e.style.border=l+"px "+ll.dash(k,n)+" "+ll.stroke(k,n)),e.style.background=ll.fill(k,n)}}let r=D(l,s);for(var u in r.textContent=t.label,n>0&&(ll.show||(r.style.color=t.width>0?ll.stroke(k,n):ll.fill(k,n)),gl("click",s,(e=>{if(xt._lock)return;wt(e);let l=de.indexOf(t);if((e.ctrlKey||e.metaKey)!=Qe.isolate){let e=de.some(((e,t)=>t>0&&t!=l&&e.show));de.forEach(((t,n)=>{n>0&&Qn(n,e?n==l?dl:pl:dl,!0,Pi.setSeries)}))}else Qn(l,{show:!t.show},!0,Pi.setSeries)}),!1),vt&&gl(d,s,(e=>{xt._lock||(wt(e),Qn(de.indexOf(t),ni,!0,Pi.setSeries))}),!1)),rl){let e=z("td","u-value",o);e.textContent="--",i.push(e)}return[o,i]}(t,n);ul.splice(n,0,i[0]),al.splice(n,0,i[1]),Qe.values.push(null)}if(xt.show){Xe.splice(n,0,null);let e=null;kt?0==n&&(e=Et(t,n)):n>0&&(e=Et(t,n)),yt.splice(n,0,e),Mt.splice(n,0,0),St.splice(n,0,0)}zi("addSeries",n)}k.addSeries=function(e,l){l=null==l?de.length:l,e=1==M?It(e,l,Ol,nt):It(e,l,{},tt),de.splice(l,0,e),Tt(de[l],l)},k.delSeries=function(e){if(de.splice(e,1),el){Qe.values.splice(e,1),al.splice(e,1);let l=ul.splice(e,1)[0];Sl(null,l.firstChild),l.remove()}xt.show&&(Xe.splice(e,1),yt.splice(e,1)[0].remove(),Mt.splice(e,1),St.splice(e,1)),zi("delSeries",e)};const zt=[!1,!1,!1,!1];function Dt(e,l,t){let[n,i,o,s]=t,r=l%2,u=0;return 0==r&&(s||i)&&(u=0==l&&!n||2==l&&!o?ne(Il.size/3):0),1==r&&(n||o)&&(u=1==l&&!i||3==l&&!s?ne(Ql.size/2):0),u}const Pt=k.padding=(u.padding||[Dt,Dt,Dt,Dt]).map((e=>me(q(e,Dt)))),At=k._padding=Pt.map(((e,l)=>e(k,l,zt,0)));let Wt,Yt=null,Ft=null;const Kt=1==M?de[0].idxs:null;let Xt,Zt,Qt,en,ln,tn,nn,on,sn,rn,un=null,an=!1;function fn(e,l){if(k.data=k._data=g=null==e?[]:e,2==M){Wt=0;for(let e=1;de.length>e;e++)Wt+=g[e][0].length}else{0==g.length&&(k.data=k._data=g=[[]]),un=g[0],Wt=un.length;let e=g;if(2==Ie){e=g.slice();let l=e[0]=Array(Wt);for(let e=0;Wt>e;e++)l[e]=e}k._data=g=e}if(Sn(!0),zi("setData"),2==Ie&&(rt=!0),!1!==l){let e=Ge;e.auto(k,an)?cn():Zn(Me,e.min,e.max),at=at||xt.left>=0,ht=!0,Nn()}}function cn(){let e,l;an=!0,1==M&&(Wt>0?(Yt=Kt[0]=0,Ft=Kt[1]=Wt-1,e=g[0][Yt],l=g[0][Ft],2==Ie?(e=Yt,l=Ft):e==l&&(3==Ie?[e,l]=N(e,e,Ge.log,!1):4==Ie?[e,l]=j(e,e,Ge.log,!1):Ge.time?l=e+ne(86400/fe):[e,l]=J(e,l,U,!0))):(Yt=Kt[0]=e=null,Ft=Kt[1]=l=null)),Zn(Me,e,l)}function hn(e,l,t,n,i,o){e??=a,t??=Ae,n??="butt",i??=a,o??="round",e!=Xt&&($.strokeStyle=Xt=e),i!=Zt&&($.fillStyle=Zt=i),l!=Qt&&($.lineWidth=Qt=l),o!=ln&&($.lineJoin=ln=o),n!=tn&&($.lineCap=tn=n),t!=en&&$.setLineDash(en=t)}function dn(e,l,t,n){l!=Zt&&($.fillStyle=Zt=l),e!=nn&&($.font=nn=e),t!=on&&($.textAlign=on=t),n!=sn&&($.textBaseline=sn=n)}function pn(e,l,t,n,i=0){if(n.length>0&&e.auto(k,an)&&(null==l||null==l.min)){let l=q(Yt,0),o=q(Ft,n.length-1),s=null==t.min?3==e.distr?function(e,l,t){let n=he,i=-he;for(let o=l;t>=o;o++){let l=e[o];null!=l&&l>0&&(n>l&&(n=l),l>i&&(i=l))}return[n,i]}(n,l,o):function(e,l,t,n){let i=he,o=-he;if(1==n)i=e[l],o=e[t];else if(-1==n)i=e[t],o=e[l];else for(let n=l;t>=n;n++){let l=e[n];null!=l&&(i>l&&(i=l),l>o&&(o=l))}return[i,o]}(n,l,o,i):[t.min,t.max];e.min=oe(e.min,t.min=s[0]),e.max=se(e.max,t.max=s[1])}}k.setData=fn;const mn={min:null,max:null};function gn(e,l){let t=l?de[e].points:de[e];t._stroke=t.stroke(k,e),t._fill=t.fill(k,e)}function xn(e,l){let t=l?de[e].points:de[e],{stroke:n,fill:i,clip:o,flags:s,_stroke:r=t._stroke,_fill:u=t._fill,_width:a=t.width}=t._paths;a=Ee(a*y,3);let f=null,c=a%2/2;l&&null==u&&(u=a>0?"#fff":r);let h=1==t.pxAlign&&c>0;if(h&&$.translate(c,c),!l){let e=Vl-a/2,l=$l-a/2,t=Jl+a,n=ql+a;f=new Path2D,f.rect(e,l,t,n)}l?_n(r,a,t.dash,t.cap,u,n,i,s,o):function(e,l,t,n,i,o,s,r,u,a,f){let c=!1;0!=u&&ke.forEach(((h,d)=>{if(h.series[0]==e){let e,p=de[h.series[1]],m=g[h.series[1]],x=(p._paths||Pe).band;Ye(x)&&(x=1==h.dir?x[0]:x[1]);let w=null;p.show&&x&&function(e,l,t){for(l=q(l,0),t=q(t,e.length-1);t>=l;){if(null!=e[l])return!0;l++}return!1}(m,Yt,Ft)?(w=h.fill(k,d)||o,e=p._paths.clip):x=null,_n(l,t,n,i,w,s,r,u,a,f,e,x),c=!0}})),c||_n(l,t,n,i,o,s,r,u,a,f)}(e,r,a,t.dash,t.cap,u,n,i,s,f,o),h&&$.translate(-c,-c)}const wn=3;function _n(e,l,t,n,i,o,s,r,u,a,f,c){hn(e,l,t,n,i),(u||a||c)&&($.save(),u&&$.clip(u),a&&$.clip(a)),c?(r&wn)==wn?($.clip(c),f&&$.clip(f),vn(i,s),bn(e,o,l)):2&r?(vn(i,s),$.clip(c),bn(e,o,l)):1&r&&($.save(),$.clip(c),f&&$.clip(f),vn(i,s),$.restore(),bn(e,o,l)):(vn(i,s),bn(e,o,l)),(u||a||c)&&$.restore()}function bn(e,l,t){t>0&&(l instanceof Map?l.forEach(((e,l)=>{$.strokeStyle=Xt=l,$.stroke(e)})):null!=l&&e&&$.stroke(l))}function vn(e,l){l instanceof Map?l.forEach(((e,l)=>{$.fillStyle=Zt=l,$.fill(e)})):null!=l&&e&&$.fill(l)}function kn(e,l,t,n,i,o,s,r,u,a){let f=s%2/2;1==te&&$.translate(f,f),hn(r,s,u,a,r),$.beginPath();let c,h,d,p,m=i+(0==n||3==n?-o:o);0==t?(h=i,p=m):(c=i,d=m);for(let n=0;e.length>n;n++)null!=l[n]&&(0==t?c=d=e[n]:h=p=e[n],$.moveTo(c,h),$.lineTo(d,p));$.stroke(),1==te&&$.translate(-f,-f)}function yn(e){let l=!0;return ge.forEach(((t,n)=>{if(!t.show)return;let i=ve[t.scale];if(null==i.min)return void(t._show&&(l=!1,t._show=!1,Sn(!1)));t._show||(l=!1,t._show=!0,Sn(!1));let o=t.side,s=o%2,{min:r,max:u}=i,[a,f]=function(e,l,t,n){let i,o=ge[e];if(n>0){let s=o._space=o.space(k,e,l,t,n);i=$t(l,t,o._incrs=o.incrs(k,e,l,t,n,s),n,s)}else i=[0,0];return o._found=i}(n,r,u,0==s?Al:Yl);if(0==f)return;let c=t._splits=t.splits(k,n,r,u,a,f,2==i.distr),h=2==i.distr?c.map((e=>un[e])):c,d=2==i.distr?un[c[1]]-un[c[0]]:a,p=t._values=t.values(k,t.filter(k,h,n,f,d),n,f,d);t._rotate=2==o?t.rotate(k,p,n,f):0;let m=t._size;t._size=ie(t.size(k,p,n,e)),null!=m&&t._size!=m&&(l=!1)})),l}function Mn(e){let l=!0;return Pt.forEach(((t,n)=>{let i=t(k,n,zt,e);i!=At[n]&&(l=!1),At[n]=i})),l}function Sn(e){de.forEach(((l,t)=>{t>0&&(l._paths=null,e&&(1==M?(l.min=null,l.max=null):l.facets.forEach((e=>{e.min=null,e.max=null}))))}))}let En,Tn,zn,Dn,Pn,An,Wn,Yn,Cn,Fn,Hn,Rn,Gn=!1,In=!1,On=[];function Ln(){In=!1;for(let e=0;On.length>e;e++)zi(...On[e]);On.length=0}function Nn(){Gn||(je(jn),Gn=!0)}function jn(){if(et&&(function(){for(let e in ve){let l=ve[e];null==Be[e]&&(null==l.min||null!=Be[Me]&&l.auto(k,an))&&(Be[e]=mn)}for(let e in ve){let l=ve[e];null==Be[e]&&null!=l.from&&null!=Be[l.from]&&(Be[e]=mn)}null!=Be[Me]&&Sn(!0);let e={};for(let l in Be){let t=Be[l];if(null!=t){let n=e[l]=Oe(ve[l],Re);if(null!=t.min)Le(n,t);else if(l!=Me||2==M)if(0==Wt&&null==n.from){let e=n.range(k,null,null,l);n.min=e[0],n.max=e[1]}else n.min=he,n.max=-he}}if(Wt>0){de.forEach(((l,t)=>{if(1==M){let n=l.scale,i=Be[n];if(null==i)return;let o=e[n];if(0==t){let e=o.range(k,o.min,o.max,n);o.min=e[0],o.max=e[1],Yt=O(o.min,g[0]),Ft=O(o.max,g[0]),Ft-Yt>1&&(o.min>g[0][Yt]&&Yt++,g[0][Ft]>o.max&&Ft--),l.min=un[Yt],l.max=un[Ft]}else l.show&&l.auto&&pn(o,i,l,g[t],l.sorted);l.idxs[0]=Yt,l.idxs[1]=Ft}else if(t>0&&l.show&&l.auto){let[n,i]=l.facets,o=n.scale,s=i.scale,[r,u]=g[t],a=e[o],f=e[s];null!=a&&pn(a,Be[o],n,r,n.sorted),null!=f&&pn(f,Be[s],i,u,i.sorted),l.min=i.min,l.max=i.max}}));for(let l in e){let t=e[l],n=Be[l];if(null==t.from&&(null==n||null==n.min)){let e=t.range(k,t.min==he?null:t.min,t.max==-he?null:t.max,l);t.min=e[0],t.max=e[1]}}}for(let l in e){let t=e[l];if(null!=t.from){let n=e[t.from];if(null==n.min)t.min=t.max=null;else{let e=t.range(k,n.min,n.max,l);t.min=e[0],t.max=e[1]}}}let l={},t=!1;for(let n in e){let i=e[n],o=ve[n];if(o.min!=i.min||o.max!=i.max){o.min=i.min,o.max=i.max;let e=o.distr;o._min=3==e?ae(o.min):4==e?ce(o.min,o.asinh):100==e?o.fwd(o.min):o.min,o._max=3==e?ae(o.max):4==e?ce(o.max,o.asinh):100==e?o.fwd(o.max):o.max,l[n]=t=!0}}if(t){de.forEach(((e,t)=>{2==M?t>0&&l.y&&(e._paths=null):l[e.scale]&&(e._paths=null)}));for(let e in l)rt=!0,zi("setScale",e);xt.show&&xt.left>=0&&(at=ht=!0)}for(let e in Be)Be[e]=null}(),et=!1),rt&&(function(){let e=!1,l=0;for(;!e;){l++;let t=yn(l),n=Mn(l);e=l==gt||t&&n,e||(pt(k.width,k.height),lt=!0)}}(),rt=!1),lt){if(T(X,s,Cl),T(X,i,Fl),T(X,t,Al),T(X,n,Yl),T(Z,s,Cl),T(Z,i,Fl),T(Z,t,Al),T(Z,n,Yl),T(K,t,Dl),T(K,n,Pl),V.width=ne(Dl*y),V.height=ne(Pl*y),ge.forEach((({_el:l,_show:t,_size:n,_pos:i,side:o})=>{if(null!=l)if(t){let t=o%2==1;T(l,t?"left":"top",i-(3===o||0===o?n:0)),T(l,t?"width":"height",n),T(l,t?"top":"left",t?Fl:Cl),T(l,t?"height":"width",t?Yl:Al),E(l,e)}else S(l,e)})),Xt=Zt=Qt=ln=tn=nn=on=sn=en=null,rn=1,di(!0),Cl!=Hl||Fl!=Rl||Al!=Gl||Yl!=Bl){Sn(!1);let e=Al/Gl,l=Yl/Bl;if(xt.show&&!at&&xt.left>=0){xt.left*=e,xt.top*=l,zn&&A(zn,ne(xt.left),0,Al,Yl),Dn&&A(Dn,0,ne(xt.top),Al,Yl);for(let t=0;yt.length>t;t++){let n=yt[t];null!=n&&(Mt[t]*=e,St[t]*=l,A(n,ie(Mt[t]),ie(St[t]),Al,Yl))}}if(qn.show&&!ft&&qn.left>=0&&qn.width>0){qn.left*=e,qn.width*=e,qn.top*=l,qn.height*=l;for(let e in gi)T(Kn,e,qn[e])}Hl=Cl,Rl=Fl,Gl=Al,Bl=Yl}zi("setSize"),lt=!1}Dl>0&&Pl>0&&($.clearRect(0,0,V.width,V.height),zi("drawClear"),De.forEach((e=>e())),zi("draw")),qn.show&&ft&&(Xn(qn),ft=!1),xt.show&&at&&(ci(null,!0,!1),at=!1),Qe.show&&Qe.live&&ht&&(ai(),ht=!1),R||(R=!0,k.status=1,zi("ready")),an=!1,Gn=!1}function Un(e,l){let t=ve[e];if(null==t.from){if(0==Wt){let n=t.range(k,l.min,l.max,e);l.min=n[0],l.max=n[1]}if(l.min>l.max){let e=l.min;l.min=l.max,l.max=e}if(Wt>1&&null!=l.min&&null!=l.max&&1e-16>l.max-l.min)return;e==Me&&2==t.distr&&Wt>0&&(l.min=O(l.min,g[0]),l.max=O(l.max,g[0]),l.min==l.max&&l.max++),Be[e]=l,et=!0,Nn()}}k.batch=function(e,l=!1){Gn=!0,In=l,e(k),jn(),l&&On.length>0&&queueMicrotask(Ln)},k.redraw=(e,l)=>{rt=l||!1,!1!==e?Zn(Me,Ge.min,Ge.max):Nn()},k.setScale=Un;let Bn=!1;const Vn=xt.drag;let $n=Vn.x,Jn=Vn.y;xt.show&&(xt.x&&(En=D("u-cursor-x",Z)),xt.y&&(Tn=D("u-cursor-y",Z)),0==Ge.ori?(zn=En,Dn=Tn):(zn=Tn,Dn=En),Hn=xt.left,Rn=xt.top);const qn=k.select=Le({show:!0,over:!0,left:0,width:0,top:0,height:0},u.select),Kn=qn.show?D("u-select",qn.over?Z:X):null;function Xn(e,l){if(qn.show){for(let l in e)qn[l]=e[l],l in gi&&T(Kn,l,e[l]);!1!==l&&zi("setSelect")}}function Zn(e,l,t){Un(e,{min:l,max:t})}function Qn(l,t,n,i){null!=t.focus&&function(e){if(e!=ti){let l=null==e,t=1!=bt.alpha;de.forEach(((n,i)=>{if(1==M||i>0){let o=l||0==i||i==e;n._focus=l?null:o,t&&function(e,l){de[e].alpha=l,xt.show&&yt[e]&&(yt[e].style.opacity=l),el&&ul[e]&&(ul[e].style.opacity=l)}(i,o?1:bt.alpha)}})),ti=e,t&&Nn()}}(l),null!=t.show&&de.forEach(((n,i)=>{0>=i||l!=i&&null!=l||(n.show=t.show,function(l){let t=el?ul[l]:null;de[l].show?t&&E(t,e):(t&&S(t,e),A(kt?yt[0]:yt[l],-10,-10,Al,Yl))}(i),2==M?(Zn(n.facets[0].scale,null,null),Zn(n.facets[1].scale,null,null)):Zn(n.scale,null,null),Nn())})),!1!==n&&zi("setSeries",l,t),i&&Yi("setSeries",k,l,t)}let ei,li,ti;k.setSelect=Xn,k.setSeries=Qn,k.addBand=function(e,l){e.fill=me(e.fill||null),e.dir=q(e.dir,-1),ke.splice(l=null==l?ke.length:l,0,e)},k.setBand=function(e,l){Le(ke[e],l)},k.delBand=function(e){null==e?ke.length=0:ke.splice(e,1)};const ni={focus:!0};function ii(e,l,t){let n=ve[l];t&&(e=e/y-(1==n.ori?Fl:Cl));let i=Al;1==n.ori&&(i=Yl,e=i-e),-1==n.dir&&(e=i-e);let o=n._min,s=o+e/i*(n._max-o),r=n.distr;return 3==r?re(10,s):4==r?((e,l=1)=>Q.sinh(e)*l)(s,n.asinh):100==r?n.bwd(s):s}function oi(e,l){T(Kn,s,qn.left=e),T(Kn,t,qn.width=l)}function si(e,l){T(Kn,i,qn.top=e),T(Kn,n,qn.height=l)}el&&vt&&gl(p,tl,(e=>{xt._lock||(wt(e),null!=ti&&Qn(null,ni,!0,Pi.setSeries))})),k.valToIdx=e=>O(e,g[0]),k.posToIdx=function(e,l){return O(ii(e,Me,l),g[0],Yt,Ft)},k.posToVal=ii,k.valToPos=(e,l,t)=>0==ve[l].ori?W(e,ve[l],t?Jl:Al,t?Vl:0):C(e,ve[l],t?ql:Yl,t?$l:0),k.setCursor=(e,l,t)=>{Hn=e.left,Rn=e.top,ci(null,l,t)};let ri=0==Ge.ori?oi:si,ui=1==Ge.ori?oi:si;function ai(e,l){if(null!=e&&(e.idxs?e.idxs.forEach(((e,l)=>{Xe[l]=e})):(e=>void 0===e)(e.idx)||Xe.fill(e.idx),Qe.idx=Xe[0]),el&&Qe.live){for(let e=0;de.length>e;e++)(e>0||1==M&&!fl)&&fi(e,Xe[e]);!function(){if(el&&Qe.live)for(let e=2==M?1:0;de.length>e;e++){if(0==e&&fl)continue;let l=Qe.values[e],t=0;for(let n in l)al[e][t++].firstChild.nodeValue=l[n]}}()}ht=!1,!1!==l&&zi("setLegend")}function fi(e,l){let t,n=de[e],i=0==e&&2==Ie?un:g[e];fl?t=n.values(k,e,l)??cl:(t=n.value(k,null==l?null:i[l],e,l),t=null==t?cl:{_:t}),Qe.values[e]=t}function ci(e,l,t){let n;Cn=Hn,Fn=Rn,[Hn,Rn]=xt.move(k,Hn,Rn),xt.left=Hn,xt.top=Rn,xt.show&&(zn&&A(zn,ne(Hn),0,Al,Yl),Dn&&A(Dn,0,ne(Rn),Al,Yl)),ei=he,li=null;let i=0==Ge.ori?Al:Yl,o=1==Ge.ori?Al:Yl;if(0>Hn||0==Wt||Yt>Ft){n=xt.idx=null;for(let e=0;de.length>e;e++){let l=yt[e];null!=l&&A(l,-10,-10,Al,Yl)}vt&&Qn(null,ni,!0,null==e&&Pi.setSeries),Qe.live&&(Xe.fill(n),ht=!0)}else{let e,l,t;1==M&&(e=0==Ge.ori?Hn:Rn,l=ii(e,Me),n=xt.idx=O(l,g[0],Yt,Ft),t=Ne(g[0][n],Ge,i,0));let s=-10,r=-10,u=0,a=0,f=!0,c="",h="";for(let e=2==M?1:0;de.length>e;e++){let d=de[e],p=Xe[e],m=null==p?null:1==M?g[e][p]:g[e][1][p],x=xt.dataIdx(k,e,n,l),w=null==x?null:1==M?g[e][x]:g[e][1][x];ht=ht||w!=m||x!=p,Xe[e]=x;let _=x==n?t:Ne(1==M?g[0][x]:g[e][0][x],Ge,i,0);if(e>0&&d.show){let l=null==w?-10:Ue(w,1==M?ve[d.scale]:ve[d.facets[1].scale],o,0);if(vt&&null!=w){let t=1==Ge.ori?Hn:Rn,n=le(bt.dist(k,e,x,l,t));if(ei>n){let l=bt.bias;if(0!=l){let i=ii(t,d.scale),o=0>i?-1:1;o!=(0>w?-1:1)||(1==o?1==l?i>w:w>i:1==l?w>i:i>w)||(ei=n,li=e)}else ei=n,li=e}}if(ht||kt){let t,n;0==Ge.ori?(t=_,n=l):(t=l,n=_);let i,o,d,p,m,g,x=!0,w=_t.bbox;if(null!=w){x=!1;let l=w(k,e);d=l.left,p=l.top,i=l.width,o=l.height}else d=t,p=n,i=o=_t.size(k,e);if(g=_t.fill(k,e),m=_t.stroke(k,e),kt)e!=li||ei>bt.prox||(s=d,r=p,u=i,a=o,f=x,c=g,h=m);else{let l=yt[e];null!=l&&(Mt[e]=d,St[e]=p,F(l,i,o,x),Y(l,g,m),A(l,ie(d),ie(p),Al,Yl))}}}}if(kt){let e=bt.prox;if(ht||(null==ti?e>=ei:ei>e||li!=ti)){let e=yt[0];Mt[0]=s,St[0]=r,F(e,u,a,f),Y(e,c,h),A(e,ie(s),ie(r),Al,Yl)}}}if(qn.show&&Bn)if(null!=e){let[l,t]=Pi.scales,[n,s]=Pi.match,[r,u]=e.cursor.sync.scales,a=e.cursor.drag;if($n=a._x,Jn=a._y,$n||Jn){let a,f,c,h,d,{left:p,top:m,width:g,height:x}=e.select,w=e.scales[r].ori,_=e.posToVal,b=null!=l&&n(l,r),v=null!=t&&s(t,u);b&&$n?(0==w?(a=p,f=g):(a=m,f=x),c=ve[l],h=Ne(_(a,r),c,i,0),d=Ne(_(a+f,r),c,i,0),ri(oe(h,d),le(d-h))):ri(0,i),v&&Jn?(1==w?(a=p,f=g):(a=m,f=x),c=ve[t],h=Ue(_(a,u),c,o,0),d=Ue(_(a+f,u),c,o,0),ui(oe(h,d),le(d-h))):ui(0,o)}else xi()}else{let e=le(Cn-Pn),l=le(Fn-An);if(1==Ge.ori){let t=e;e=l,l=t}$n=Vn.x&&e>=Vn.dist,Jn=Vn.y&&l>=Vn.dist;let t,n,s=Vn.uni;null!=s?$n&&Jn&&($n=e>=s,Jn=l>=s,$n||Jn||(l>e?Jn=!0:$n=!0)):Vn.x&&Vn.y&&($n||Jn)&&($n=Jn=!0),$n&&(0==Ge.ori?(t=Wn,n=Hn):(t=Yn,n=Rn),ri(oe(t,n),le(n-t)),Jn||ui(0,o)),Jn&&(1==Ge.ori?(t=Wn,n=Hn):(t=Yn,n=Rn),ui(oe(t,n),le(n-t)),$n||ri(0,i)),$n||Jn||(ri(0,0),ui(0,0))}if(Vn._x=$n,Vn._y=Jn,null==e){if(t){if(null!=Ai){let[e,l]=Pi.scales;Pi.values[0]=null!=e?ii(0==Ge.ori?Hn:Rn,e):null,Pi.values[1]=null!=l?ii(1==Ge.ori?Hn:Rn,l):null}Yi(f,k,Hn,Rn,Al,Yl,n)}if(vt){let e=t&&Pi.setSeries,l=bt.prox;null==ti?ei>l||Qn(li,ni,!0,e):ei>l?Qn(null,ni,!0,e):li!=ti&&Qn(li,ni,!0,e)}}ht&&(Qe.idx=n,ai()),!1!==l&&zi("setCursor")}k.setLegend=ai;let hi=null;function di(e=!1){e?hi=null:(hi=Z.getBoundingClientRect(),zi("syncRect",hi))}function pi(e,l,t,n,i,o){xt._lock||Bn&&null!=e&&0==e.movementX&&0==e.movementY||(mi(e,l,t,n,i,o,0,!1,null!=e),null!=e?ci(null,!0,!0):ci(l,!0,!1))}function mi(e,l,t,n,i,o,s,r,u){if(null==hi&&di(!1),wt(e),null!=e)t=e.clientX-hi.left,n=e.clientY-hi.top;else{if(0>t||0>n)return Hn=-10,void(Rn=-10);let[e,s]=Pi.scales,r=l.cursor.sync,[u,a]=r.values,[f,c]=r.scales,[h,d]=Pi.match,p=l.axes[0].side%2==1,m=0==Ge.ori?Al:Yl,g=1==Ge.ori?Al:Yl,x=p?o:i,w=p?i:o,_=p?n:t,b=p?t:n;if(t=null!=f?h(e,f)?H(u,ve[e],m,0):-10:m*(_/x),n=null!=c?d(s,c)?H(a,ve[s],g,0):-10:g*(b/w),1==Ge.ori){let e=t;t=n,n=e}}u&&(t>1&&Al-1>t||(t=ye(t,Al)),n>1&&Yl-1>n||(n=ye(n,Yl))),r?(Pn=t,An=n,[Wn,Yn]=xt.move(k,t,n)):(Hn=t,Rn=n)}Object.defineProperty(k,"rect",{get:()=>(null==hi&&di(!1),hi)});const gi={width:0,height:0,left:0,top:0};function xi(){Xn(gi,!1)}let wi,_i,bi,vi;function ki(e,l,t,n,i,o){Bn=!0,$n=Jn=Vn._x=Vn._y=!1,mi(e,l,t,n,i,o,0,!0,!1),null!=e&&(gl(h,b,yi,!1),Yi(c,k,Wn,Yn,Al,Yl,null));let{left:s,top:r,width:u,height:a}=qn;wi=s,_i=r,bi=u,vi=a,xi()}function yi(e,l,t,n,i,o){Bn=Vn._x=Vn._y=!1,mi(e,l,t,n,i,o,0,!1,!0);let{left:s,top:r,width:u,height:a}=qn,f=u>0||a>0,c=wi!=s||_i!=r||bi!=u||vi!=a;if(f&&c&&Xn(qn),Vn.setScale&&f&&c){let e=s,l=u,t=r,n=a;if(1==Ge.ori&&(e=r,l=a,t=s,n=u),$n&&Zn(Me,ii(e,Me),ii(e+l,Me)),Jn)for(let e in ve){let l=ve[e];e!=Me&&null==l.from&&l.min!=he&&Zn(e,ii(t+n,e),ii(t,e))}xi()}else xt.lock&&(xt._lock=!xt._lock,ci(null,!0,!1));null!=e&&(Sl(h,b),Yi(h,k,Hn,Rn,Al,Yl,null))}function Mi(e){xt._lock||(wt(e),cn(),xi(),null!=e&&Yi(m,k,Hn,Rn,Al,Yl,null))}function Si(){ge.forEach(qt),dt(k.width,k.height,!0)}G(x,v,Si);const Ei={};Ei.mousedown=ki,Ei.mousemove=pi,Ei.mouseup=yi,Ei.dblclick=Mi,Ei.setSeries=(e,l,t,n)=>{-1!=(t=(0,Pi.match[2])(k,l,t))&&Qn(t,n,!0,!1)},xt.show&&(gl(c,Z,ki),gl(f,Z,pi),gl(d,Z,(e=>{wt(e),di(!1)})),gl(p,Z,(function(e){if(xt._lock)return;wt(e);let l=Bn;if(Bn){let e,l,t=!0,n=!0,i=10;0==Ge.ori?(e=$n,l=Jn):(e=Jn,l=$n),e&&l&&(t=i>=Hn||Hn>=Al-i,n=i>=Rn||Rn>=Yl-i),e&&t&&(Hn=Wn>Hn?0:Al),l&&n&&(Rn=Yn>Rn?0:Yl),ci(null,!0,!0),Bn=!1}Hn=-10,Rn=-10,ci(null,!0,!0),l&&(Bn=l)})),gl(m,Z,Mi),Ct.add(k),k.syncRect=di);const Ti=k.hooks=u.hooks||{};function zi(e,l,t){In?On.push([e,l,t]):e in Ti&&Ti[e].forEach((e=>{e.call(null,k,l,t)}))}(u.plugins||[]).forEach((e=>{for(let l in e.hooks)Ti[l]=(Ti[l]||[]).concat(e.hooks[l])}));const Di=(e,l,t)=>t,Pi=Le({key:null,setSeries:!1,filters:{pub:_e,sub:_e},scales:[Me,de[1]?de[1].scale:null],match:[be,be,Di],values:[null,null]},xt.sync);2==Pi.match.length&&Pi.match.push(Di),xt.sync=Pi;const Ai=Pi.key,Wi=ut(Ai);function Yi(e,l,t,n,i,o,s){Pi.filters.pub(e,l,t,n,i,o,s)&&Wi.pub(e,l,t,n,i,o,s)}function Ci(){zi("init",u,g),fn(g||u.data,!1),Be[Me]?Un(Me,Be[Me]):cn(),ft=qn.show&&(qn.width>0||qn.height>0),at=ht=!0,dt(u.width,u.height)}return Wi.sub(k),k.pub=function(e,l,t,n,i,o,s){Pi.filters.sub(e,l,t,n,i,o,s)&&Ei[e](null,l,t,n,i,o,s)},k.destroy=function(){Wi.unsub(k),Ct.delete(k),ml.clear(),I(x,v,Si),L.remove(),tl?.remove(),zi("destroy")},de.forEach(Tt),ge.forEach((function(e,l){if(e._show=e.show,e.show){let t=ve[e.scale];null==t&&(e.scale=e.side%2?de[1].scale:Me,t=ve[e.scale]);let n=t.time;e.size=me(e.size),e.space=me(e.space),e.rotate=me(e.rotate),Ye(e.incrs)&&e.incrs.forEach((e=>{!Te.has(e)&&Te.set(e,ze(e))})),e.incrs=me(e.incrs||(2==t.distr?il:n?1==fe?xl:bl:ol)),e.splits=me(e.splits||(n&&1==t.distr?Je:3==t.distr?jl:4==t.distr?Ul:Nl)),e.stroke=me(e.stroke),e.grid.stroke=me(e.grid.stroke),e.ticks.stroke=me(e.ticks.stroke),e.border.stroke=me(e.border.stroke);let i=e.values;e.values=Ye(i)&&!Ye(i[0])?me(i):n?Ye(i)?Ml(Ve,yl(i,$e)):Fe(i)?function(e,l){let t=Ze(l);return(l,n)=>n.map((l=>t(e(l))))}(Ve,i):i||qe:i||Ll,e.filter=me(e.filter||(3>t.distr||10!=t.log?3==t.distr&&2==t.log?Xl:xe:Kl)),e.font=Jt(e.font),e.labelFont=Jt(e.labelFont),e._size=e.size(k,null,l,0),e._space=e._rotate=e._incrs=e._found=e._splits=e._values=null,e._size>0&&(zt[l]=!0,e._el=D("u-axis",K))}})),_?_ instanceof HTMLElement?(_.appendChild(L),Ci()):_(k,Ci):Ci(),k}Kt.assign=Le,Kt.fmtNum=Z,Kt.rangeNum=J,Kt.rangeLog=N,Kt.rangeAsinh=j,Kt.orient=at,Kt.pxRatio=y,Kt.join=function(e,l){if(function(e){let l=e[0][0],t=l.length;for(let n=1;e.length>n;n++){let i=e[n][0];if(i.length!=t)return!1;if(i!=l)for(let e=0;t>e;e++)if(i[e]!=l[e])return!1}return!0}(e)){let l=e[0].slice();for(let t=1;e.length>t;t++)l.push(...e[t].slice(1));return function(e,l=100){const t=e.length;if(1>=t)return!0;let n=0,i=t-1;for(;i>=n&&null==e[n];)n++;for(;i>=n&&null==e[i];)i--;if(n>=i)return!0;const o=se(1,te((i-n+1)/l));for(let l=e[n],t=n+o;i>=t;t+=o){const n=e[t];if(null!=n){if(l>=n)return!1;l=n}}return!0}(l[0])||(l=function(e){let l=e[0],t=l.length,n=Array(t);for(let e=0;n.length>e;e++)n[e]=e;n.sort(((e,t)=>l[e]-l[t]));let i=[];for(let l=0;e.length>l;l++){let o=e[l],s=Array(t);for(let e=0;t>e;e++)s[e]=o[n[e]];i.push(s)}return i}(l)),l}let t=new Set;for(let l=0;e.length>l;l++){let n=e[l][0],i=n.length;for(let e=0;i>e;e++)t.add(n[e])}let n=[Array.from(t).sort(((e,l)=>e-l))],i=n[0].length,o=new Map;for(let e=0;i>e;e++)o.set(n[0][e],e);for(let t=0;e.length>t;t++){let s=e[t],r=s[0];for(let e=1;s.length>e;e++){let u=s[e],a=Array(i).fill(void 0),f=l?l[t][e]:1,c=[];for(let e=0;u.length>e;e++){let l=u[e],t=o.get(r[e]);null===l?0!=f&&(a[t]=l,2==f&&c.push(t)):a[t]=l}Ne(a,c,i),n.push(a)}}return n},Kt.fmtDate=Ze,Kt.tzDate=function(e,l){let t;return"UTC"==l||"Etc/UTC"==l?t=new Date(+e+6e4*e.getTimezoneOffset()):l==Qe?t=e:(t=new Date(e.toLocaleString("en-US",{timeZone:l})),t.setMilliseconds(e.getMilliseconds())),t},Kt.sync=ut;{Kt.addGap=function(e,l,t){let n=e[e.length-1];n&&n[0]==l?n[1]=t:e.push([l,t])},Kt.clipGaps=dt;let e=Kt.paths={points:Tt};e.linear=At,e.stepped=function(e){const l=q(e.align,1),t=q(e.ascDesc,!1),n=q(e.alignGaps,0),i=q(e.extend,!1);return(e,o,s,r)=>at(e,o,((u,a,f,c,h,d,p,m,g,x,w)=>{let _=u.pxRound,{left:b,width:v}=e.bbox,k=e=>_(d(e,c,x,m)),M=e=>_(p(e,h,w,g)),S=0==c.ori?_t:bt;const E={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},T=E.stroke,z=c.dir*(0==c.ori?1:-1);s=L(f,s,r,1),r=L(f,s,r,-1);let D=M(f[1==z?s:r]),P=k(a[1==z?s:r]),A=P,W=P;i&&-1==l&&(W=b,S(T,W,D)),S(T,P,D);for(let e=1==z?s:r;e>=s&&r>=e;e+=z){let t=f[e];if(null==t)continue;let n=k(a[e]),i=M(t);1==l?S(T,n,D):S(T,A,i),S(T,n,i),D=i,A=n}let Y=A;i&&1==l&&(Y=b+v,S(T,Y,D));let[C,F]=ft(e,o);if(null!=u.fill||0!=C){let l=E.fill=new Path2D(T),t=M(u.fillTo(e,o,u.min,u.max,C));S(l,Y,t),S(l,W,t)}if(!u.spanGaps){let i=[];i.push(...pt(a,f,s,r,z,k,n));let h=u.width*y/2,d=t||1==l?h:-h,p=t||-1==l?-h:h;i.forEach((e=>{e[0]+=d,e[1]+=p})),E.gaps=i=u.gaps(e,o,s,r,i),E.clip=dt(i,c.ori,m,g,x,w)}return 0!=F&&(E.band=2==F?[ht(e,o,s,r,T,-1),ht(e,o,s,r,T,1)]:ht(e,o,s,r,T,F)),E}))},e.bars=function(e){const l=q((e=e||Pe).size,[.6,he,1]),t=e.align||0,n=e.gap||0;let i=e.radius;i=null==i?[0,0]:"number"==typeof i?[i,0]:i;const o=me(i),s=1-l[0],r=q(l[1],he),u=q(l[2],1),a=q(e.disp,Pe),f=q(e.each,(()=>{})),{fill:c,stroke:h}=a;return(e,l,i,d)=>at(e,l,((p,m,g,x,w,_,b,v,k,M,S)=>{let E,T,z=p.pxRound,D=t,P=n*y,A=r*y,W=u*y;0==x.ori?[E,T]=o(e,l):[T,E]=o(e,l);const Y=x.dir*(0==x.ori?1:-1);let C,F,H,R=0==x.ori?vt:kt,G=0==x.ori?f:(e,l,t,n,i,o,s)=>{f(e,l,t,i,n,s,o)},I=q(e.bands,Ae).find((e=>e.series[0]==l)),O=p.fillTo(e,l,p.min,p.max,null!=I?I.dir:0),L=z(b(O,w,S,k)),N=M,j=z(p.width*y),U=!1,B=null,V=null,$=null,J=null;null==c||0!=j&&null==h||(U=!0,B=c.values(e,l,i,d),V=new Map,new Set(B).forEach((e=>{null!=e&&V.set(e,new Path2D)})),j>0&&($=h.values(e,l,i,d),J=new Map,new Set($).forEach((e=>{null!=e&&J.set(e,new Path2D)}))));let{x0:K,size:X}=a;if(null!=K&&null!=X){D=1,m=K.values(e,l,i,d),2==K.unit&&(m=m.map((l=>e.posToVal(v+l*M,x.key,!0))));let t=X.values(e,l,i,d);F=2==X.unit?t[0]*M:_(t[0],x,M,v)-_(0,x,M,v),N=Wt(m,g,_,x,M,v,N),H=N-F+P}else N=Wt(m,g,_,x,M,v,N),H=N*s+P,F=N-H;1>H&&(H=0),F/2>j||(j=0),5>H&&(z=ge);let Z=H>0;F=z(pe(N-H-(Z?j:0),W,A)),C=(0==D?F/2:D==Y?0:F)-D*Y*((0==D?P/2:0)+(Z?j/2:0));const Q={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},ee=U?null:new Path2D;let le=null;if(null!=I)le=e.data[I.series[1]];else{let{y0:t,y1:n}=a;null!=t&&null!=n&&(g=n.values(e,l,i,d),le=t.values(e,l,i,d))}let ne=E*F,ie=T*F;for(let t=1==Y?i:d;t>=i&&d>=t;t+=Y){let n=g[t];if(null==n)continue;if(null!=le){let e=le[t]??0;if(n-e==0)continue;L=b(e,w,S,k)}let i=_(2!=x.distr||null!=a?m[t]:t,x,M,v),o=b(q(n,O),w,S,k),s=z(i-C),r=z(se(o,L)),u=z(oe(o,L)),f=r-u;if(null!=n){let i=0>n?ie:ne,o=0>n?ne:ie;U?(j>0&&null!=$[t]&&R(J.get($[t]),s,u+te(j/2),F,se(0,f-j),i,o),null!=B[t]&&R(V.get(B[t]),s,u+te(j/2),F,se(0,f-j),i,o)):R(ee,s,u+te(j/2),F,se(0,f-j),i,o),G(e,l,t,s-j/2,u,F+j,f)}}return j>0?Q.stroke=U?J:ee:U||(Q._fill=0==p.width?p._fill:p._stroke??p._fill,Q.width=0),Q.fill=U?V:ee,Q}))},e.spline=function(e){return function(e,l){const t=q(l?.alignGaps,0);return(l,n,i,o)=>at(l,n,((s,r,u,a,f,c,h,d,p,m,g)=>{let x,w,_,b=s.pxRound,v=e=>b(c(e,a,m,d)),k=e=>b(h(e,f,g,p));0==a.ori?(x=xt,_=_t,w=St):(x=wt,_=bt,w=Et);const y=a.dir*(0==a.ori?1:-1);i=L(u,i,o,1),o=L(u,i,o,-1);let M=v(r[1==y?i:o]),S=M,E=[],T=[];for(let e=1==y?i:o;e>=i&&o>=e;e+=y)if(null!=u[e]){let l=v(r[e]);E.push(S=l),T.push(k(u[e]))}const z={stroke:e(E,T,x,_,w,b),fill:null,clip:null,band:null,gaps:null,flags:1},D=z.stroke;let[P,A]=ft(l,n);if(null!=s.fill||0!=P){let e=z.fill=new Path2D(D),t=k(s.fillTo(l,n,s.min,s.max,P));_(e,S,t),_(e,M,t)}if(!s.spanGaps){let e=[];e.push(...pt(r,u,i,o,y,v,t)),z.gaps=e=s.gaps(l,n,i,o,e),z.clip=dt(e,a.ori,d,p,m,g)}return 0!=A&&(z.band=2==A?[ht(l,n,i,o,D,-1),ht(l,n,i,o,D,1)]:ht(l,n,i,o,D,A)),z}))}(Yt,e)}}return Kt}(); +var uPlot=function(){"use strict";const l=(new Intl.DateTimeFormat).resolvedOptions().locale;function e(l,e,t,n){let i;t=t||0;let o=2147483647>=(n=n||e.length-1);for(;n-t>1;)i=o?t+n>>1:m((t+n)/2),l>e[i]?t=i:n=i;return l-e[t]>e[n]-l?n:t}function t(l,e,t,n){for(let i=1==n?e:t;i>=e&&t>=i;i+=n)if(null!=l[i])return i;return-1}function n(l,e,t,n){let i=k(l),o=k(e);l==e&&(-1==i?(l*=t,e/=t):(l/=t,e*=t));let s=10==t?b:y,r=1==o?x:m,u=(1==i?m:x)(s(p(l))),a=r(s(p(e))),f=v(t,u),c=v(t,a);return 10==t&&(0>u&&(f=N(f,-u)),0>a&&(c=N(c,-a))),n||2==t?(l=f*i,e=c*o):(l=L(l,f),e=O(e,c)),[l,e]}function i(l,e,t,i){let o=n(l,e,t,i);return 0==l&&(o[0]=0),0==e&&(o[1]=0),o}const o=.1,s={mode:3,pad:o},r={pad:0,soft:null,mode:0},u={min:r,max:r};function a(l,e,t,n){return K(t)?c(l,e,t):(r.pad=t,r.soft=n?0:null,r.mode=n?3:0,c(l,e,u))}function f(l,e){return null==l?e:l}function c(l,e,t){let n=t.min,i=t.max,o=f(n.pad,0),s=f(i.pad,0),r=f(n.hard,-E),u=f(i.hard,E),a=f(n.soft,E),c=f(i.soft,-E),h=f(n.mode,0),d=f(i.mode,0),g=e-l,x=b(g),k=_(p(l),p(e)),y=b(k),S=p(y-x);(1e-9>g||S>10)&&(g=0,0!=l&&0!=e||(g=1e-9,2==h&&a!=E&&(o=0),2==d&&c!=-E&&(s=0)));let T=g||k||1e3,z=b(T),D=v(10,m(z)),P=N(L(l-T*(0==g?0==l?.1:1:o),D/10),9),A=a>l||1!=h&&(3!=h||P>a)&&(2!=h||a>P)?E:a,M=_(r,A>P&&l>=A?A:w(A,P)),C=N(O(e+T*(0==g?0==e?.1:1:s),D/10),9),I=e>c||1!=d&&(3!=d||c>C)&&(2!=d||C>c)?-E:c,R=w(u,C>I&&I>=e?I:_(I,C));return M==R&&0==M&&(R=100),[M,R]}const h=Math,d=h.PI,p=h.abs,m=h.floor,g=h.round,x=h.ceil,w=h.min,_=h.max,v=h.pow,k=h.sign,b=h.log10,y=h.log2,S=(l,e=1)=>h.asinh(l/e),E=1/0;function T(l){return 1+(0|b((l^l>>31)-(l>>31)))}function z(l,e,t){return w(_(l,e),t)}function D(l){return"function"==typeof l?l:()=>l}const P=l=>l,A=(l,e)=>e,M=()=>null,C=()=>!0,I=(l,e)=>l==e,R=/\.\d*?(?=9{6,}|0{6,})/gm,F=l=>{if(W(l)||Y.has(l))return l;const e=""+l,t=e.match(R);if(null==t)return l;let n=t[0].length-1;if(-1!=e.indexOf("e-")){let[l,t]=e.split("e");return+`${F(l)}e${t}`}return N(l,n)};function G(l,e){return F(N(F(l/e))*e)}function O(l,e){return F(x(F(l/e))*e)}function L(l,e){return F(m(F(l/e))*e)}function N(l,e=0){if(W(l))return l;let t=10**e;return g(l*t*(1+Number.EPSILON))/t}const Y=new Map;function j(l){return((""+l).split(".")[1]||"").length}function B(l,e,t,n){let i=[],o=n.map(j);for(let s=e;t>s;s++){let e=p(s),t=N(v(l,s),e);for(let r=0;n.length>r;r++){let u=10==l?+`${n[r]}e${s}`:n[r]*t,a=(0>s?e:0)+(o[r]>s?o[r]:0),f=10==l?u:N(u,a);i.push(f),Y.set(f,a)}}return i}const H={},U=[],V=[null,null],$=Array.isArray,W=Number.isInteger;function q(l){return"string"==typeof l}function K(l){let e=!1;if(null!=l){let t=l.constructor;e=null==t||t==Object}return e}function X(l){return null!=l&&"object"==typeof l}const Z=Object.getPrototypeOf(Uint8Array),J="__proto__";function Q(l,e=K){let t;if($(l)){let n=l.find((l=>null!=l));if($(n)||e(n)){t=Array(l.length);for(let n=0;l.length>n;n++)t[n]=Q(l[n],e)}else t=l.slice()}else if(l instanceof Z)t=l.slice();else if(e(l)){t={};for(let n in l)n!=J&&(t[n]=Q(l[n],e))}else t=l;return t}function ll(l){let e=arguments;for(let t=1;e.length>t;t++){let n=e[t];for(let e in n)e!=J&&(K(l[e])?ll(l[e],Q(n[e])):l[e]=Q(n[e]))}return l}function el(l,e,t){for(let n,i=0,o=-1;e.length>i;i++){let s=e[i];if(s>o){for(n=s-1;n>=0&&null==l[n];)l[n--]=null;for(n=s+1;t>n&&null==l[n];)l[o=n++]=null}}}const tl="undefined"==typeof queueMicrotask?l=>Promise.resolve().then(l):queueMicrotask,nl="width",il="height",ol="top",sl="bottom",rl="left",ul="right",al="#000",fl=al+"0",cl="mousemove",hl="mousedown",dl="mouseup",pl="mouseenter",ml="mouseleave",gl="dblclick",xl="change",wl="dppxchange",_l="--",vl="u-off",kl="u-label",bl="undefined"!=typeof window,yl=bl?document:null,Sl=bl?window:null;let El,Tl;function zl(l,e){if(null!=e){let t=l.classList;!t.contains(e)&&t.add(e)}}function Dl(l,e){let t=l.classList;t.contains(e)&&t.remove(e)}function Pl(l,e,t){l.style[e]=t+"px"}function Al(l,e,t,n){let i=yl.createElement(l);return null!=e&&zl(i,e),null!=t&&t.insertBefore(i,n),i}function Ml(l,e){return Al("div",l,e)}const Cl=new WeakMap;function Il(l,e,t,n,i){let o="translate("+e+"px,"+t+"px)";o!=Cl.get(l)&&(l.style.transform=o,Cl.set(l,o),0>e||0>t||e>n||t>i?zl(l,vl):Dl(l,vl))}const Rl=new WeakMap;function Fl(l,e,t){let n=e+t;n!=Rl.get(l)&&(Rl.set(l,n),l.style.background=e,l.style.borderColor=t)}const Gl=new WeakMap;function Ol(l,e,t,n){let i=e+""+t;i!=Gl.get(l)&&(Gl.set(l,i),l.style.height=t+"px",l.style.width=e+"px",l.style.marginLeft=n?-e/2+"px":0,l.style.marginTop=n?-t/2+"px":0)}const Ll={passive:!0},Nl={...Ll,capture:!0};function Yl(l,e,t,n){e.addEventListener(l,t,n?Nl:Ll)}function jl(l,e,t){e.removeEventListener(l,t,Ll)}bl&&function l(){let e=devicePixelRatio;El!=e&&(El=e,Tl&&jl(xl,Tl,l),Tl=matchMedia(`(min-resolution: ${El-.001}dppx) and (max-resolution: ${El+.001}dppx)`),Yl(xl,Tl,l),Sl.dispatchEvent(new CustomEvent(wl)))}();const Bl=(new Intl.DateTimeFormat).resolvedOptions().timeZone,Hl=l=>l%1==0,Ul=[1,2,2.5,5],Vl=B(10,-32,0,Ul),$l=B(10,0,32,Ul),Wl=$l.filter(Hl),ql=Vl.concat($l);let Kl={year:"numeric"},Xl={month:"numeric"},Zl={month:"short"},Jl={day:"numeric"},Ql={hour:"numeric"},le={minute:"numeric"},ee={second:"numeric"},te={fractionalSecondDigits:3};const ne=null;function ie(l){let e=1e3*l,t=60*e,n=60*t,i=24*n,o=30*i,s=365*i;return[(1==l?B(10,0,3,Ul).filter(Hl):B(10,-3,0,Ul)).concat([e,5*e,10*e,15*e,30*e,t,5*t,10*t,15*t,30*t,n,2*n,3*n,4*n,6*n,8*n,12*n,i,2*i,3*i,4*i,5*i,6*i,7*i,8*i,9*i,10*i,15*i,o,2*o,3*o,4*o,6*o,s,2*s,5*s,10*s,25*s,50*s,100*s]),[[s,{...Kl},ne,ne,ne,ne,ne,ne,1],[28*i,{...Zl},{...Kl},ne,ne,ne,ne,ne,1],[i,{...Xl,...Jl},{...Kl},ne,ne,ne,ne,ne,1],[n,{...Ql},{...Kl,...Xl,...Jl},ne,{...Xl,...Jl},ne,ne,ne,1],[t,{...Ql,...le},{...Kl,...Xl,...Jl},ne,{...Xl,...Jl},ne,ne,ne,1],[e,{...ee},{...Kl,...Xl,...Jl,...Ql,...le},ne,{...Xl,...Jl,...Ql,...le},ne,{...Ql,...le},ne,1],[l,{...ee,...te},{...Kl,...Xl,...Jl,...Ql,...le},ne,{...Xl,...Jl,...Ql,...le},ne,{...Ql,...le},ne,1]],function(e){return(r,u,a,f,c,h)=>{let d=[],p=c>=s,x=c>=o&&s>c,w=e(a),_=N(w*l,3),v=pe(w.getFullYear(),p?0:w.getMonth(),x||p?1:w.getDate()),k=N(v*l,3);if(x||p){let t=x?c/o:0,n=p?c/s:0,i=_==k?_:N(pe(v.getFullYear()+n,v.getMonth()+t,1)*l,3),r=new Date(g(i/l)),u=r.getFullYear(),a=r.getMonth();for(let o=0;f>=i;o++){let s=pe(u+n*o,a+t*o,1),r=s-e(N(s*l,3));i=N((+s+r)*l,3),i>f||d.push(i)}}else{let o=i>c?c:i,s=k+(m(a)-m(_))+O(_-k,o);d.push(s);let p=e(s),g=p.getHours()+p.getMinutes()/t+p.getSeconds()/n,x=c/n,w=h/r.axes[u]._space;for(;s=N(s+c,1==l?0:3),f>=s;)if(x>1){let l=m(N(g+x,6))%24,t=e(s).getHours()-l;t>1&&(t=-1),s-=t*n,g=(g+x)%24,.7>N((s-d[d.length-1])/c,3)*w||d.push(s)}else d.push(s)}return d}}]}const[oe,se,re]=ie(1),[ue,ae,fe]=ie(.001);function ce(l,e){return l.map((l=>l.map(((t,n)=>0==n||8==n||null==t?t:e(1==n||0==l[8]?t:l[1]+t)))))}function he(l,e){return(t,n,i,o,s)=>{let r,u,a,f,c,h,d=e.find((l=>s>=l[0]))||e[e.length-1];return n.map((e=>{let t=l(e),n=t.getFullYear(),i=t.getMonth(),o=t.getDate(),s=t.getHours(),p=t.getMinutes(),m=t.getSeconds(),g=n!=r&&d[2]||i!=u&&d[3]||o!=a&&d[4]||s!=f&&d[5]||p!=c&&d[6]||m!=h&&d[7]||d[1];return r=n,u=i,a=o,f=s,c=p,h=m,g(t)}))}}function de(l,e){let t=fmtDate(e);return(e,n)=>n.map((e=>t(l(e))))}function pe(l,e,t){return new Date(l,e,t)}function me(l,e){return e(l)}function ge(l,e){return(t,n,i,o)=>null==o?_l:e(l(n))}B(2,-53,53,[1]);const xe={show:!0,live:!0,isolate:!1,mount:()=>{},markers:{show:!0,width:2,stroke:function(l,e){let t=l.series[e];return t.width?t.stroke(l,e):t.points.width?t.points.stroke(l,e):null},fill:function(l,e){return l.series[e].fill(l,e)},dash:"solid"},idx:null,idxs:null,values:[]},we=[0,0];function _e(l,e,t,n=!0){return l=>{0==l.button&&(!n||l.target==e)&&t(l)}}function ve(l,e,t,n=!0){return l=>{(!n||l.target==e)&&t(l)}}const ke={show:!0,x:!0,y:!0,lock:!1,move:function(l,e,t){return we[0]=e,we[1]=t,we},points:{one:!1,show:function(l,e){let t=l.cursor.points,n=Ml(),i=t.size(l,e);Pl(n,nl,i),Pl(n,il,i);let o=i/-2;Pl(n,"marginLeft",o),Pl(n,"marginTop",o);let s=t.width(l,e,i);return s&&Pl(n,"borderWidth",s),n},size:function(l,e){return l.series[e].points.size},width:0,stroke:function(l,e){let t=l.series[e].points;return t._stroke||t._fill},fill:function(l,e){let t=l.series[e].points;return t._fill||t._stroke}},bind:{mousedown:_e,mouseup:_e,click:_e,dblclick:_e,mousemove:ve,mouseleave:ve,mouseenter:ve},drag:{setScale:!0,x:!0,y:!1,dist:0,uni:null,click:(l,e)=>{e.stopPropagation(),e.stopImmediatePropagation()},_x:!1,_y:!1},focus:{dist:(l,e,t,n,i)=>n-i,prox:-1,bias:0},hover:{skip:[void 0],prox:null,bias:0},left:-10,top:-10,idx:null,dataIdx:null,idxs:null,event:null},be={show:!0,stroke:"rgba(0,0,0,0.07)",width:2},ye=ll({},be,{filter:A}),Se=ll({},ye,{size:10}),Ee=ll({},be,{show:!1}),Te='12px system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"',ze="bold "+Te,De={show:!0,scale:"x",stroke:al,space:50,gap:5,size:50,labelGap:0,labelSize:30,labelFont:ze,side:2,grid:ye,ticks:Se,border:Ee,font:Te,lineGap:1.5,rotate:0},Pe={show:!0,scale:"x",auto:!1,sorted:1,min:E,max:-E,idxs:[]};function Ae(l,e,t,n,i,o){return e.map((l=>null==l?"":o(l)))}function Me(l,e,t,n,i,o,s){let r=[],u=Y.get(i)||0;for(let l=t=s?t:N(O(t,i),u);n>=l;l=N(l+i,u))r.push(Object.is(l,-0)?0:l);return r}function Ce(l,t,n,i,o){const s=[],r=l.scales[l.axes[t].scale].log,u=m((10==r?b:y)(n));o=v(r,u),10==r&&(o=ql[e(o,ql)]);let a=n,f=o*r;10==r&&(f=ql[e(f,ql)]);do{s.push(a),a+=o,10!=r||Y.has(a)||(a=N(a,Y.get(o))),f>a||(f=(o=a)*r,10==r&&(f=ql[e(f,ql)]))}while(i>=a);return s}function Ie(l,e,t,n,i){let o=l.scales[l.axes[e].scale].asinh,s=n>o?Ce(l,e,_(o,t),n,i):[o],r=0>n||t>0?[]:[0];return(-o>t?Ce(l,e,_(o,-n),-t,i):[o]).reverse().map((l=>-l)).concat(r,s)}const Re=/./,Fe=/[12357]/,Ge=/[125]/,Oe=/1/,Le=(l,e,t,n)=>l.map(((l,i)=>4==e&&0==l||i%n==0&&t.test(l.toExponential()[0>l?1:0])?l:null));function Ne(l,e,t){let n=l.axes[t],i=n.scale,o=l.scales[i],s=l.valToPos,r=n._space,u=s(10,i),a=s(9,i)-ul)return Le(e.slice().reverse(),o.distr,a,x(r/l)).reverse()}return Le(e,o.distr,a,1)}function Ye(l,e,t){let n=l.axes[t],i=n.scale,o=n._space,s=l.valToPos,r=p(s(1,i)-s(2,i));return o>r?Le(e.slice().reverse(),3,Re,x(o/r)).reverse():e}function je(l,e,t,n,i){return null==n?_l:null==e?"":i(e)}const Be={show:!0,scale:"y",stroke:al,space:30,gap:5,size:50,labelGap:0,labelSize:30,labelFont:ze,side:3,grid:ye,ticks:Se,border:Ee,font:Te,lineGap:1.5,rotate:0},He={scale:null,auto:!0,sorted:0,min:E,max:-E},Ue=(l,e,t,n,i)=>i,Ve={show:!0,auto:!0,sorted:0,gaps:Ue,alpha:1,facets:[ll({},He,{scale:"x"}),ll({},He,{scale:"y"})]},$e={scale:"y",auto:!0,sorted:0,show:!0,spanGaps:!1,gaps:Ue,alpha:1,points:{show:function(l,e){let{scale:t,idxs:n}=l.series[0],i=l._data[0],o=l.valToPos(i[n[0]],t,!0),s=l.valToPos(i[n[1]],t,!0);return p(s-o)/(l.series[e].points.space*El)>=n[1]-n[0]},filter:null},values:null,min:E,max:-E,idxs:[],path:null,clip:null};function We(l,e,t){return t/10}const qe={time:!0,auto:!0,distr:1,log:10,asinh:1,min:null,max:null,dir:1,ori:0},Ke=ll({},qe,{time:!1,ori:1}),Xe={};function Ze(l){let e=Xe[l];return e||(e={key:l,plots:[],sub(l){e.plots.push(l)},unsub(l){e.plots=e.plots.filter((e=>e!=l))},pub(l,t,n,i,o,s,r){for(let u=0;e.plots.length>u;u++)e.plots[u]!=t&&e.plots[u].pub(l,t,n,i,o,s,r)}},null!=l&&(Xe[l]=e)),e}function Je(l,e,t){const n=l.mode,i=l.series[e],o=2==n?l._data[e]:l._data,s=l.scales,r=l.bbox;let u=o[0],a=2==n?o[1]:o[e],f=2==n?s[i.facets[0].scale]:s[l.series[0].scale],c=2==n?s[i.facets[1].scale]:s[i.scale],h=r.left,d=r.top,p=r.width,m=r.height,g=l.valToPosH,x=l.valToPosV;return 0==f.ori?t(i,u,a,f,c,g,x,h,d,p,m,st,ut,ft,ht,pt):t(i,u,a,f,c,x,g,d,h,m,p,rt,at,ct,dt,mt)}function Qe(l,e){let t=0,n=0,i=f(l.bands,U);for(let l=0;i.length>l;l++){let o=i[l];o.series[0]==e?t=o.dir:o.series[1]==e&&(n|=1==o.dir?1:2)}return[t,1==n?-1:2==n?1:3==n?2:0]}function lt(l,e,t,n,i){let o=l.series[e],s=l.scales[2==l.mode?o.facets[1].scale:o.scale];return-1==i?s.min:1==i?s.max:3==s.distr?1==s.dir?s.min:s.max:0}function et(l,e,t,n,i,o){return Je(l,e,((l,e,s,r,u,a,f,c,h,d,p)=>{let m=l.pxRound;const g=0==r.ori?ut:at;let x,w;1==r.dir*(0==r.ori?1:-1)?(x=t,w=n):(x=n,w=t);let _=m(a(e[x],r,d,c)),v=m(f(s[x],u,p,h)),k=m(a(e[w],r,d,c)),b=m(f(1==o?u.max:u.min,u,p,h)),y=new Path2D(i);return g(y,k,b),g(y,_,b),g(y,_,v),y}))}function tt(l,e,t,n,i,o){let s=null;if(l.length>0){s=new Path2D;const r=0==e?ft:ct;let u=t;for(let e=0;l.length>e;e++){let t=l[e];if(t[1]>t[0]){let l=t[0]-u;l>0&&r(s,u,n,l,n+o),u=t[1]}}let a=t+i-u,f=10;a>0&&r(s,u,n-f/2,a,n+o+f)}return s}function nt(l,e,t,n,i,o,s){let r=[],u=l.length;for(let a=1==i?t:n;a>=t&&n>=a;a+=i)if(null===e[a]){let f=a,c=a;if(1==i)for(;++a<=n&&null===e[a];)c=a;else for(;--a>=t&&null===e[a];)c=a;let h=o(l[f]),d=c==f?h:o(l[c]),p=f-i;h=s>0||0>p||p>=u?h:o(l[p]);let m=c+i;d=0>s||0>m||m>=u?d:o(l[m]),h>d||r.push([h,d])}return r}function it(l){return 0==l?P:1==l?g:e=>G(e,l)}function ot(l){let e=0==l?st:rt,t=0==l?(l,e,t,n,i,o)=>{l.arcTo(e,t,n,i,o)}:(l,e,t,n,i,o)=>{l.arcTo(t,e,i,n,o)},n=0==l?(l,e,t,n,i)=>{l.rect(e,t,n,i)}:(l,e,t,n,i)=>{l.rect(t,e,i,n)};return(l,i,o,s,r,u=0,a=0)=>{0==u&&0==a?n(l,i,o,s,r):(u=w(u,s/2,r/2),a=w(a,s/2,r/2),e(l,i+u,o),t(l,i+s,o,i+s,o+r,u),t(l,i+s,o+r,i,o+r,a),t(l,i,o+r,i,o,a),t(l,i,o,i+s,o,u),l.closePath())}}const st=(l,e,t)=>{l.moveTo(e,t)},rt=(l,e,t)=>{l.moveTo(t,e)},ut=(l,e,t)=>{l.lineTo(e,t)},at=(l,e,t)=>{l.lineTo(t,e)},ft=ot(0),ct=ot(1),ht=(l,e,t,n,i,o)=>{l.arc(e,t,n,i,o)},dt=(l,e,t,n,i,o)=>{l.arc(t,e,n,i,o)},pt=(l,e,t,n,i,o,s)=>{l.bezierCurveTo(e,t,n,i,o,s)},mt=(l,e,t,n,i,o,s)=>{l.bezierCurveTo(t,e,i,n,s,o)};function gt(){return(l,e,t,n,i)=>Je(l,e,((e,o,s,r,u,a,f,c,h,p,m)=>{let g,x,{pxRound:w,points:_}=e;0==r.ori?(g=st,x=ht):(g=rt,x=dt);const v=N(_.width*El,3);let k=(_.size-_.width)/2*El,b=N(2*k,3),y=new Path2D,S=new Path2D,{left:E,top:T,width:z,height:D}=l.bbox;ft(S,E-b,T-b,z+2*b,D+2*b);const P=l=>{if(null!=s[l]){let e=w(a(o[l],r,p,c)),t=w(f(s[l],u,m,h));g(y,e+k,t),x(y,e,t,k,0,2*d)}};if(i)i.forEach(P);else for(let l=t;n>=l;l++)P(l);return{stroke:v>0?y:null,fill:y,clip:S,flags:3}}))}function xt(l){return(e,t,n,i,o,s)=>{n!=i&&(o!=n&&s!=n&&l(e,t,n),o!=i&&s!=i&&l(e,t,i),l(e,t,s))}}const wt=xt(ut),_t=xt(at);function vt(l){const e=f(l?.alignGaps,0);return(l,n,i,o)=>Je(l,n,((s,r,u,a,f,c,h,d,p,m,g)=>{let x,v,k=s.pxRound,b=l=>k(c(l,a,m,d)),y=l=>k(h(l,f,g,p));0==a.ori?(x=ut,v=wt):(x=at,v=_t);const S=a.dir*(0==a.ori?1:-1),T={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},z=T.stroke;let D,P,A,M=E,C=-E,I=b(r[1==S?i:o]),R=t(u,i,o,1*S),F=t(u,i,o,-1*S),G=b(r[R]),O=b(r[F]),L=!1;for(let l=1==S?i:o;l>=i&&o>=l;l+=S){let e=b(r[l]),t=u[l];e==I?null!=t?(P=y(t),M==E&&(x(z,e,P),D=P),M=w(P,M),C=_(P,C)):null===t&&(L=!0):(M!=E&&(v(z,I,M,C,D,P),A=I),null!=t?(P=y(t),x(z,e,P),M=C=D=P):(M=E,C=-E,null===t&&(L=!0)),I=e)}M!=E&&M!=C&&A!=I&&v(z,I,M,C,D,P);let[N,Y]=Qe(l,n);if(null!=s.fill||0!=N){let e=T.fill=new Path2D(z),t=y(s.fillTo(l,n,s.min,s.max,N));x(e,O,t),x(e,G,t)}if(!s.spanGaps){let t=[];L&&t.push(...nt(r,u,i,o,S,b,e)),T.gaps=t=s.gaps(l,n,i,o,t),T.clip=tt(t,a.ori,d,p,m,g)}return 0!=Y&&(T.band=2==Y?[et(l,n,i,o,z,-1),et(l,n,i,o,z,1)]:et(l,n,i,o,z,Y)),T}))}function kt(l,e,t,n,i,o,s=E){if(l.length>1){let r=null;for(let u=0,a=1/0;l.length>u;u++)if(void 0!==e[u]){if(null!=r){let e=p(l[u]-l[r]);a>e&&(a=e,s=p(t(l[u],n,i,o)-t(l[r],n,i,o)))}r=u}}return s}function bt(l,e,t,n,i){const o=l.length;if(2>o)return null;const s=new Path2D;if(t(s,l[0],e[0]),2==o)n(s,l[1],e[1]);else{let t=Array(o),n=Array(o-1),r=Array(o-1),u=Array(o-1);for(let t=0;o-1>t;t++)r[t]=e[t+1]-e[t],u[t]=l[t+1]-l[t],n[t]=r[t]/u[t];t[0]=n[0];for(let l=1;o-1>l;l++)0===n[l]||0===n[l-1]||n[l-1]>0!=n[l]>0?t[l]=0:(t[l]=3*(u[l-1]+u[l])/((2*u[l]+u[l-1])/n[l-1]+(u[l]+2*u[l-1])/n[l]),isFinite(t[l])||(t[l]=0));t[o-1]=n[o-2];for(let n=0;o-1>n;n++)i(s,l[n]+u[n]/3,e[n]+t[n]*u[n]/3,l[n+1]-u[n]/3,e[n+1]-t[n+1]*u[n]/3,l[n+1],e[n+1])}return s}const yt=new Set;function St(){for(let l of yt)l.syncRect(!0)}bl&&(Yl("resize",Sl,St),Yl("scroll",Sl,St,!0),Yl(wl,Sl,(()=>{Nt.pxRatio=El})));const Et=vt(),Tt=gt();function zt(l,e,t,n){return(n?[l[0],l[1]].concat(l.slice(2)):[l[0]].concat(l.slice(1))).map(((l,n)=>Dt(l,n,e,t)))}function Dt(l,e,t,n){return ll({},0==e?t:n,l)}function Pt(l,e,t){return null==e?V:[e,t]}const At=Pt;function Mt(l,e,t){return null==e?V:a(e,t,o,!0)}function Ct(l,e,t,i){return null==e?V:n(e,t,l.scales[i].log,!1)}const It=Ct;function Rt(l,e,t,n){return null==e?V:i(e,t,l.scales[n].log,!1)}const Ft=Rt;function Gt(l,t,n,i,o){let s=_(T(l),T(t)),r=t-l,u=e(o/i*r,n);do{let l=n[u],e=i*l/r;if(e>=o&&17>=s+(5>l?Y.get(l):0))return[l,e]}while(++u(e=g((t=+n)*El))+"px")),e,t]}function Lt(l){l.show&&[l.font,l.labelFont].forEach((l=>{let e=N(l[2]*El,1);l[0]=l[0].replace(/[0-9.]+px/,e+"px"),l[1]=e}))}function Nt(t,r,u){const c={mode:f(t.mode,1)},m=c.mode,k=new Intl.NumberFormat(t.locale||l),y=l=>k.format(l);c.fmtNum=y;const T=e=>new Intl.DateTimeFormat(t.locale||l,e).format;function P(l,e){return((3==e.distr?b(l>0?l:e.clamp(c,l,e.min,e.max,e.key)):4==e.distr?S(l,e.asinh):100==e.distr?e.fwd(l):l)-e._min)/(e._max-e._min)}function R(l,e,t,n){let i=P(l,e);return n+t*(-1==e.dir?1-i:i)}function F(l,e,t,n){let i=P(l,e);return n+t*(-1==e.dir?i:1-i)}function O(l,e,t,n){return 0==e.ori?R(l,e,t,n):F(l,e,t,n)}c.fmtDate=T,c.valToPosH=R,c.valToPosV=F;let L=!1;c.status=0;const B=c.root=Ml("uplot");null!=t.id&&(B.id=t.id),zl(B,t.class),t.title&&(Ml("u-title",B).textContent=t.title);const W=Al("canvas"),Z=c.ctx=W.getContext("2d"),J=Ml("u-wrap",B);Yl("click",J,(l=>{l.target===al&&(Yn!=Gn||jn!=On)&&Xn.click(c,l)}),!0);const el=c.under=Ml("u-under",J);J.appendChild(W);const al=c.over=Ml("u-over",J),xl=+f((t=Q(t)).pxAlign,1),bl=it(xl);(t.plugins||[]).forEach((l=>{l.opts&&(t=l.opts(c,t)||t)}));const Tl=t.ms||.001,Cl=c.series=1==m?zt(t.series||[],Pe,$e,!1):function(l,e){return l.map(((l,t)=>0==t?{}:ll({},e,l)))}(t.series||[null],Ve),Rl=c.axes=zt(t.axes||[],De,Be,!0),Gl=c.scales={},Ll=c.bands=t.bands||[];Ll.forEach((l=>{l.fill=D(l.fill||null),l.dir=f(l.dir,-1)}));const Nl=2==m?Cl[1].facets[0].scale:Cl[0].scale,Bl={axes:function(){for(let l=0;Rl.length>l;l++){let e=Rl[l];if(!e.show||!e._show)continue;let t,n,i=e.side,o=i%2,s=e.stroke(c,l),r=0==i||3==i?-1:1;if(e.label){let l=g((e._lpos+e.labelGap*r)*El);xn(e.labelFont[0],s,"center",2==i?ol:sl),Z.save(),1==o?(t=n=0,Z.translate(l,g(at+ct/2)),Z.rotate((3==i?-d:d)/2)):(t=g(ut+ft/2),n=l),Z.fillText(e.label,t,n),Z.restore()}let[u,a]=e._found;if(0==a)continue;let f=Gl[e.scale],h=0==o?ft:ct,p=0==o?ut:at,m=g(e.gap*El),x=e._splits,w=2==f.distr?x.map((l=>hn[l])):x,_=2==f.distr?hn[x[1]]-hn[x[0]]:u,v=e.ticks,k=e.border,b=v.show?g(v.size*El):0,y=e._rotate*-d/180,S=bl(e._pos*El),E=S+(b+m)*r;n=0==o?E:0,t=1==o?E:0,xn(e.font[0],s,1==e.align?rl:2==e.align?ul:y>0?rl:0>y?ul:0==o?"center":3==i?ul:rl,y||1==o?"middle":2==i?ol:sl);let T=e.font[1]*e.lineGap,z=x.map((l=>bl(O(l,f,h,p)))),D=e._values;for(let l=0;D.length>l;l++){let e=D[l];if(null!=e){0==o?t=z[l]:n=z[l],e=""+e;let i=-1==e.indexOf("\n")?[e]:e.split(/\n/gm);for(let l=0;i.length>l;l++){let e=i[l];y?(Z.save(),Z.translate(t,n+l*T),Z.rotate(y),Z.fillText(e,0,0),Z.restore()):Z.fillText(e,t,n+l*T)}}}v.show&&Tn(z,v.filter(c,w,l,a,_),o,i,S,b,N(v.width*El,3),v.stroke(c,l),v.dash,v.cap);let P=e.grid;P.show&&Tn(z,P.filter(c,w,l,a,_),o,0==o?2:1,0==o?at:ut,0==o?ct:ft,N(P.width*El,3),P.stroke(c,l),P.dash,P.cap),k.show&&Tn([S],[1],0==o?1:0,0==o?1:2,1==o?at:ut,1==o?ct:ft,N(k.width*El,3),k.stroke(c,l),k.dash,k.cap)}Ci("drawAxes")},series:function(){Zt>0&&(Cl.forEach(((l,e)=>{if(e>0&&l.show&&(vn(e,!1),vn(e,!0),null==l._paths)){cn!=l.alpha&&(Z.globalAlpha=cn=l.alpha);let t=2==m?[0,r[e][0].length-1]:function(l){let e=z(Jt-1,0,Zt-1),t=z(Qt+1,0,Zt-1);for(;null==l[e]&&e>0;)e--;for(;null==l[t]&&Zt-1>t;)t++;return[e,t]}(r[e]);l._paths=l.paths(c,e,t[0],t[1]),1!=cn&&(Z.globalAlpha=cn=1)}})),Cl.forEach(((l,e)=>{if(e>0&&l.show){cn!=l.alpha&&(Z.globalAlpha=cn=l.alpha),null!=l._paths&&kn(e,!1);{let t=null!=l._paths?l._paths.gaps:null,n=l.points.show(c,e,Jt,Qt,t),i=l.points.filter(c,e,n,t);(n||i)&&(l.points._paths=l.points.paths(c,e,Jt,Qt,i),kn(e,!0))}1!=cn&&(Z.globalAlpha=cn=1),Ci("drawSeries",e)}})))}},Hl=(t.drawOrder||["axes","series"]).map((l=>Bl[l]));function Ul(l){let e=Gl[l];if(null==e){let n=(t.scales||H)[l]||H;if(null!=n.from)Ul(n.from),Gl[l]=ll({},Gl[n.from],n,{key:l});else{e=Gl[l]=ll({},l==Nl?qe:Ke,n),e.key=l;let t=e.time,i=e.range,o=$(i);if((l!=Nl||2==m&&!t)&&(!o||null!=i[0]&&null!=i[1]||(i={min:null==i[0]?s:{mode:1,hard:i[0],soft:i[0]},max:null==i[1]?s:{mode:1,hard:i[1],soft:i[1]}},o=!1),!o&&K(i))){let l=i;i=(e,t,n)=>null==t?V:a(t,n,l)}e.range=D(i||(t?At:l==Nl?3==e.distr?It:4==e.distr?Ft:Pt:3==e.distr?Ct:4==e.distr?Rt:Mt)),e.auto=D(!o&&e.auto),e.clamp=D(e.clamp||We),e._min=e._max=null}}}Ul("x"),Ul("y"),1==m&&Cl.forEach((l=>{Ul(l.scale)})),Rl.forEach((l=>{Ul(l.scale)}));for(let l in t.scales)Ul(l);const Vl=Gl[Nl],$l=Vl.distr;let Kl,Xl;0==Vl.ori?(zl(B,"u-hz"),Kl=R,Xl=F):(zl(B,"u-vt"),Kl=F,Xl=R);const Zl={};for(let l in Gl){let e=Gl[l];null==e.min&&null==e.max||(Zl[l]={min:e.min,max:e.max},e.min=e.max=null)}const Jl=t.tzDate||(l=>new Date(g(l/Tl))),Ql=t.fmtDate||T,le=1==Tl?re(Jl):fe(Jl),ee=he(Jl,ce(1==Tl?se:ae,Ql)),te=ge(Jl,me("{YYYY}-{MM}-{DD} {h}:{mm}{aa}",Ql)),ne=[],ie=c.legend=ll({},xe,t.legend),pe=ie.show,we=ie.markers;let _e,ve,be;ie.idxs=ne,we.width=D(we.width),we.dash=D(we.dash),we.stroke=D(we.stroke),we.fill=D(we.fill);let ye,Se=[],Ee=[],Te=!1,ze={};if(ie.live){const l=Cl[1]?Cl[1].values:null;Te=null!=l,ye=Te?l(c,1,0):{_:0};for(let l in ye)ze[l]=_l}if(pe)if(_e=Al("table","u-legend",B),be=Al("tbody",null,_e),ie.mount(c,_e),Te){ve=Al("thead",null,_e,be);let l=Al("tr",null,ve);for(var Re in Al("th",null,l),ye)Al("th",kl,l).textContent=Re}else zl(_e,"u-inline"),ie.live&&zl(_e,"u-live");const Fe={show:!0},Ge={show:!1},Oe=new Map;function Le(l,e,t,n=!0){const i=Oe.get(e)||{},o=kt.bind[l](c,e,t,n);o&&(Yl(l,e,i[l]=o),Oe.set(e,i))}function He(l,e){const t=Oe.get(e)||{};for(let n in t)null!=l&&n!=l||(jl(n,e,t[n]),delete t[n]);null==l&&Oe.delete(e)}let Ue=0,Xe=0,Je=0,Qe=0,et=0,tt=0,nt=et,ot=tt,st=Je,rt=Qe,ut=0,at=0,ft=0,ct=0;c.bbox={};let ht=!1,dt=!1,pt=!1,mt=!1,gt=!1,xt=!1;function wt(l,e,t){(t||l!=c.width||e!=c.height)&&_t(l,e),Pn(!1),pt=!0,dt=!0,$n()}function _t(l,e){c.width=Ue=Je=l,c.height=Xe=Qe=e,et=tt=0,function(){let l=!1,e=!1,t=!1,n=!1;Rl.forEach((i=>{if(i.show&&i._show){let{side:o,_size:s}=i,r=s+(null!=i.label?i.labelSize:0);r>0&&(o%2?(Je-=r,3==o?(et+=r,n=!0):t=!0):(Qe-=r,0==o?(tt+=r,l=!0):e=!0))}})),Wt[0]=l,Wt[1]=t,Wt[2]=e,Wt[3]=n,Je-=Xt[1]+Xt[3],et+=Xt[3],Qe-=Xt[2]+Xt[0],tt+=Xt[0]}(),function(){let l=et+Je,e=tt+Qe,t=et,n=tt;function i(i,o){switch(i){case 1:return l+=o,l-o;case 2:return e+=o,e-o;case 3:return t-=o,t+o;case 0:return n-=o,n+o}}Rl.forEach((l=>{if(l.show&&l._show){let e=l.side;l._pos=i(e,l._size),null!=l.label&&(l._lpos=i(e,l.labelSize))}}))}();let t=c.bbox;ut=t.left=G(et*El,.5),at=t.top=G(tt*El,.5),ft=t.width=G(Je*El,.5),ct=t.height=G(Qe*El,.5)}const vt=3;c.setSize=function({width:l,height:e}){wt(l,e)};const kt=c.cursor=ll({},ke,{drag:{y:2==m}},t.cursor);if(null==kt.dataIdx){let l=kt.hover,e=l.skip=new Set(l.skip??[]);e.add(void 0);let t=l.prox=D(l.prox),n=l.bias??=0;kt.dataIdx=(l,i,o,s)=>{if(0==i)return o;let u=o,a=t(l,i,o,s)??E,f=a>=0&&E>a,c=0==Vl.ori?Je:Qe,h=kt.left,d=r[0],m=r[i];if(e.has(m[o])){u=null;let l,t=null,i=null;if(0==n||-1==n)for(l=o;null==t&&l-- >0;)e.has(m[l])||(t=l);if(0==n||1==n)for(l=o;null==i&&l++e?e>a||(u=i):l>a||(u=t)}else u=null==i?t:null==t||o-t>i-o?i:t}else f&&p(h-Kl(d[o],Vl,c,0))>a&&(u=null);return u}}const bt=l=>{kt.event=l};kt.idxs=ne,kt._lock=!1;let St=kt.points;St.show=D(St.show),St.size=D(St.size),St.stroke=D(St.stroke),St.width=D(St.width),St.fill=D(St.fill);const Nt=c.focus=ll({},t.focus||{alpha:.3},kt.focus),Yt=Nt.prox>=0,jt=Yt&&St.one;let Bt=[],Ht=[],Ut=[];function Vt(l,e){let t=St.show(c,e);if(t)return zl(t,"u-cursor-pt"),zl(t,l.class),Il(t,-10,-10,Je,Qe),al.insertBefore(t,Bt[e]),t}function $t(l,e){if(1==m||e>0){let e=1==m&&Gl[l.scale].time,t=l.value;l.value=e?q(t)?ge(Jl,me(t,Ql)):t||te:t||je,l.label=l.label||(e?"Time":"Value")}if(jt||e>0){l.width=null==l.width?1:l.width,l.paths=l.paths||Et||M,l.fillTo=D(l.fillTo||lt),l.pxAlign=+f(l.pxAlign,xl),l.pxRound=it(l.pxAlign),l.stroke=D(l.stroke||null),l.fill=D(l.fill||null),l._stroke=l._fill=l._paths=l._focus=null;let e=function(l){return N(1*(3+2*(l||1)),3)}(_(1,l.width)),t=l.points=ll({},{size:e,width:_(1,.2*e),stroke:l.stroke,space:2*e,paths:Tt,_stroke:null,_fill:null},l.points);t.show=D(t.show),t.filter=D(t.filter),t.fill=D(t.fill),t.stroke=D(t.stroke),t.paths=D(t.paths),t.pxAlign=l.pxAlign}if(pe){let t=function(l,e){if(0==e&&(Te||!ie.live||2==m))return V;let t=[],n=Al("tr","u-series",be,be.childNodes[e]);zl(n,l.class),l.show||zl(n,vl);let i=Al("th",null,n);if(we.show){let l=Ml("u-marker",i);if(e>0){let t=we.width(c,e);t&&(l.style.border=t+"px "+we.dash(c,e)+" "+we.stroke(c,e)),l.style.background=we.fill(c,e)}}let o=Ml(kl,i);for(var s in o.textContent=l.label,e>0&&(we.show||(o.style.color=l.width>0?we.stroke(c,e):we.fill(c,e)),Le("click",i,(e=>{if(kt._lock)return;bt(e);let t=Cl.indexOf(l);if((e.ctrlKey||e.metaKey)!=ie.isolate){let l=Cl.some(((l,e)=>e>0&&e!=t&&l.show));Cl.forEach(((e,n)=>{n>0&&ni(n,l?n==t?Fe:Ge:Fe,!0,Ri.setSeries)}))}else ni(t,{show:!l.show},!0,Ri.setSeries)}),!1),Yt&&Le(pl,i,(e=>{kt._lock||(bt(e),ni(Cl.indexOf(l),ri,!0,Ri.setSeries))}),!1)),ye){let l=Al("td","u-value",n);l.textContent="--",t.push(l)}return[n,t]}(l,e);Se.splice(e,0,t[0]),Ee.splice(e,0,t[1]),ie.values.push(null)}if(kt.show){ne.splice(e,0,null);let t=null;jt?0==e&&(t=Vt(l,e)):e>0&&(t=Vt(l,e)),Bt.splice(e,0,t),Ht.splice(e,0,0),Ut.splice(e,0,0)}Ci("addSeries",e)}c.addSeries=function(l,e){e=null==e?Cl.length:e,l=1==m?Dt(l,e,Pe,$e):Dt(l,e,{},Ve),Cl.splice(e,0,l),$t(Cl[e],e)},c.delSeries=function(l){if(Cl.splice(l,1),pe){ie.values.splice(l,1),Ee.splice(l,1);let e=Se.splice(l,1)[0];He(null,e.firstChild),e.remove()}kt.show&&(ne.splice(l,1),Bt.splice(l,1)[0].remove(),Ht.splice(l,1),Ut.splice(l,1)),Ci("delSeries",l)};const Wt=[!1,!1,!1,!1];function qt(l,e,t){let[n,i,o,s]=t,r=e%2,u=0;return 0==r&&(s||i)&&(u=0==e&&!n||2==e&&!o?g(De.size/3):0),1==r&&(n||o)&&(u=1==e&&!i||3==e&&!s?g(Be.size/2):0),u}const Kt=c.padding=(t.padding||[qt,qt,qt,qt]).map((l=>D(f(l,qt)))),Xt=c._padding=Kt.map(((l,e)=>l(c,e,Wt,0)));let Zt,Jt=null,Qt=null;const ln=1==m?Cl[0].idxs:null;let en,tn,nn,on,sn,rn,un,an,fn,cn,hn=null,dn=!1;function pn(l,e){if(c.data=c._data=r=null==l?[]:l,2==m){Zt=0;for(let l=1;Cl.length>l;l++)Zt+=r[l][0].length}else{0==r.length&&(c.data=c._data=r=[[]]),hn=r[0],Zt=hn.length;let l=r;if(2==$l){l=r.slice();let e=l[0]=Array(Zt);for(let l=0;Zt>l;l++)e[l]=l}c._data=r=l}if(Pn(!0),Ci("setData"),2==$l&&(pt=!0),!1!==e){let l=Vl;l.auto(c,dn)?mn():ti(Nl,l.min,l.max),mt=mt||kt.left>=0,xt=!0,$n()}}function mn(){let l,e;dn=!0,1==m&&(Zt>0?(Jt=ln[0]=0,Qt=ln[1]=Zt-1,l=r[0][Jt],e=r[0][Qt],2==$l?(l=Jt,e=Qt):l==e&&(3==$l?[l,e]=n(l,l,Vl.log,!1):4==$l?[l,e]=i(l,l,Vl.log,!1):Vl.time?e=l+g(86400/Tl):[l,e]=a(l,e,o,!0))):(Jt=ln[0]=l=null,Qt=ln[1]=e=null)),ti(Nl,l,e)}function gn(l,e,t,n,i,o){l??=fl,t??=U,n??="butt",i??=fl,o??="round",l!=en&&(Z.strokeStyle=en=l),i!=tn&&(Z.fillStyle=tn=i),e!=nn&&(Z.lineWidth=nn=e),o!=sn&&(Z.lineJoin=sn=o),n!=rn&&(Z.lineCap=rn=n),t!=on&&Z.setLineDash(on=t)}function xn(l,e,t,n){e!=tn&&(Z.fillStyle=tn=e),l!=un&&(Z.font=un=l),t!=an&&(Z.textAlign=an=t),n!=fn&&(Z.textBaseline=fn=n)}function wn(l,e,t,n,i=0){if(n.length>0&&l.auto(c,dn)&&(null==e||null==e.min)){let e=f(Jt,0),o=f(Qt,n.length-1),s=null==t.min?3==l.distr?function(l,e,t){let n=E,i=-E;for(let o=e;t>=o;o++){let e=l[o];null!=e&&e>0&&(n>e&&(n=e),e>i&&(i=e))}return[n,i]}(n,e,o):function(l,e,t,n){let i=E,o=-E;if(1==n)i=l[e],o=l[t];else if(-1==n)i=l[t],o=l[e];else for(let n=e;t>=n;n++){let e=l[n];null!=e&&(i>e&&(i=e),e>o&&(o=e))}return[i,o]}(n,e,o,i):[t.min,t.max];l.min=w(l.min,t.min=s[0]),l.max=_(l.max,t.max=s[1])}}c.setData=pn;const _n={min:null,max:null};function vn(l,e){let t=e?Cl[l].points:Cl[l];t._stroke=t.stroke(c,l),t._fill=t.fill(c,l)}function kn(l,e){let t=e?Cl[l].points:Cl[l],{stroke:n,fill:i,clip:o,flags:s,_stroke:u=t._stroke,_fill:a=t._fill,_width:h=t.width}=t._paths;h=N(h*El,3);let d=null,p=h%2/2;e&&null==a&&(a=h>0?"#fff":u);let m=1==t.pxAlign&&p>0;if(m&&Z.translate(p,p),!e){let l=ut-h/2,e=at-h/2,t=ft+h,n=ct+h;d=new Path2D,d.rect(l,e,t,n)}e?yn(u,h,t.dash,t.cap,a,n,i,s,o):function(l,e,t,n,i,o,s,u,a,h,d){let p=!1;0!=a&&Ll.forEach(((m,g)=>{if(m.series[0]==l){let l,x=Cl[m.series[1]],w=r[m.series[1]],_=(x._paths||H).band;$(_)&&(_=1==m.dir?_[0]:_[1]);let v=null;x.show&&_&&function(l,e,t){for(e=f(e,0),t=f(t,l.length-1);t>=e;){if(null!=l[e])return!0;e++}return!1}(w,Jt,Qt)?(v=m.fill(c,g)||o,l=x._paths.clip):_=null,yn(e,t,n,i,v,s,u,a,h,d,l,_),p=!0}})),p||yn(e,t,n,i,o,s,u,a,h,d)}(l,u,h,t.dash,t.cap,a,n,i,s,d,o),m&&Z.translate(-p,-p)}const bn=3;function yn(l,e,t,n,i,o,s,r,u,a,f,c){gn(l,e,t,n,i),(u||a||c)&&(Z.save(),u&&Z.clip(u),a&&Z.clip(a)),c?(r&bn)==bn?(Z.clip(c),f&&Z.clip(f),En(i,s),Sn(l,o,e)):2&r?(En(i,s),Z.clip(c),Sn(l,o,e)):1&r&&(Z.save(),Z.clip(c),f&&Z.clip(f),En(i,s),Z.restore(),Sn(l,o,e)):(En(i,s),Sn(l,o,e)),(u||a||c)&&Z.restore()}function Sn(l,e,t){t>0&&(e instanceof Map?e.forEach(((l,e)=>{Z.strokeStyle=en=e,Z.stroke(l)})):null!=e&&l&&Z.stroke(e))}function En(l,e){e instanceof Map?e.forEach(((l,e)=>{Z.fillStyle=tn=e,Z.fill(l)})):null!=e&&l&&Z.fill(e)}function Tn(l,e,t,n,i,o,s,r,u,a){let f=s%2/2;1==xl&&Z.translate(f,f),gn(r,s,u,a,r),Z.beginPath();let c,h,d,p,m=i+(0==n||3==n?-o:o);0==t?(h=i,p=m):(c=i,d=m);for(let n=0;l.length>n;n++)null!=e[n]&&(0==t?c=d=l[n]:h=p=l[n],Z.moveTo(c,h),Z.lineTo(d,p));Z.stroke(),1==xl&&Z.translate(-f,-f)}function zn(l){let e=!0;return Rl.forEach(((t,n)=>{if(!t.show)return;let i=Gl[t.scale];if(null==i.min)return void(t._show&&(e=!1,t._show=!1,Pn(!1)));t._show||(e=!1,t._show=!0,Pn(!1));let o=t.side,s=o%2,{min:r,max:u}=i,[a,f]=function(l,e,t,n){let i,o=Rl[l];if(n>0){let s=o._space=o.space(c,l,e,t,n);i=Gt(e,t,o._incrs=o.incrs(c,l,e,t,n,s),n,s)}else i=[0,0];return o._found=i}(n,r,u,0==s?Je:Qe);if(0==f)return;let h=t._splits=t.splits(c,n,r,u,a,f,2==i.distr),d=2==i.distr?h.map((l=>hn[l])):h,p=2==i.distr?hn[h[1]]-hn[h[0]]:a,m=t._values=t.values(c,t.filter(c,d,n,f,p),n,f,p,y);t._rotate=2==o?t.rotate(c,m,n,f):0;let g=t._size;t._size=x(t.size(c,m,n,l)),null!=g&&t._size!=g&&(e=!1)})),e}function Dn(l){let e=!0;return Kt.forEach(((t,n)=>{let i=t(c,n,Wt,l);i!=Xt[n]&&(e=!1),Xt[n]=i})),e}function Pn(l){Cl.forEach(((e,t)=>{t>0&&(e._paths=null,l&&(1==m?(e.min=null,e.max=null):e.facets.forEach((l=>{l.min=null,l.max=null}))))}))}let An,Mn,Cn,In,Rn,Fn,Gn,On,Ln,Nn,Yn,jn,Bn=!1,Hn=!1,Un=[];function Vn(){Hn=!1;for(let l=0;Un.length>l;l++)Ci(...Un[l]);Un.length=0}function $n(){Bn||(tl(Wn),Bn=!0)}function Wn(){if(ht&&(function(){for(let l in Gl){let e=Gl[l];null==Zl[l]&&(null==e.min||null!=Zl[Nl]&&e.auto(c,dn))&&(Zl[l]=_n)}for(let l in Gl){let e=Gl[l];null==Zl[l]&&null!=e.from&&null!=Zl[e.from]&&(Zl[l]=_n)}null!=Zl[Nl]&&Pn(!0);let l={};for(let e in Zl){let t=Zl[e];if(null!=t){let n=l[e]=Q(Gl[e],X);if(null!=t.min)ll(n,t);else if(e!=Nl||2==m)if(0==Zt&&null==n.from){let l=n.range(c,null,null,e);n.min=l[0],n.max=l[1]}else n.min=E,n.max=-E}}if(Zt>0){Cl.forEach(((t,n)=>{if(1==m){let i=t.scale,o=Zl[i];if(null==o)return;let s=l[i];if(0==n){let l=s.range(c,s.min,s.max,i);s.min=l[0],s.max=l[1],Jt=e(s.min,r[0]),Qt=e(s.max,r[0]),Qt-Jt>1&&(s.min>r[0][Jt]&&Jt++,r[0][Qt]>s.max&&Qt--),t.min=hn[Jt],t.max=hn[Qt]}else t.show&&t.auto&&wn(s,o,t,r[n],t.sorted);t.idxs[0]=Jt,t.idxs[1]=Qt}else if(n>0&&t.show&&t.auto){let[e,i]=t.facets,o=e.scale,s=i.scale,[u,a]=r[n],f=l[o],c=l[s];null!=f&&wn(f,Zl[o],e,u,e.sorted),null!=c&&wn(c,Zl[s],i,a,i.sorted),t.min=i.min,t.max=i.max}}));for(let e in l){let t=l[e],n=Zl[e];if(null==t.from&&(null==n||null==n.min)){let l=t.range(c,t.min==E?null:t.min,t.max==-E?null:t.max,e);t.min=l[0],t.max=l[1]}}}for(let e in l){let t=l[e];if(null!=t.from){let n=l[t.from];if(null==n.min)t.min=t.max=null;else{let l=t.range(c,n.min,n.max,e);t.min=l[0],t.max=l[1]}}}let t={},n=!1;for(let e in l){let i=l[e],o=Gl[e];if(o.min!=i.min||o.max!=i.max){o.min=i.min,o.max=i.max;let l=o.distr;o._min=3==l?b(o.min):4==l?S(o.min,o.asinh):100==l?o.fwd(o.min):o.min,o._max=3==l?b(o.max):4==l?S(o.max,o.asinh):100==l?o.fwd(o.max):o.max,t[e]=n=!0}}if(n){Cl.forEach(((l,e)=>{2==m?e>0&&t.y&&(l._paths=null):t[l.scale]&&(l._paths=null)}));for(let l in t)pt=!0,Ci("setScale",l);kt.show&&kt.left>=0&&(mt=xt=!0)}for(let l in Zl)Zl[l]=null}(),ht=!1),pt&&(function(){let l=!1,e=0;for(;!l;){e++;let t=zn(e),n=Dn(e);l=e==vt||t&&n,l||(_t(c.width,c.height),dt=!0)}}(),pt=!1),dt){if(Pl(el,rl,et),Pl(el,ol,tt),Pl(el,nl,Je),Pl(el,il,Qe),Pl(al,rl,et),Pl(al,ol,tt),Pl(al,nl,Je),Pl(al,il,Qe),Pl(J,nl,Ue),Pl(J,il,Xe),W.width=g(Ue*El),W.height=g(Xe*El),Rl.forEach((({_el:l,_show:e,_size:t,_pos:n,side:i})=>{if(null!=l)if(e){let e=i%2==1;Pl(l,e?"left":"top",n-(3===i||0===i?t:0)),Pl(l,e?"width":"height",t),Pl(l,e?"top":"left",e?tt:et),Pl(l,e?"height":"width",e?Qe:Je),Dl(l,vl)}else zl(l,vl)})),en=tn=nn=sn=rn=un=an=fn=on=null,cn=1,xi(!0),et!=nt||tt!=ot||Je!=st||Qe!=rt){Pn(!1);let l=Je/st,e=Qe/rt;if(kt.show&&!mt&&kt.left>=0){kt.left*=l,kt.top*=e,Cn&&Il(Cn,g(kt.left),0,Je,Qe),In&&Il(In,0,g(kt.top),Je,Qe);for(let t=0;Bt.length>t;t++){let n=Bt[t];null!=n&&(Ht[t]*=l,Ut[t]*=e,Il(n,x(Ht[t]),x(Ut[t]),Je,Qe))}}if(Qn.show&&!gt&&Qn.left>=0&&Qn.width>0){Qn.left*=l,Qn.width*=l,Qn.top*=e,Qn.height*=e;for(let l in vi)Pl(li,l,Qn[l])}nt=et,ot=tt,st=Je,rt=Qe}Ci("setSize"),dt=!1}Ue>0&&Xe>0&&(Z.clearRect(0,0,W.width,W.height),Ci("drawClear"),Hl.forEach((l=>l())),Ci("draw")),Qn.show&>&&(ei(Qn),gt=!1),kt.show&&mt&&(mi(null,!0,!1),mt=!1),ie.show&&ie.live&&xt&&(di(),xt=!1),L||(L=!0,c.status=1,Ci("ready")),dn=!1,Bn=!1}function qn(l,t){let n=Gl[l];if(null==n.from){if(0==Zt){let e=n.range(c,t.min,t.max,l);t.min=e[0],t.max=e[1]}if(t.min>t.max){let l=t.min;t.min=t.max,t.max=l}if(Zt>1&&null!=t.min&&null!=t.max&&1e-16>t.max-t.min)return;l==Nl&&2==n.distr&&Zt>0&&(t.min=e(t.min,r[0]),t.max=e(t.max,r[0]),t.min==t.max&&t.max++),Zl[l]=t,ht=!0,$n()}}c.batch=function(l,e=!1){Bn=!0,Hn=e,l(c),Wn(),e&&Un.length>0&&queueMicrotask(Vn)},c.redraw=(l,e)=>{pt=e||!1,!1!==l?ti(Nl,Vl.min,Vl.max):$n()},c.setScale=qn;let Kn=!1;const Xn=kt.drag;let Zn=Xn.x,Jn=Xn.y;kt.show&&(kt.x&&(An=Ml("u-cursor-x",al)),kt.y&&(Mn=Ml("u-cursor-y",al)),0==Vl.ori?(Cn=An,In=Mn):(Cn=Mn,In=An),Yn=kt.left,jn=kt.top);const Qn=c.select=ll({show:!0,over:!0,left:0,width:0,top:0,height:0},t.select),li=Qn.show?Ml("u-select",Qn.over?al:el):null;function ei(l,e){if(Qn.show){for(let e in l)Qn[e]=l[e],e in vi&&Pl(li,e,l[e]);!1!==e&&Ci("setSelect")}}function ti(l,e,t){qn(l,{min:e,max:t})}function ni(l,e,t,n){null!=e.focus&&function(l){if(l!=si){let e=null==l,t=1!=Nt.alpha;Cl.forEach(((n,i)=>{if(1==m||i>0){let o=e||0==i||i==l;n._focus=e?null:o,t&&function(l,e){Cl[l].alpha=e,kt.show&&Bt[l]&&(Bt[l].style.opacity=e),pe&&Se[l]&&(Se[l].style.opacity=e)}(i,o?1:Nt.alpha)}})),si=l,t&&$n()}}(l),null!=e.show&&Cl.forEach(((t,n)=>{0>=n||l!=n&&null!=l||(t.show=e.show,function(l){let e=pe?Se[l]:null;Cl[l].show?e&&Dl(e,vl):(e&&zl(e,vl),Il(jt?Bt[0]:Bt[l],-10,-10,Je,Qe))}(n),2==m?(ti(t.facets[0].scale,null,null),ti(t.facets[1].scale,null,null)):ti(t.scale,null,null),$n())})),!1!==t&&Ci("setSeries",l,e),n&&Oi("setSeries",c,l,e)}let ii,oi,si;c.setSelect=ei,c.setSeries=ni,c.addBand=function(l,e){l.fill=D(l.fill||null),l.dir=f(l.dir,-1),Ll.splice(e=null==e?Ll.length:e,0,l)},c.setBand=function(l,e){ll(Ll[l],e)},c.delBand=function(l){null==l?Ll.length=0:Ll.splice(l,1)};const ri={focus:!0};function ui(l,e,t){let n=Gl[e];t&&(l=l/El-(1==n.ori?tt:et));let i=Je;1==n.ori&&(i=Qe,l=i-l),-1==n.dir&&(l=i-l);let o=n._min,s=o+l/i*(n._max-o),r=n.distr;return 3==r?v(10,s):4==r?((l,e=1)=>h.sinh(l)*e)(s,n.asinh):100==r?n.bwd(s):s}function ai(l,e){Pl(li,rl,Qn.left=l),Pl(li,nl,Qn.width=e)}function fi(l,e){Pl(li,ol,Qn.top=l),Pl(li,il,Qn.height=e)}pe&&Yt&&Le(ml,_e,(l=>{kt._lock||(bt(l),null!=si&&ni(null,ri,!0,Ri.setSeries))})),c.valToIdx=l=>e(l,r[0]),c.posToIdx=function(l,t){return e(ui(l,Nl,t),r[0],Jt,Qt)},c.posToVal=ui,c.valToPos=(l,e,t)=>0==Gl[e].ori?R(l,Gl[e],t?ft:Je,t?ut:0):F(l,Gl[e],t?ct:Qe,t?at:0),c.setCursor=(l,e,t)=>{Yn=l.left,jn=l.top,mi(null,e,t)};let ci=0==Vl.ori?ai:fi,hi=1==Vl.ori?ai:fi;function di(l,e){if(null!=l&&(l.idxs?l.idxs.forEach(((l,e)=>{ne[e]=l})):(l=>void 0===l)(l.idx)||ne.fill(l.idx),ie.idx=ne[0]),pe&&ie.live){for(let l=0;Cl.length>l;l++)(l>0||1==m&&!Te)&&pi(l,ne[l]);!function(){if(pe&&ie.live)for(let l=2==m?1:0;Cl.length>l;l++){if(0==l&&Te)continue;let e=ie.values[l],t=0;for(let n in e)Ee[l][t++].firstChild.nodeValue=e[n]}}()}xt=!1,!1!==e&&Ci("setLegend")}function pi(l,e){let t,n=Cl[l],i=0==l&&2==$l?hn:r[l];Te?t=n.values(c,l,e)??ze:(t=n.value(c,null==e?null:i[e],l,e,y),t=null==t?ze:{_:t}),ie.values[l]=t}function mi(l,t,n){let i;Ln=Yn,Nn=jn,[Yn,jn]=kt.move(c,Yn,jn),kt.left=Yn,kt.top=jn,kt.show&&(Cn&&Il(Cn,g(Yn),0,Je,Qe),In&&Il(In,0,g(jn),Je,Qe)),ii=E,oi=null;let o=0==Vl.ori?Je:Qe,s=1==Vl.ori?Je:Qe;if(0>Yn||0==Zt||Jt>Qt){i=kt.idx=null;for(let l=0;Cl.length>l;l++){let e=Bt[l];null!=e&&Il(e,-10,-10,Je,Qe)}Yt&&ni(null,ri,!0,null==l&&Ri.setSeries),ie.live&&(ne.fill(i),xt=!0)}else{let l,t,n;1==m&&(l=0==Vl.ori?Yn:jn,t=ui(l,Nl),i=kt.idx=e(t,r[0],Jt,Qt),n=Kl(r[0][i],Vl,o,0));let u=-10,a=-10,f=0,h=0,d=!0,g="",w="";for(let l=2==m?1:0;Cl.length>l;l++){let e=Cl[l],_=ne[l],v=null==_?null:1==m?r[l][_]:r[l][1][_],k=kt.dataIdx(c,l,i,t),b=null==k?null:1==m?r[l][k]:r[l][1][k];xt=xt||b!=v||k!=_,ne[l]=k;let y=k==i?n:Kl(1==m?r[0][k]:r[l][0][k],Vl,o,0);if(l>0&&e.show){let t=null==b?-10:Xl(b,1==m?Gl[e.scale]:Gl[e.facets[1].scale],s,0);if(Yt&&null!=b){let n=1==Vl.ori?Yn:jn,i=p(Nt.dist(c,l,k,t,n));if(ii>i){let t=Nt.bias;if(0!=t){let o=ui(n,e.scale),s=0>o?-1:1;s!=(0>b?-1:1)||(1==s?1==t?o>b:b>o:1==t?b>o:o>b)||(ii=i,oi=l)}else ii=i,oi=l}}if(xt||jt){let e,n;0==Vl.ori?(e=y,n=t):(e=t,n=y);let i,o,s,r,p,m,_=!0,v=St.bbox;if(null!=v){_=!1;let e=v(c,l);s=e.left,r=e.top,i=e.width,o=e.height}else s=e,r=n,i=o=St.size(c,l);if(m=St.fill(c,l),p=St.stroke(c,l),jt)l!=oi||ii>Nt.prox||(u=s,a=r,f=i,h=o,d=_,g=m,w=p);else{let e=Bt[l];null!=e&&(Ht[l]=s,Ut[l]=r,Ol(e,i,o,_),Fl(e,m,p),Il(e,x(s),x(r),Je,Qe))}}}}if(jt){let l=Nt.prox;if(xt||(null==si?l>=ii:ii>l||oi!=si)){let l=Bt[0];Ht[0]=u,Ut[0]=a,Ol(l,f,h,d),Fl(l,g,w),Il(l,x(u),x(a),Je,Qe)}}}if(Qn.show&&Kn)if(null!=l){let[e,t]=Ri.scales,[n,i]=Ri.match,[r,u]=l.cursor.sync.scales,a=l.cursor.drag;if(Zn=a._x,Jn=a._y,Zn||Jn){let a,f,c,h,d,{left:m,top:g,width:x,height:_}=l.select,v=l.scales[r].ori,k=l.posToVal,b=null!=e&&n(e,r),y=null!=t&&i(t,u);b&&Zn?(0==v?(a=m,f=x):(a=g,f=_),c=Gl[e],h=Kl(k(a,r),c,o,0),d=Kl(k(a+f,r),c,o,0),ci(w(h,d),p(d-h))):ci(0,o),y&&Jn?(1==v?(a=m,f=x):(a=g,f=_),c=Gl[t],h=Xl(k(a,u),c,s,0),d=Xl(k(a+f,u),c,s,0),hi(w(h,d),p(d-h))):hi(0,s)}else ki()}else{let l=p(Ln-Rn),e=p(Nn-Fn);if(1==Vl.ori){let t=l;l=e,e=t}Zn=Xn.x&&l>=Xn.dist,Jn=Xn.y&&e>=Xn.dist;let t,n,i=Xn.uni;null!=i?Zn&&Jn&&(Zn=l>=i,Jn=e>=i,Zn||Jn||(e>l?Jn=!0:Zn=!0)):Xn.x&&Xn.y&&(Zn||Jn)&&(Zn=Jn=!0),Zn&&(0==Vl.ori?(t=Gn,n=Yn):(t=On,n=jn),ci(w(t,n),p(n-t)),Jn||hi(0,s)),Jn&&(1==Vl.ori?(t=Gn,n=Yn):(t=On,n=jn),hi(w(t,n),p(n-t)),Zn||ci(0,o)),Zn||Jn||(ci(0,0),hi(0,0))}if(Xn._x=Zn,Xn._y=Jn,null==l){if(n){if(null!=Fi){let[l,e]=Ri.scales;Ri.values[0]=null!=l?ui(0==Vl.ori?Yn:jn,l):null,Ri.values[1]=null!=e?ui(1==Vl.ori?Yn:jn,e):null}Oi(cl,c,Yn,jn,Je,Qe,i)}if(Yt){let l=n&&Ri.setSeries,e=Nt.prox;null==si?ii>e||ni(oi,ri,!0,l):ii>e?ni(null,ri,!0,l):oi!=si&&ni(oi,ri,!0,l)}}xt&&(ie.idx=i,di()),!1!==t&&Ci("setCursor")}c.setLegend=di;let gi=null;function xi(l=!1){l?gi=null:(gi=al.getBoundingClientRect(),Ci("syncRect",gi))}function wi(l,e,t,n,i,o){kt._lock||Kn&&null!=l&&0==l.movementX&&0==l.movementY||(_i(l,e,t,n,i,o,0,!1,null!=l),null!=l?mi(null,!0,!0):mi(e,!0,!1))}function _i(l,e,t,n,i,o,s,r,u){if(null==gi&&xi(!1),bt(l),null!=l)t=l.clientX-gi.left,n=l.clientY-gi.top;else{if(0>t||0>n)return Yn=-10,void(jn=-10);let[l,s]=Ri.scales,r=e.cursor.sync,[u,a]=r.values,[f,c]=r.scales,[h,d]=Ri.match,p=e.axes[0].side%2==1,m=0==Vl.ori?Je:Qe,g=1==Vl.ori?Je:Qe,x=p?o:i,w=p?i:o,_=p?n:t,v=p?t:n;if(t=null!=f?h(l,f)?O(u,Gl[l],m,0):-10:m*(_/x),n=null!=c?d(s,c)?O(a,Gl[s],g,0):-10:g*(v/w),1==Vl.ori){let l=t;t=n,n=l}}u&&(t>1&&Je-1>t||(t=G(t,Je)),n>1&&Qe-1>n||(n=G(n,Qe))),r?(Rn=t,Fn=n,[Gn,On]=kt.move(c,t,n)):(Yn=t,jn=n)}Object.defineProperty(c,"rect",{get:()=>(null==gi&&xi(!1),gi)});const vi={width:0,height:0,left:0,top:0};function ki(){ei(vi,!1)}let bi,yi,Si,Ei;function Ti(l,e,t,n,i,o){Kn=!0,Zn=Jn=Xn._x=Xn._y=!1,_i(l,e,t,n,i,o,0,!0,!1),null!=l&&(Le(dl,yl,zi,!1),Oi(hl,c,Gn,On,Je,Qe,null));let{left:s,top:r,width:u,height:a}=Qn;bi=s,yi=r,Si=u,Ei=a,ki()}function zi(l,e,t,n,i,o){Kn=Xn._x=Xn._y=!1,_i(l,e,t,n,i,o,0,!1,!0);let{left:s,top:r,width:u,height:a}=Qn,f=u>0||a>0,h=bi!=s||yi!=r||Si!=u||Ei!=a;if(f&&h&&ei(Qn),Xn.setScale&&f&&h){let l=s,e=u,t=r,n=a;if(1==Vl.ori&&(l=r,e=a,t=s,n=u),Zn&&ti(Nl,ui(l,Nl),ui(l+e,Nl)),Jn)for(let l in Gl){let e=Gl[l];l!=Nl&&null==e.from&&e.min!=E&&ti(l,ui(t+n,l),ui(t,l))}ki()}else kt.lock&&(kt._lock=!kt._lock,mi(null,!0,!1));null!=l&&(He(dl,yl),Oi(dl,c,Yn,jn,Je,Qe,null))}function Di(l){kt._lock||(bt(l),mn(),ki(),null!=l&&Oi(gl,c,Yn,jn,Je,Qe,null))}function Pi(){Rl.forEach(Lt),wt(c.width,c.height,!0)}Yl(wl,Sl,Pi);const Ai={};Ai.mousedown=Ti,Ai.mousemove=wi,Ai.mouseup=zi,Ai.dblclick=Di,Ai.setSeries=(l,e,t,n)=>{-1!=(t=(0,Ri.match[2])(c,e,t))&&ni(t,n,!0,!1)},kt.show&&(Le(hl,al,Ti),Le(cl,al,wi),Le(pl,al,(l=>{bt(l),xi(!1)})),Le(ml,al,(function(l){if(kt._lock)return;bt(l);let e=Kn;if(Kn){let l,e,t=!0,n=!0,i=10;0==Vl.ori?(l=Zn,e=Jn):(l=Jn,e=Zn),l&&e&&(t=i>=Yn||Yn>=Je-i,n=i>=jn||jn>=Qe-i),l&&t&&(Yn=Gn>Yn?0:Je),e&&n&&(jn=On>jn?0:Qe),mi(null,!0,!0),Kn=!1}Yn=-10,jn=-10,mi(null,!0,!0),e&&(Kn=e)})),Le(gl,al,Di),yt.add(c),c.syncRect=xi);const Mi=c.hooks=t.hooks||{};function Ci(l,e,t){Hn?Un.push([l,e,t]):l in Mi&&Mi[l].forEach((l=>{l.call(null,c,e,t)}))}(t.plugins||[]).forEach((l=>{for(let e in l.hooks)Mi[e]=(Mi[e]||[]).concat(l.hooks[e])}));const Ii=(l,e,t)=>t,Ri=ll({key:null,setSeries:!1,filters:{pub:C,sub:C},scales:[Nl,Cl[1]?Cl[1].scale:null],match:[I,I,Ii],values:[null,null]},kt.sync);2==Ri.match.length&&Ri.match.push(Ii),kt.sync=Ri;const Fi=Ri.key,Gi=Ze(Fi);function Oi(l,e,t,n,i,o,s){Ri.filters.pub(l,e,t,n,i,o,s)&&Gi.pub(l,e,t,n,i,o,s)}function Li(){Ci("init",t,r),pn(r||t.data,!1),Zl[Nl]?qn(Nl,Zl[Nl]):mn(),gt=Qn.show&&(Qn.width>0||Qn.height>0),mt=xt=!0,wt(t.width,t.height)}return Gi.sub(c),c.pub=function(l,e,t,n,i,o,s){Ri.filters.sub(l,e,t,n,i,o,s)&&Ai[l](null,e,t,n,i,o,s)},c.destroy=function(){Gi.unsub(c),yt.delete(c),Oe.clear(),jl(wl,Sl,Pi),B.remove(),_e?.remove(),Ci("destroy")},Cl.forEach($t),Rl.forEach((function(l,e){if(l._show=l.show,l.show){let t=Gl[l.scale];null==t&&(l.scale=l.side%2?Cl[1].scale:Nl,t=Gl[l.scale]);let n=t.time;l.size=D(l.size),l.space=D(l.space),l.rotate=D(l.rotate),$(l.incrs)&&l.incrs.forEach((l=>{!Y.has(l)&&Y.set(l,j(l))})),l.incrs=D(l.incrs||(2==t.distr?Wl:n?1==Tl?oe:ue:ql)),l.splits=D(l.splits||(n&&1==t.distr?le:3==t.distr?Ce:4==t.distr?Ie:Me)),l.stroke=D(l.stroke),l.grid.stroke=D(l.grid.stroke),l.ticks.stroke=D(l.ticks.stroke),l.border.stroke=D(l.border.stroke);let i=l.values;l.values=$(i)&&!$(i[0])?D(i):n?$(i)?he(Jl,ce(i,Ql)):q(i)?de(Jl,i):i||ee:i||Ae,l.filter=D(l.filter||(3>t.distr||10!=t.log?3==t.distr&&2==t.log?Ye:A:Ne)),l.font=Ot(l.font),l.labelFont=Ot(l.labelFont),l._size=l.size(c,null,e,0),l._space=l._rotate=l._incrs=l._found=l._splits=l._values=null,l._size>0&&(Wt[e]=!0,l._el=Ml("u-axis",J))}})),u?u instanceof HTMLElement?(u.appendChild(B),Li()):u(c,Li):Li(),c}Nt.assign=ll,Nt.rangeNum=a,Nt.rangeLog=n,Nt.rangeAsinh=i,Nt.orient=Je,Nt.pxRatio=El,Nt.join=function(l,e){if(function(l){let e=l[0][0],t=e.length;for(let n=1;l.length>n;n++){let i=l[n][0];if(i.length!=t)return!1;if(i!=e)for(let l=0;t>l;l++)if(i[l]!=e[l])return!1}return!0}(l)){let e=l[0].slice();for(let t=1;l.length>t;t++)e.push(...l[t].slice(1));return function(l,e=100){const t=l.length;if(1>=t)return!0;let n=0,i=t-1;for(;i>=n&&null==l[n];)n++;for(;i>=n&&null==l[i];)i--;if(n>=i)return!0;const o=_(1,m((i-n+1)/e));for(let e=l[n],t=n+o;i>=t;t+=o){const n=l[t];if(null!=n){if(e>=n)return!1;e=n}}return!0}(e[0])||(e=function(l){let e=l[0],t=e.length,n=Array(t);for(let l=0;n.length>l;l++)n[l]=l;n.sort(((l,t)=>e[l]-e[t]));let i=[];for(let e=0;l.length>e;e++){let o=l[e],s=Array(t);for(let l=0;t>l;l++)s[l]=o[n[l]];i.push(s)}return i}(e)),e}let t=new Set;for(let e=0;l.length>e;e++){let n=l[e][0],i=n.length;for(let l=0;i>l;l++)t.add(n[l])}let n=[Array.from(t).sort(((l,e)=>l-e))],i=n[0].length,o=new Map;for(let l=0;i>l;l++)o.set(n[0][l],l);for(let t=0;l.length>t;t++){let s=l[t],r=s[0];for(let l=1;s.length>l;l++){let u=s[l],a=Array(i).fill(void 0),f=e?e[t][l]:1,c=[];for(let l=0;u.length>l;l++){let e=u[l],t=o.get(r[l]);null===e?0!=f&&(a[t]=e,2==f&&c.push(t)):a[t]=e}el(a,c,i),n.push(a)}}return n},Nt.tzDate=function(l,e){let t;return"UTC"==e||"Etc/UTC"==e?t=new Date(+l+6e4*l.getTimezoneOffset()):e==Bl?t=l:(t=new Date(l.toLocaleString("en-US",{timeZone:e})),t.setMilliseconds(l.getMilliseconds())),t},Nt.sync=Ze;{Nt.addGap=function(l,e,t){let n=l[l.length-1];n&&n[0]==e?n[1]=t:l.push([e,t])},Nt.clipGaps=tt;let l=Nt.paths={points:gt};l.linear=vt,l.stepped=function(l){const e=f(l.align,1),n=f(l.ascDesc,!1),i=f(l.alignGaps,0),o=f(l.extend,!1);return(l,s,r,u)=>Je(l,s,((a,f,c,h,d,p,m,g,x,w,_)=>{let v=a.pxRound,{left:k,width:b}=l.bbox,y=l=>v(p(l,h,w,g)),S=l=>v(m(l,d,_,x)),E=0==h.ori?ut:at;const T={stroke:new Path2D,fill:null,clip:null,band:null,gaps:null,flags:1},z=T.stroke,D=h.dir*(0==h.ori?1:-1);r=t(c,r,u,1),u=t(c,r,u,-1);let P=S(c[1==D?r:u]),A=y(f[1==D?r:u]),M=A,C=A;o&&-1==e&&(C=k,E(z,C,P)),E(z,A,P);for(let l=1==D?r:u;l>=r&&u>=l;l+=D){let t=c[l];if(null==t)continue;let n=y(f[l]),i=S(t);1==e?E(z,n,P):E(z,M,i),E(z,n,i),P=i,M=n}let I=M;o&&1==e&&(I=k+b,E(z,I,P));let[R,F]=Qe(l,s);if(null!=a.fill||0!=R){let e=T.fill=new Path2D(z),t=S(a.fillTo(l,s,a.min,a.max,R));E(e,I,t),E(e,C,t)}if(!a.spanGaps){let t=[];t.push(...nt(f,c,r,u,D,y,i));let o=a.width*El/2,d=n||1==e?o:-o,p=n||-1==e?-o:o;t.forEach((l=>{l[0]+=d,l[1]+=p})),T.gaps=t=a.gaps(l,s,r,u,t),T.clip=tt(t,h.ori,g,x,w,_)}return 0!=F&&(T.band=2==F?[et(l,s,r,u,z,-1),et(l,s,r,u,z,1)]:et(l,s,r,u,z,F)),T}))},l.bars=function(l){const e=f((l=l||H).size,[.6,E,1]),t=l.align||0,n=l.gap||0;let i=l.radius;i=null==i?[0,0]:"number"==typeof i?[i,0]:i;const o=D(i),s=1-e[0],r=f(e[1],E),u=f(e[2],1),a=f(l.disp,H),c=f(l.each,(()=>{})),{fill:h,stroke:d}=a;return(l,e,i,p)=>Je(l,e,((g,x,v,k,b,y,S,E,T,D,A)=>{let M,C,I=g.pxRound,R=t,F=n*El,G=r*El,O=u*El;0==k.ori?[M,C]=o(l,e):[C,M]=o(l,e);const L=k.dir*(0==k.ori?1:-1);let N,Y,j,B=0==k.ori?ft:ct,H=0==k.ori?c:(l,e,t,n,i,o,s)=>{c(l,e,t,i,n,s,o)},V=f(l.bands,U).find((l=>l.series[0]==e)),$=g.fillTo(l,e,g.min,g.max,null!=V?V.dir:0),W=I(S($,b,A,T)),q=D,K=I(g.width*El),X=!1,Z=null,J=null,Q=null,ll=null;null==h||0!=K&&null==d||(X=!0,Z=h.values(l,e,i,p),J=new Map,new Set(Z).forEach((l=>{null!=l&&J.set(l,new Path2D)})),K>0&&(Q=d.values(l,e,i,p),ll=new Map,new Set(Q).forEach((l=>{null!=l&&ll.set(l,new Path2D)}))));let{x0:el,size:tl}=a;if(null!=el&&null!=tl){R=1,x=el.values(l,e,i,p),2==el.unit&&(x=x.map((e=>l.posToVal(E+e*D,k.key,!0))));let t=tl.values(l,e,i,p);Y=2==tl.unit?t[0]*D:y(t[0],k,D,E)-y(0,k,D,E),q=kt(x,v,y,k,D,E,q),j=q-Y+F}else q=kt(x,v,y,k,D,E,q),j=q*s+F,Y=q-j;1>j&&(j=0),Y/2>K||(K=0),5>j&&(I=P);let nl=j>0;Y=I(z(q-j-(nl?K:0),O,G)),N=(0==R?Y/2:R==L?0:Y)-R*L*((0==R?F/2:0)+(nl?K/2:0));const il={stroke:null,fill:null,clip:null,band:null,gaps:null,flags:0},ol=X?null:new Path2D;let sl=null;if(null!=V)sl=l.data[V.series[1]];else{let{y0:t,y1:n}=a;null!=t&&null!=n&&(v=n.values(l,e,i,p),sl=t.values(l,e,i,p))}let rl=M*Y,ul=C*Y;for(let t=1==L?i:p;t>=i&&p>=t;t+=L){let n=v[t];if(null==n)continue;if(null!=sl){let l=sl[t]??0;if(n-l==0)continue;W=S(l,b,A,T)}let i=y(2!=k.distr||null!=a?x[t]:t,k,D,E),o=S(f(n,$),b,A,T),s=I(i-N),r=I(_(o,W)),u=I(w(o,W)),c=r-u;if(null!=n){let i=0>n?ul:rl,o=0>n?rl:ul;X?(K>0&&null!=Q[t]&&B(ll.get(Q[t]),s,u+m(K/2),Y,_(0,c-K),i,o),null!=Z[t]&&B(J.get(Z[t]),s,u+m(K/2),Y,_(0,c-K),i,o)):B(ol,s,u+m(K/2),Y,_(0,c-K),i,o),H(l,e,t,s-K/2,u,Y+K,c)}}return K>0?il.stroke=X?ll:ol:X||(il._fill=0==g.width?g._fill:g._stroke??g._fill,il.width=0),il.fill=X?J:ol,il}))},l.spline=function(l){return function(l,e){const n=f(e?.alignGaps,0);return(e,i,o,s)=>Je(e,i,((r,u,a,f,c,h,d,p,m,g,x)=>{let w,_,v,k=r.pxRound,b=l=>k(h(l,f,g,p)),y=l=>k(d(l,c,x,m));0==f.ori?(w=st,v=ut,_=pt):(w=rt,v=at,_=mt);const S=f.dir*(0==f.ori?1:-1);o=t(a,o,s,1),s=t(a,o,s,-1);let E=b(u[1==S?o:s]),T=E,z=[],D=[];for(let l=1==S?o:s;l>=o&&s>=l;l+=S)if(null!=a[l]){let e=b(u[l]);z.push(T=e),D.push(y(a[l]))}const P={stroke:l(z,D,w,v,_,k),fill:null,clip:null,band:null,gaps:null,flags:1},A=P.stroke;let[M,C]=Qe(e,i);if(null!=r.fill||0!=M){let l=P.fill=new Path2D(A),t=y(r.fillTo(e,i,r.min,r.max,M));v(l,T,t),v(l,E,t)}if(!r.spanGaps){let l=[];l.push(...nt(u,a,o,s,S,b,n)),P.gaps=l=r.gaps(e,i,o,s,l),P.clip=tt(l,f.ori,p,m,g,x)}return 0!=C&&(P.band=2==C?[et(e,i,o,s,A,-1),et(e,i,o,s,A,1)]:et(e,i,o,s,A,C)),P}))}(bt,l)}}return Nt}(); diff --git a/src/fmtDate.js b/src/fmtDate.js deleted file mode 100644 index 2bc31af0..00000000 --- a/src/fmtDate.js +++ /dev/null @@ -1,146 +0,0 @@ -import { - FEAT_TIME, -} from './feats'; - -const months = [ - "January", - "February", - "March", - "April", - "May", - "June", - "July", - "August", - "September", - "October", - "November", - "December", -]; - -const days = [ - "Sunday", - "Monday", - "Tuesday", - "Wednesday", - "Thursday", - "Friday", - "Saturday", -]; - -function slice3(str) { - return str.slice(0, 3); -} - -const days3 = FEAT_TIME && days.map(slice3); - -const months3 = FEAT_TIME && months.map(slice3); - -const engNames = { - MMMM: months, - MMM: months3, - WWWW: days, - WWW: days3, -}; - -function zeroPad2(int) { - return (int < 10 ? '0' : '') + int; -} - -function zeroPad3(int) { - return (int < 10 ? '00' : int < 100 ? '0' : '') + int; -} - -/* -function suffix(int) { - let mod10 = int % 10; - - return int + ( - mod10 == 1 && int != 11 ? "st" : - mod10 == 2 && int != 12 ? "nd" : - mod10 == 3 && int != 13 ? "rd" : "th" - ); -} -*/ - -const subs = { - // 2019 - YYYY: d => d.getFullYear(), - // 19 - YY: d => (d.getFullYear()+'').slice(2), - // July - MMMM: (d, names) => names.MMMM[d.getMonth()], - // Jul - MMM: (d, names) => names.MMM[d.getMonth()], - // 07 - MM: d => zeroPad2(d.getMonth()+1), - // 7 - M: d => d.getMonth()+1, - // 09 - DD: d => zeroPad2(d.getDate()), - // 9 - D: d => d.getDate(), - // Monday - WWWW: (d, names) => names.WWWW[d.getDay()], - // Mon - WWW: (d, names) => names.WWW[d.getDay()], - // 03 - HH: d => zeroPad2(d.getHours()), - // 3 - H: d => d.getHours(), - // 9 (12hr, unpadded) - h: d => {let h = d.getHours(); return h == 0 ? 12 : h > 12 ? h - 12 : h;}, - // AM - AA: d => d.getHours() >= 12 ? 'PM' : 'AM', - // am - aa: d => d.getHours() >= 12 ? 'pm' : 'am', - // a - a: d => d.getHours() >= 12 ? 'p' : 'a', - // 09 - mm: d => zeroPad2(d.getMinutes()), - // 9 - m: d => d.getMinutes(), - // 09 - ss: d => zeroPad2(d.getSeconds()), - // 9 - s: d => d.getSeconds(), - // 374 - fff: d => zeroPad3(d.getMilliseconds()), -}; - -export function fmtDate(tpl, names) { - names = names || engNames; - let parts = []; - - let R = /\{([a-z]+)\}|[^{]+/gi, m; - - while (m = R.exec(tpl)) - parts.push(m[0][0] == '{' ? subs[m[1]] : m[0]); - - return d => { - let out = ''; - - for (let i = 0; i < parts.length; i++) - out += typeof parts[i] == "string" ? parts[i] : parts[i](d, names); - - return out; - } -} - -const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; - -// https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 -export function tzDate(date, tz) { - let date2; - - // perf optimization - if (tz == 'UTC' || tz == 'Etc/UTC') - date2 = new Date(+date + date.getTimezoneOffset() * 6e4); - else if (tz == localTz) - date2 = date; - else { - date2 = new Date(date.toLocaleString('en-US', {timeZone: tz})); - date2.setMilliseconds(date.getMilliseconds()); - } - - return date2; -} \ No newline at end of file diff --git a/src/opts.js b/src/opts.js index f93e40ae..768c8ad5 100644 --- a/src/opts.js +++ b/src/opts.js @@ -18,7 +18,6 @@ import { incrRoundUp, roundDec, floor, - fmtNum, fixedDec, retArg1, @@ -40,8 +39,6 @@ import { setStylePx, } from './dom'; -import { fmtDate } from './fmtDate'; - //export const series = []; // default formatters: @@ -63,17 +60,14 @@ export const numIncrs = decIncrs.concat(oneIncrs); const NL = "\n"; -const yyyy = "{YYYY}"; -const NLyyyy = NL + yyyy; -const md = "{M}/{D}"; -const NLmd = NL + md; -const NLmdyy = NLmd + "/{YY}"; - -const aa = "{aa}"; -const hmm = "{h}:{mm}"; -const hmmaa = hmm + aa; -const NLhmmaa = NL + hmmaa; -const ss = ":{ss}"; +let YYYY = {year: 'numeric'}; +let MM = {month: 'numeric'}; +let MMM = {month: 'short'}; +let dd = {day: 'numeric'}; +let hh = {hour: 'numeric'}; +let mm = {minute: 'numeric'}; +let ss = {second: 'numeric'}; +let fff = { fractionalSecondDigits: 3}; const _ = null; @@ -142,16 +136,16 @@ function genTimeStuffs(ms) { // [2-7]: rollover tick formats // [8]: mode: 0: replace [1] -> [2-7], 1: concat [1] + [2-7] const _timeAxisStamps = [ - // tick incr default year month day hour min sec mode - [y, yyyy, _, _, _, _, _, _, 1], - [d * 28, "{MMM}", NLyyyy, _, _, _, _, _, 1], - [d, md, NLyyyy, _, _, _, _, _, 1], - [h, "{h}" + aa, NLmdyy, _, NLmd, _, _, _, 1], - [m, hmmaa, NLmdyy, _, NLmd, _, _, _, 1], - [s, ss, NLmdyy + " " + hmmaa, _, NLmd + " " + hmmaa, _, NLhmmaa, _, 1], - [ms, ss + ".{fff}", NLmdyy + " " + hmmaa, _, NLmd + " " + hmmaa, _, NLhmmaa, _, 1], + // tick incr default year month day hour min sec mode + [y, { ...YYYY }, _, _, _, _, _, _, 1], + [d * 28, { ...MMM }, {...YYYY}, _, _, _, _, _, 1], + [d, { ...MM, ...dd }, {...YYYY}, _, _, _, _, _, 1], + [h, { ...hh }, { ...YYYY, ...MM, ...dd}, _, {...MM, ...dd}, _, _, _, 1], + [m, { ...hh, ...mm }, { ...YYYY, ...MM, ...dd}, _, {...MM, ...dd}, _, _, _, 1], + [s, { ...ss }, { ...YYYY, ...MM, ...dd, ...hh, ...mm}, _, {...MM, ...dd, ...hh, ...mm}, _, {...hh, ...mm}, _, 1], + [ms, { ...ss, ...fff }, { ...YYYY, ...MM, ...dd, ...hh, ...mm}, _, {...MM, ...dd, ...hh, ...mm}, _, {...hh, ...mm}, _, 1], ]; - + // the ensures that axis ticks, values & grid are aligned to logical temporal breakpoints and not an arbitrary timestamp // https://www.timeanddate.com/time/dst/ // https://www.timeanddate.com/time/dst/2019.html @@ -540,7 +534,7 @@ export const xSeriesOpts = { idxs: [], }; -export function numAxisVals(self, splits, axisIdx, foundSpace, foundIncr) { +export function numAxisVals(self, splits, axisIdx, foundSpace, foundIncr, fmtNum) { return splits.map(v => v == null ? "" : fmtNum(v)); } @@ -663,7 +657,7 @@ export function log2AxisValsFilt(self, splits, axisIdx, foundSpace, foundIncr) { return splits; } -export function numSeriesVal(self, val, seriesIdx, dataIdx) { +export function numSeriesVal(self, val, seriesIdx, dataIdx, fmtNum) { return dataIdx == null ? LEGEND_DISP : val == null ? "" : fmtNum(val); } @@ -790,4 +784,4 @@ export const xScaleOpts = { export const yScaleOpts = assign({}, xScaleOpts, { time: false, ori: 1, -}); \ No newline at end of file +}); diff --git a/src/tzDate.js b/src/tzDate.js new file mode 100644 index 00000000..10658704 --- /dev/null +++ b/src/tzDate.js @@ -0,0 +1,19 @@ + +const localTz = new Intl.DateTimeFormat().resolvedOptions().timeZone; + +// https://stackoverflow.com/questions/15141762/how-to-initialize-a-javascript-date-to-a-particular-time-zone/53652131#53652131 +export function tzDate(date, tz) { + let date2; + + // perf optimization + if (tz == 'UTC' || tz == 'Etc/UTC') + date2 = new Date(+date + date.getTimezoneOffset() * 6e4); + else if (tz == localTz) + date2 = date; + else { + date2 = new Date(date.toLocaleString('en-US', {timeZone: tz})); + date2.setMilliseconds(date.getMilliseconds()); + } + + return date2; +} diff --git a/src/uPlot.js b/src/uPlot.js index 3421ba68..240e2677 100644 --- a/src/uPlot.js +++ b/src/uPlot.js @@ -17,6 +17,7 @@ import { import { copy, assign, + browserLocale, PI, inf, abs, @@ -44,7 +45,6 @@ import { fastIsObj, isStr, fnOrSelf, - fmtNum, fixedDec, ifNull, join, @@ -130,9 +130,8 @@ import { } from './dom'; import { - fmtDate, tzDate, -} from './fmtDate'; +} from './tzDate'; import { ptDia, @@ -294,7 +293,16 @@ export default function uPlot(opts, data, then) { }; const mode = self.mode; - + + const numFormatter = new Intl.NumberFormat(opts.locale || browserLocale); + const fmtNum = val => numFormatter.format(val); + self.fmtNum = fmtNum + + const fmtDate = (tsOpts) => new Intl.DateTimeFormat(opts.locale || browserLocale, tsOpts).format + if (FEAT_TIME) { + self.fmtDate = fmtDate + } + // TODO: cache denoms & mins scale.cache = {r, min, } function getValPct(val, scale) { let _val = ( @@ -1873,7 +1881,7 @@ export default 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, fmtNum); // rotating of labels only supported on bottom x axis axis._rotate = side == 2 ? axis.rotate(self, values, i, _space) : 0; @@ -2648,7 +2656,7 @@ export default function uPlot(opts, data, then) { if (multiValLegend) val = s.values(self, sidx, idx) ?? NULL_LEGEND_VALUES; else { - val = s.value(self, idx == null ? null : src[idx], sidx, idx); + val = s.value(self, idx == null ? null : src[idx], sidx, idx, fmtNum); val = val == null ? NULL_LEGEND_VALUES : {_: val}; } @@ -3460,7 +3468,6 @@ export default function uPlot(opts, data, then) { } uPlot.assign = assign; -uPlot.fmtNum = fmtNum; uPlot.rangeNum = rangeNum; uPlot.rangeLog = rangeLog; uPlot.rangeAsinh = rangeAsinh; @@ -3472,7 +3479,6 @@ if (FEAT_JOIN) { } if (FEAT_TIME) { - uPlot.fmtDate = fmtDate; uPlot.tzDate = tzDate; } diff --git a/src/utils.js b/src/utils.js index 14cfb876..20c311e1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,4 +1,4 @@ -import { domEnv, nav } from './dom'; +export const browserLocale = new Intl.DateTimeFormat().resolvedOptions().locale // binary search for index of closest value export function closestIdx(num, arr, lo, hi) { @@ -257,10 +257,6 @@ function _rangeNum(_min, _max, cfg) { return [minLim, maxLim]; } -// alternative: https://stackoverflow.com/a/2254896 -const numFormatter = new Intl.NumberFormat(domEnv ? nav.language : 'en-US'); -export const fmtNum = val => numFormatter.format(val); - const M = Math; export const PI = M.PI; @@ -659,4 +655,4 @@ function isAsc(vals, samples = 100) { } return true; -} \ No newline at end of file +}