@flowtools/uplot 0.0.9 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.es.js +39 -36
- package/dist/index.umd.js +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/utils/deepmerge.d.ts +5 -5
- package/package.json +32 -20
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
1
|
+
import { defineComponent as F, ref as D, onMounted as N, watch as v, nextTick as P, openBlock as p, createElementBlock as u, renderSlot as j, unref as d, createElementVNode as y, createTextVNode as U, toDisplayString as h, createCommentVNode as S, Fragment as L, renderList as M, normalizeClass as R, normalizeStyle as C } from "vue";
|
|
2
2
|
import q from "uplot";
|
|
3
|
-
import { useElementSize as G, useVModel as
|
|
4
|
-
|
|
3
|
+
import { useElementSize as G, useVModel as T } from "@vueuse/core";
|
|
4
|
+
function B(n) {
|
|
5
5
|
if (typeof n == "object" && n !== null) {
|
|
6
6
|
if (typeof Object.getPrototypeOf == "function") {
|
|
7
7
|
const r = Object.getPrototypeOf(n);
|
|
@@ -10,25 +10,29 @@ const E = (n) => {
|
|
|
10
10
|
return Object.prototype.toString.call(n) === "[object Object]";
|
|
11
11
|
}
|
|
12
12
|
return !1;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
}
|
|
14
|
+
function c(...n) {
|
|
15
|
+
return n.reduce((r, a) => {
|
|
16
|
+
if (Array.isArray(a))
|
|
17
|
+
throw new TypeError(
|
|
18
|
+
"Arguments provided to ts-deepmerge must be objects, not arrays."
|
|
19
|
+
);
|
|
20
|
+
return a && Object.keys(a).forEach((o) => {
|
|
21
|
+
["__proto__", "constructor", "prototype"].includes(o) || (Array.isArray(r[o]) && Array.isArray(a[o]) ? r[o] = c.options.mergeArrays ? Array.from(new Set(r[o].concat(a[o]))) : a[o] : B(r[o]) && B(a[o]) ? r[o] = c(r[o], a[o]) : r[o] = a[o]);
|
|
22
|
+
}), r;
|
|
23
|
+
}, {});
|
|
24
|
+
}
|
|
25
|
+
const E = {
|
|
22
26
|
mergeArrays: !0
|
|
23
27
|
};
|
|
24
|
-
c.options =
|
|
28
|
+
c.options = E;
|
|
25
29
|
c.withOptions = (n, ...r) => {
|
|
26
30
|
c.options = {
|
|
27
31
|
mergeArrays: !0,
|
|
28
32
|
...n
|
|
29
33
|
};
|
|
30
34
|
const a = c(...r);
|
|
31
|
-
return c.options =
|
|
35
|
+
return c.options = E, a;
|
|
32
36
|
};
|
|
33
37
|
const H = { class: "__uplot-root" }, I = {
|
|
34
38
|
key: 0,
|
|
@@ -39,7 +43,7 @@ const H = { class: "__uplot-root" }, I = {
|
|
|
39
43
|
}, Y = {
|
|
40
44
|
key: 2,
|
|
41
45
|
class: "__uplot-legend-value"
|
|
42
|
-
}, te = /* @__PURE__ */
|
|
46
|
+
}, te = /* @__PURE__ */ F({
|
|
43
47
|
__name: "uplot",
|
|
44
48
|
props: {
|
|
45
49
|
options: {},
|
|
@@ -52,7 +56,7 @@ const H = { class: "__uplot-root" }, I = {
|
|
|
52
56
|
},
|
|
53
57
|
emits: ["select", "cursor", "update:zoom", "update:series"],
|
|
54
58
|
setup(n, { expose: r, emit: a }) {
|
|
55
|
-
const o = n, _ = a, b = D(), { width: w, height: x } = G(b), z =
|
|
59
|
+
const o = n, _ = a, b = D(), { width: w, height: x } = G(b), z = T(o, "zoom", _, { passive: !0 }), i = T(o, "series", _, { passive: !0 }), $ = {
|
|
56
60
|
title: void 0,
|
|
57
61
|
legend: {
|
|
58
62
|
show: !1
|
|
@@ -73,12 +77,12 @@ const H = { class: "__uplot-root" }, I = {
|
|
|
73
77
|
setCursor: [
|
|
74
78
|
(e) => {
|
|
75
79
|
_("cursor", e.cursor), i.value = e.series.map((l, t) => {
|
|
76
|
-
var f,
|
|
80
|
+
var f, m;
|
|
77
81
|
return {
|
|
78
82
|
label: l.label,
|
|
79
83
|
stroke: typeof l.stroke == "function" ? l.stroke(e, t) : null,
|
|
80
84
|
value: e.cursor.idx && e.data[t][e.cursor.idx] ? typeof l.value == "function" ? l.value(e, e.data[t][e.cursor.idx], t, e.cursor.idx) : e.data[t][e.cursor.idx] : null,
|
|
81
|
-
data: (f = e.cursor) != null && f.idx ? e.data[t][(
|
|
85
|
+
data: (f = e.cursor) != null && f.idx ? e.data[t][(m = e.cursor) == null ? void 0 : m.idx] : null,
|
|
82
86
|
show: l.show
|
|
83
87
|
// ...s,
|
|
84
88
|
};
|
|
@@ -106,14 +110,14 @@ const H = { class: "__uplot-root" }, I = {
|
|
|
106
110
|
let s;
|
|
107
111
|
const O = D();
|
|
108
112
|
function A() {
|
|
109
|
-
s && s.destroy(), s = new q({ width: 100, height: 100, ...c(o.options,
|
|
113
|
+
s && s.destroy(), s = new q({ width: 100, height: 100, ...c(o.options, $) }, o.data, b.value), O.value = s, o.zoom[0] !== null && o.zoom[1] !== null && s.setScale("x", { min: o.zoom[0], max: o.zoom[1] }), setTimeout(() => {
|
|
110
114
|
k();
|
|
111
115
|
}, 0);
|
|
112
116
|
}
|
|
113
|
-
|
|
117
|
+
N(() => {
|
|
114
118
|
A();
|
|
115
119
|
}), v([w, x], () => {
|
|
116
|
-
|
|
120
|
+
P(() => {
|
|
117
121
|
k();
|
|
118
122
|
});
|
|
119
123
|
}), v(o.data, (e) => {
|
|
@@ -124,7 +128,7 @@ const H = { class: "__uplot-root" }, I = {
|
|
|
124
128
|
s.setData(e, !0);
|
|
125
129
|
}), v(o.options, (e, l) => {
|
|
126
130
|
o.showDebug && console.log("watch options", e, l), A();
|
|
127
|
-
}), v(() => o.zoom, (e
|
|
131
|
+
}), v(() => o.zoom, (e) => {
|
|
128
132
|
e[0] !== null && e[1] !== null && (s.scales.x.min !== e[0] || s.scales.x.max !== e[1]) && (console.log("watch zoom setScale", s.scales.x.min, e[0], s.scales.x.max, e[1]), s.setScale("x", { min: e[0], max: e[1] }));
|
|
129
133
|
});
|
|
130
134
|
function k() {
|
|
@@ -135,9 +139,8 @@ const H = { class: "__uplot-root" }, I = {
|
|
|
135
139
|
typeof e == "object" && (e = ((l = i.value) == null ? void 0 : l.indexOf(e)) || -1), s.setSeries(e, { show: !s.series[e].show }), (t = i.value) != null && t[e] && (i.value[e].show = s.series[e].show);
|
|
136
140
|
}
|
|
137
141
|
return r({ toggleShow: g, uplot: O }), (e, l) => (p(), u("div", H, [
|
|
138
|
-
j(
|
|
139
|
-
|
|
140
|
-
series: m(i),
|
|
142
|
+
j(e.$slots, "header", {
|
|
143
|
+
series: d(i),
|
|
141
144
|
toggleShow: g
|
|
142
145
|
}),
|
|
143
146
|
y("div", {
|
|
@@ -146,30 +149,30 @@ const H = { class: "__uplot-root" }, I = {
|
|
|
146
149
|
class: "__uplot"
|
|
147
150
|
}, null, 512),
|
|
148
151
|
e.showDebug ? (p(), u("div", I, [
|
|
149
|
-
|
|
152
|
+
U(h(d(w)) + " x " + h(d(x)) + " ", 1),
|
|
150
153
|
J,
|
|
151
|
-
y("pre", K, d(
|
|
154
|
+
y("pre", K, h(d(i)), 1)
|
|
152
155
|
])) : S("", !0),
|
|
153
|
-
e.noFooter ? S("", !0) :
|
|
156
|
+
e.noFooter ? S("", !0) : j(e.$slots, "footer", {
|
|
154
157
|
key: 1,
|
|
155
|
-
series:
|
|
158
|
+
series: d(i),
|
|
156
159
|
toggleShow: g
|
|
157
160
|
}, () => [
|
|
158
161
|
y("div", Q, [
|
|
159
|
-
(p(!0), u(
|
|
160
|
-
var
|
|
162
|
+
(p(!0), u(L, null, M(d(i), (t, f) => {
|
|
163
|
+
var m;
|
|
161
164
|
return p(), u("div", {
|
|
162
165
|
key: t.label,
|
|
163
|
-
class:
|
|
164
|
-
style:
|
|
166
|
+
class: R(["__uplot-legend-series", [`__uplot-${(m = t.label) == null ? void 0 : m.toLowerCase()}`, `__uplot-i-${f}`]]),
|
|
167
|
+
style: C({ backgroundColor: t.show ? "" : "lightgrey" }),
|
|
165
168
|
onClick: (Z) => g(f)
|
|
166
169
|
}, [
|
|
167
170
|
f !== 0 ? (p(), u("span", {
|
|
168
171
|
key: 0,
|
|
169
|
-
style:
|
|
172
|
+
style: C({ color: t.stroke || "black" }),
|
|
170
173
|
class: "__uplot-legend-label"
|
|
171
|
-
},
|
|
172
|
-
t.value ? (p(), u("span", X,
|
|
174
|
+
}, h(t.label), 5)) : S("", !0),
|
|
175
|
+
t.value ? (p(), u("span", X, h(t.value), 1)) : (p(), u("span", Y, "--"))
|
|
173
176
|
], 14, W);
|
|
174
177
|
}), 128))
|
|
175
178
|
])
|
package/dist/index.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(i,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue"),require("uplot"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","uplot","@vueuse/core"],o):(i=typeof globalThis<"u"?globalThis:i||self,o(i["change-name"]={},i.vue,i.Uplot,i.core))})(this,function(i,o,D,g){"use strict";
|
|
1
|
+
(function(i,o){typeof exports=="object"&&typeof module<"u"?o(exports,require("vue"),require("uplot"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","uplot","@vueuse/core"],o):(i=typeof globalThis<"u"?globalThis:i||self,o(i["change-name"]={},i.vue,i.Uplot,i.core))})(this,function(i,o,D,g){"use strict";function w(c){if(typeof c=="object"&&c!==null){if(typeof Object.getPrototypeOf=="function"){const r=Object.getPrototypeOf(c);return r===Object.prototype||r===null}return Object.prototype.toString.call(c)==="[object Object]"}return!1}function f(...c){return c.reduce((r,a)=>{if(Array.isArray(a))throw new TypeError("Arguments provided to ts-deepmerge must be objects, not arrays.");return a&&Object.keys(a).forEach(t=>{["__proto__","constructor","prototype"].includes(t)||(Array.isArray(r[t])&&Array.isArray(a[t])?r[t]=f.options.mergeArrays?Array.from(new Set(r[t].concat(a[t]))):a[t]:w(r[t])&&w(a[t])?r[t]=f(r[t],a[t]):r[t]=a[t])}),r},{})}const S={mergeArrays:!0};f.options=S,f.withOptions=(c,...r)=>{f.options={mergeArrays:!0,...c};const a=f(...r);return f.options=S,a};const E={class:"__uplot-root"},O={key:0,class:"extra-info"},A=o.createElementVNode("br",null,null,-1),j={style:{"text-align":"left"}},C={class:"__uplot-legend"},T=["onClick"],N={key:1,class:"__uplot-legend-value"},$={key:2,class:"__uplot-legend-value"},M=o.defineComponent({__name:"uplot",props:{options:{},data:{},noResetScale:{type:Boolean,default:!1},showDebug:{type:Boolean,default:!1},noFooter:{type:Boolean,default:!1},zoom:{default:()=>[null,null]},series:{}},emits:["select","cursor","update:zoom","update:series"],setup(c,{expose:r,emit:a}){const t=c,h=a,_=o.ref(),{width:y,height:b}=g.useElementSize(_),k=g.useVModel(t,"zoom",h,{passive:!0}),p=g.useVModel(t,"series",h,{passive:!0}),P={title:void 0,legend:{show:!1},hooks:{init:[e=>{t.showDebug&&console.log("init",e),p.value=e.series.map((n,l)=>({label:n.label,stroke:typeof n.stroke=="function"?n.stroke(e,l):null,value:null,data:null,show:n.show}))}],setCursor:[e=>{h("cursor",e.cursor),p.value=e.series.map((n,l)=>{var d,m;return{label:n.label,stroke:typeof n.stroke=="function"?n.stroke(e,l):null,value:e.cursor.idx&&e.data[l][e.cursor.idx]?typeof n.value=="function"?n.value(e,e.data[l][e.cursor.idx],l,e.cursor.idx):e.data[l][e.cursor.idx]:null,data:(d=e.cursor)!=null&&d.idx?e.data[l][(m=e.cursor)==null?void 0:m.idx]:null,show:n.show}})}],setSelect:[e=>{h("select",e.select),t.showDebug&&console.log("setSelect",e.select),k.value=[e.posToVal(e.select.left,"x"),e.posToVal(e.select.left+e.select.width,"x")]}],setScale:[e=>{t.showDebug&&console.log("setScale",e.scales),k.value=[e.scales.x.min||null,e.scales.x.max||null]}]}};let s;const x=o.ref();function z(){s&&s.destroy(),s=new D({width:100,height:100,...f(t.options,P)},t.data,_.value),x.value=s,t.zoom[0]!==null&&t.zoom[1]!==null&&s.setScale("x",{min:t.zoom[0],max:t.zoom[1]}),setTimeout(()=>{B()},0)}o.onMounted(()=>{z()}),o.watch([y,b],()=>{o.nextTick(()=>{B()})}),o.watch(t.data,e=>{if(t.noResetScale){s.setData(e,!1),s.redraw(!1);return}s.setData(e,!0)}),o.watch(t.options,(e,n)=>{t.showDebug&&console.log("watch options",e,n),z()}),o.watch(()=>t.zoom,e=>{e[0]!==null&&e[1]!==null&&(s.scales.x.min!==e[0]||s.scales.x.max!==e[1])&&(console.log("watch zoom setScale",s.scales.x.min,e[0],s.scales.x.max,e[1]),s.setScale("x",{min:e[0],max:e[1]}))});function B(){s.setSize({width:y.value,height:b.value}),t.showDebug&&console.log("resize",s)}function u(e){var n,l;typeof e=="object"&&(e=((n=p.value)==null?void 0:n.indexOf(e))||-1),s.setSeries(e,{show:!s.series[e].show}),(l=p.value)!=null&&l[e]&&(p.value[e].show=s.series[e].show)}return r({toggleShow:u,uplot:x}),(e,n)=>(o.openBlock(),o.createElementBlock("div",E,[o.renderSlot(e.$slots,"header",{series:o.unref(p),toggleShow:u}),o.createElementVNode("div",{ref_key:"el",ref:_,class:"__uplot"},null,512),e.showDebug?(o.openBlock(),o.createElementBlock("div",O,[o.createTextVNode(o.toDisplayString(o.unref(y))+" x "+o.toDisplayString(o.unref(b))+" ",1),A,o.createElementVNode("pre",j,o.toDisplayString(o.unref(p)),1)])):o.createCommentVNode("",!0),e.noFooter?o.createCommentVNode("",!0):o.renderSlot(e.$slots,"footer",{key:1,series:o.unref(p),toggleShow:u},()=>[o.createElementVNode("div",C,[(o.openBlock(!0),o.createElementBlock(o.Fragment,null,o.renderList(o.unref(p),(l,d)=>{var m;return o.openBlock(),o.createElementBlock("div",{key:l.label,class:o.normalizeClass(["__uplot-legend-series",[`__uplot-${(m=l.label)==null?void 0:m.toLowerCase()}`,`__uplot-i-${d}`]]),style:o.normalizeStyle({backgroundColor:l.show?"":"lightgrey"}),onClick:V=>u(d)},[d!==0?(o.openBlock(),o.createElementBlock("span",{key:0,style:o.normalizeStyle({color:l.stroke||"black"}),class:"__uplot-legend-label"},o.toDisplayString(l.label),5)):o.createCommentVNode("",!0),l.value?(o.openBlock(),o.createElementBlock("span",N,o.toDisplayString(l.value),1)):(o.openBlock(),o.createElementBlock("span",$,"--"))],14,T)}),128))])])]))}});i.Uplot=M,Object.defineProperty(i,Symbol.toStringTag,{value:"Module"})});
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { default as Uplot } from './components/
|
|
1
|
+
export { default as Uplot } from './components/uplot.vue';
|
|
@@ -13,11 +13,11 @@ type TMerged<T> = [T] extends [Array<any>] ? {
|
|
|
13
13
|
interface IObject {
|
|
14
14
|
[key: string]: any;
|
|
15
15
|
}
|
|
16
|
-
declare
|
|
17
|
-
|
|
18
|
-
options: IOptions;
|
|
19
|
-
withOptions<
|
|
20
|
-
}
|
|
16
|
+
declare function merge<T extends IObject[]>(...objects: T): TMerged<T[number]>;
|
|
17
|
+
declare namespace merge {
|
|
18
|
+
var options: IOptions;
|
|
19
|
+
var withOptions: <T extends IObject[]>(options: Partial<IOptions>, ...objects: T) => TMerged<T[number]>;
|
|
20
|
+
}
|
|
21
21
|
interface IOptions {
|
|
22
22
|
mergeArrays: boolean;
|
|
23
23
|
}
|
package/package.json
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flowtools/uplot",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.11",
|
|
5
|
+
"packageManager": "pnpm@8.14.0",
|
|
5
6
|
"description": "Modern vue component for uplot",
|
|
6
|
-
"
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
"author": "Jukka Raimovaara <roska@mentalhouse.fi> (Mentalhouse Oy)",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"funding": "https://github.com/sponsors/flow-tools",
|
|
9
10
|
"homepage": "https://github.com/flow-tools/uplot",
|
|
10
|
-
"bugs": "https://github.com/flow-tools/uplot",
|
|
11
|
-
"author": "add author",
|
|
12
11
|
"repository": {
|
|
13
12
|
"type": "git",
|
|
14
13
|
"url": "https://github.com/flow-tools/uplot.git"
|
|
15
14
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
|
|
20
|
-
|
|
15
|
+
"bugs": "https://github.com/flow-tools/uplot",
|
|
16
|
+
"keywords": [
|
|
17
|
+
"vue",
|
|
18
|
+
"uplot",
|
|
19
|
+
"chart",
|
|
20
|
+
"component"
|
|
21
|
+
],
|
|
21
22
|
"exports": {
|
|
22
23
|
".": {
|
|
23
|
-
"
|
|
24
|
-
"
|
|
24
|
+
"types": "./dist/index.d.ts",
|
|
25
|
+
"import": "./dist/index.es.js"
|
|
25
26
|
},
|
|
26
27
|
"./dist/style.css": "./dist/style.css"
|
|
27
28
|
},
|
|
28
29
|
"main": "./dist/index.es.js",
|
|
29
30
|
"types": "./dist/index.d.ts",
|
|
30
31
|
"files": [
|
|
31
|
-
"dist",
|
|
32
32
|
"LICENSE",
|
|
33
|
-
"README.md"
|
|
33
|
+
"README.md",
|
|
34
|
+
"dist"
|
|
34
35
|
],
|
|
35
|
-
"
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=18"
|
|
38
|
+
},
|
|
36
39
|
"peerDependencies": {
|
|
37
40
|
"@vueuse/core": "^9.13.0",
|
|
38
41
|
"uplot": "^1.6.24",
|
|
@@ -41,12 +44,14 @@
|
|
|
41
44
|
"devDependencies": {
|
|
42
45
|
"@antfu/eslint-config": "^2.6.3",
|
|
43
46
|
"@vitejs/plugin-vue": "^5.0.3",
|
|
44
|
-
"@vitest/coverage-
|
|
47
|
+
"@vitest/coverage-v8": "^1.2.1",
|
|
45
48
|
"@vue/test-utils": "^2.4.3",
|
|
46
49
|
"@vueuse/core": "^10.7.2",
|
|
47
50
|
"bumpp": "^9.3.0",
|
|
48
51
|
"eslint": "^8.56.0",
|
|
49
52
|
"jsdom": "^24.0.0",
|
|
53
|
+
"lint-staged": "^15.2.0",
|
|
54
|
+
"simple-git-hooks": "^2.9.0",
|
|
50
55
|
"typescript": "^5.3.3",
|
|
51
56
|
"uplot": "^1.6.28",
|
|
52
57
|
"vi-canvas-mock": "^1.0.0",
|
|
@@ -55,6 +60,12 @@
|
|
|
55
60
|
"vitest": "^1.2.1",
|
|
56
61
|
"vue": "^3.4.15"
|
|
57
62
|
},
|
|
63
|
+
"simple-git-hooks": {
|
|
64
|
+
"pre-commit": "pnpm lint-staged"
|
|
65
|
+
},
|
|
66
|
+
"lint-staged": {
|
|
67
|
+
"*": "pnpm eslint . --fix"
|
|
68
|
+
},
|
|
58
69
|
"publishConfig": {
|
|
59
70
|
"access": "public"
|
|
60
71
|
},
|
|
@@ -62,10 +73,11 @@
|
|
|
62
73
|
"build": "vite build --mode production",
|
|
63
74
|
"dev": "vite",
|
|
64
75
|
"release": "pnpm build && bumpp --commit --push --tag && pnpm publish",
|
|
65
|
-
"lint": "eslint
|
|
66
|
-
"lint:fix": "eslint
|
|
76
|
+
"lint": "eslint .",
|
|
77
|
+
"lint:fix": "eslint . --fix",
|
|
67
78
|
"test": "vitest",
|
|
68
79
|
"test:watch": "vitest --watch",
|
|
69
|
-
"coverage": "vitest run --coverage"
|
|
80
|
+
"coverage": "vitest run --coverage",
|
|
81
|
+
"postinstall": "npx simple-git-hooks"
|
|
70
82
|
}
|
|
71
83
|
}
|