geekin-devtoys 0.2.10 → 0.2.12
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/lib/GBubble/index.js +2 -2
- package/lib/GBubble/index.mjs +143 -166
- package/lib/GBubble/style.css +1 -1
- package/lib/GBubble.d.ts +1 -0
- package/lib/GCount/index.js +1 -1
- package/lib/GCount/index.mjs +65 -52
- package/lib/GCount.d.ts +1 -0
- package/lib/GDialog/index.js +1 -1
- package/lib/GDialog/index.mjs +109 -99
- package/lib/GDialog/style.css +1 -1
- package/lib/GDialog.d.ts +1 -0
- package/lib/GPie3D/index.js +1 -0
- package/lib/GPie3D/index.mjs +227 -0
- package/lib/GPie3D.d.ts +1 -0
- package/lib/GPluginVideo/index.js +1 -14
- package/lib/GPluginVideo/index.mjs +1431 -3470
- package/lib/GPluginVideo.d.ts +1 -0
- package/lib/GProgress/index.js +1 -1
- package/lib/GProgress/index.mjs +21 -54
- package/lib/GProgress/style.css +1 -1
- package/lib/GProgress.d.ts +1 -0
- package/lib/GScreen/index.js +1 -1
- package/lib/GScreen/index.mjs +36 -173
- package/lib/GScreen.d.ts +1 -0
- package/lib/GTable/index.js +1 -1
- package/lib/GTable/index.mjs +135 -1436
- package/lib/GTable/style.css +1 -1
- package/lib/GTable.d.ts +1 -0
- package/lib/GVideo/index.js +2 -7
- package/lib/GVideo/index.mjs +125 -6899
- package/lib/GVideo/style.css +1 -1
- package/lib/GVideo.d.ts +1 -0
- package/lib/assets/GPie3D.css +1 -0
- package/lib/components/GBubble/index.d.ts +61 -0
- package/lib/components/GCount/index.d.ts +39 -0
- package/lib/components/GDialog/GDialogMinimizedIcon.d.ts +17 -0
- package/lib/components/GDialog/const.d.ts +25 -0
- package/lib/components/GDialog/index.d.ts +53 -0
- package/lib/components/GDialog/useDialogManager.d.ts +58 -0
- package/lib/components/GPie3D/index.d.ts +118 -0
- package/lib/components/GPluginVideo/index.d.ts +3 -0
- package/lib/components/GProgress/index.d.ts +48 -0
- package/lib/components/GScreen/index.d.ts +55 -0
- package/lib/components/GTable/index.d.ts +119 -0
- package/lib/components/GVideo/index.d.ts +3 -0
- package/lib/index/index.js +1 -1
- package/lib/index/index.mjs +24 -27
- package/lib/index-B1MYKy3L.js +1 -0
- package/lib/index-Dxw2pU4z.mjs +106 -0
- package/lib/index.d.ts +13 -0
- package/package.json +33 -10
- package/lib/GPercent/index.js +0 -1
- package/lib/GPercent/index.mjs +0 -127
- package/lib/GPercent/style.css +0 -1
- package/lib/index-BVvzBt8u.mjs +0 -53
- package/lib/index-CC5ivGYd.js +0 -1
package/lib/GBubble/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("vue"),J=require("../_plugin-vue_export-helper-BHFhmbuH.js"),K={__name:"index",props:{data:{
|
|
2
|
-
`);
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const f=require("vue"),J=require("../_plugin-vue_export-helper-BHFhmbuH.js"),K=f.defineComponent({__name:"index",props:{data:{default:()=>[]},config:{default:()=>({minRadius:25,maxRadius:100,padding:10,colors:["#1E88E5","#26A69A","#4CAF50","#F57C00","#9C27B0","#FF5722","#607D8B"],textColor:"#FFFFFF"})},animation:{type:Boolean,default:!0}},setup(I){const _=I,X=f.ref(null),S=f.ref(null);let j=null,m=0,y=0;const Y={..._.config},k=f.ref(!1),z=f.ref(0),H=f.ref(0),P=f.ref(null);let L=f.ref(-1),c=[],V=null;const $=()=>{if(!S.value||!X.value)return;const t=X.value,n=S.value;t.style.width="100%",t.style.height="100%",m=t.clientWidth,y=t.clientHeight,n.width=m,n.height=y,n.style.width=m+"px",n.style.height=y+"px",j=n.getContext("2d"),T(),G()},T=()=>{c=[];const t=_.data,n=t.map(d=>d.value),h=Math.max(...n),l=Math.min(...n),u=h-l;t.forEach((d,e)=>{const M=u>0?(d.value-l)/u:.5,a=Y.minRadius+(Y.maxRadius-Y.minRadius)*M,p=e/t.length*Math.PI*2,R=m/2,s=y/2,o=Math.min(m,y)/3;let i=R+Math.cos(p)*o,r=s+Math.sin(p)*o;i=Math.max(a,Math.min(m-a,i)),r=Math.max(a,Math.min(y-a,r)),c.push({x:i,y:r,radius:a,data:d,color:Y.colors[e%Y.colors.length],vx:(Math.random()-.5)*.2,vy:(Math.random()-.5)*.2,value:d.value})});const v=1500,g=.2,B=.9;for(let d=0;d<v;d++){const e=c.map(()=>({x:0,y:0}));for(let s=0;s<c.length;s++){const o=c[s];for(let i=s+1;i<c.length;i++){const r=c[i],x=o.x-r.x,C=o.y-r.y,F=Math.sqrt(x*x+C*C),D=o.radius+r.radius+Y.padding;if(F<D){const q=(D-F)*g,A=x/F*q,E=C/F*q;e[s].x+=A,e[s].y+=E,e[i].x-=A,e[i].y-=E}else if(F>0){const q=1/F*g*5,A=x/F*q,E=C/F*q;e[s].x+=A,e[s].y+=E,e[i].x-=A,e[i].y-=E}}}const M=m/2,a=y/2,p=.01;for(let s=0;s<c.length;s++){const o=c[s],i=M-o.x,r=a-o.y,x=Math.sqrt(i*i+r*r);if(x>0){const C=x*p,F=i/x*C,D=r/x*C;e[s].x+=F,e[s].y+=D}}let R=0;for(let s=0;s<c.length;s++){const o=c[s],i=e[s],r=i.x*B,x=i.y*B,C=Math.sqrt(r*r+x*x);R+=C,o.x+=r,o.y+=x,o.x=Math.max(o.radius,Math.min(m-o.radius,o.x)),o.y=Math.max(o.radius,Math.min(y-o.radius,o.y))}if(R<.1)break}for(let d=0;d<c.length;d++){const e=c[d];for(let M=d+1;M<c.length;M++){const a=c[M],p=e.x-a.x,R=e.y-a.y,s=Math.sqrt(p*p+R*R),o=e.radius+a.radius+Y.padding;if(s<o){const i=Math.atan2(R,p),r=(o-s)/2;e.x+=Math.cos(i)*r,e.y+=Math.sin(i)*r,a.x-=Math.cos(i)*r,a.y-=Math.sin(i)*r,e.x=Math.max(e.radius,Math.min(m-e.radius,e.x)),e.y=Math.max(e.radius,Math.min(y-e.radius,e.y)),a.x=Math.max(a.radius,Math.min(m-a.radius,a.x)),a.y=Math.max(a.radius,Math.min(y-a.radius,a.y))}}}},G=()=>{if(!j)return;const t=j;t.clearRect(0,0,m,y),_.animation&&N(),c.forEach((n,h)=>{const{x:l,y:u,radius:v,color:g}=n;t.beginPath(),t.arc(l,u,v,0,Math.PI*2);const B=t.createRadialGradient(l-v*.3,u-v*.3,0,l,u,v);B.addColorStop(0,g),B.addColorStop(1,g+"40"),t.fillStyle=B,t.fill();const d=m*.2,e=y*.2,M=d-l,a=e-u,p=Math.sqrt(M*M+a*a),R=l+M/p*v*.6,s=u+a/p*v*.6;t.beginPath(),t.arc(R,s,v*.3,0,Math.PI*2),t.fillStyle="rgba(255, 255, 255, 0.1)",t.fill(),t.fillStyle=Y.textColor??"",t.textAlign="center",t.textBaseline="middle";const o=Math.max(10,v/2.5);t.font=`${o}px Arial`;const i=n.data.name.split(`
|
|
2
|
+
`);i.forEach((r,x)=>{const C=u-(i.length-1)*o/2+x*o;t.fillText(r,l,C)})}),_.animation&&(V=requestAnimationFrame(G))},N=()=>{c.forEach(t=>{if(t.x+=t.vx,t.y+=t.vy,t.x-t.radius<0&&(t.x=t.radius,t.vx=-t.vx*.8),t.x+t.radius>m&&(t.x=m-t.radius,t.vx=-t.vx*.8),t.y-t.radius<0&&(t.y=t.radius,t.vy=-t.vy*.8),t.y+t.radius>y&&(t.y=y-t.radius,t.vy=-t.vy*.8),Math.random()<.01){t.vx+=(Math.random()-.5)*.1,t.vy+=(Math.random()-.5)*.1;const n=.3,h=Math.sqrt(t.vx*t.vx+t.vy*t.vy);h>n&&(t.vx=t.vx/h*n,t.vy=t.vy/h*n)}});for(let t=0;t<c.length;t++)for(let n=t+1;n<c.length;n++){const h=c[t],l=c[n],u=h.x-l.x,v=h.y-l.y,g=Math.sqrt(u*u+v*v),B=h.radius+l.radius;if(g<B){const d=Math.atan2(v,u),e=B-g,M=Math.cos(d)*e/2,a=Math.sin(d)*e/2;h.x+=M,h.y+=a,l.x-=M,l.y-=a;const p=h.vx,R=h.vy;h.vx=l.vx*.8,h.vy=l.vy*.8,l.vx=p*.8,l.vy=R*.8}}},O=t=>{if(!S.value)return;const n=S.value.getBoundingClientRect(),h=t.clientX-n.left,l=t.clientY-n.top;let u=-1;for(let v=0;v<c.length;v++){const g=c[v],B=h-g.x,d=l-g.y;if(Math.sqrt(B*B+d*d)<=g.radius){u=v;break}}u!==L.value?(L.value=u,u>=0?(k.value=!0,P.value=c[u].data,W(t)):(k.value=!1,P.value=null)):u>=0&&W(t)},W=t=>{if(X.value){const n=X.value.getBoundingClientRect(),h=120,l=60;z.value=Math.min(t.clientX+10-n.left,n.width-h),H.value=Math.min(t.clientY+10-n.top,n.height-l)}else z.value=t.clientX+10,H.value=t.clientY+10},U=()=>{k.value=!1,P.value=null,L.value=-1};return f.watch(()=>_.data,()=>{T(),G()},{deep:!0}),f.onMounted(()=>{$(),window.addEventListener("resize",$)}),f.onUnmounted(()=>{window.removeEventListener("resize",$),V&&(cancelAnimationFrame(V),V=null)}),(t,n)=>(f.openBlock(),f.createElementBlock("div",{class:"bubble-chart-container",ref_key:"containerRef",ref:X},[f.createElementVNode("canvas",{ref_key:"canvasRef",ref:S,onMousemove:O,onMouseleave:U},null,544),k.value?(f.openBlock(),f.createElementBlock("div",{key:0,class:"bubble-tooltip",style:f.normalizeStyle({left:`${z.value}px`,top:`${H.value}px`})},[f.renderSlot(t.$slots,"tooltip",{data:P.value},void 0,!0)],4)):f.createCommentVNode("",!0)],512))}}),w=J._export_sfc(K,[["__scopeId","data-v-f39dd155"]]);w.install=I=>{I.component(w.name,w)};exports.GBubble=w;exports.default=w;
|
package/lib/GBubble/index.mjs
CHANGED
|
@@ -1,233 +1,210 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { _ as
|
|
3
|
-
const
|
|
1
|
+
import { defineComponent as Q, ref as Y, watch as Z, onMounted as b, onUnmounted as tt, createElementBlock as T, openBlock as U, createElementVNode as nt, createCommentVNode as et, normalizeStyle as at, renderSlot as ot } from "vue";
|
|
2
|
+
import { _ as st } from "../_plugin-vue_export-helper-CHgC5LLL.mjs";
|
|
3
|
+
const it = /* @__PURE__ */ Q({
|
|
4
4
|
__name: "index",
|
|
5
5
|
props: {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* @description 自定义气泡样式配置
|
|
17
|
-
* @version 0.1.6
|
|
18
|
-
* @default {}
|
|
19
|
-
*/
|
|
20
|
-
config: {
|
|
21
|
-
type: Object,
|
|
22
|
-
default: () => ({
|
|
23
|
-
minRadius: 25,
|
|
24
|
-
maxRadius: 100,
|
|
25
|
-
padding: 10,
|
|
26
|
-
colors: ["#1E88E5", "#26A69A", "#4CAF50", "#F57C00", "#9C27B0", "#FF5722", "#607D8B"],
|
|
27
|
-
textColor: "#FFFFFF"
|
|
28
|
-
})
|
|
29
|
-
},
|
|
30
|
-
/**
|
|
31
|
-
* @description 是否开启气泡图的动画效果
|
|
32
|
-
* @version 0.1.6
|
|
33
|
-
* @default true
|
|
34
|
-
*/
|
|
35
|
-
animation: {
|
|
36
|
-
type: Boolean,
|
|
37
|
-
default: !0
|
|
38
|
-
}
|
|
6
|
+
data: { default: () => [] },
|
|
7
|
+
config: { default: () => ({
|
|
8
|
+
minRadius: 25,
|
|
9
|
+
maxRadius: 100,
|
|
10
|
+
padding: 10,
|
|
11
|
+
colors: ["#1E88E5", "#26A69A", "#4CAF50", "#F57C00", "#9C27B0", "#FF5722", "#607D8B"],
|
|
12
|
+
textColor: "#FFFFFF"
|
|
13
|
+
}) },
|
|
14
|
+
animation: { type: Boolean, default: !0 }
|
|
39
15
|
},
|
|
40
|
-
setup(
|
|
41
|
-
const
|
|
42
|
-
let
|
|
43
|
-
const
|
|
44
|
-
...
|
|
45
|
-
},
|
|
46
|
-
let
|
|
47
|
-
const
|
|
48
|
-
if (!
|
|
49
|
-
const t = _.value,
|
|
50
|
-
t.style.width = "100%", t.style.height = "100%", f = t.clientWidth, m = t.clientHeight,
|
|
16
|
+
setup(P) {
|
|
17
|
+
const X = P, _ = Y(null), A = Y(null);
|
|
18
|
+
let V = null, f = 0, m = 0;
|
|
19
|
+
const F = {
|
|
20
|
+
...X.config
|
|
21
|
+
}, q = Y(!1), z = Y(0), L = Y(0), k = Y(null);
|
|
22
|
+
let $ = Y(-1), c = [], D = null;
|
|
23
|
+
const j = () => {
|
|
24
|
+
if (!A.value || !_.value) return;
|
|
25
|
+
const t = _.value, e = A.value;
|
|
26
|
+
t.style.width = "100%", t.style.height = "100%", f = t.clientWidth, m = t.clientHeight, e.width = f, e.height = m, e.style.width = f + "px", e.style.height = m + "px", V = e.getContext("2d"), G(), H();
|
|
51
27
|
}, G = () => {
|
|
52
|
-
|
|
53
|
-
const t =
|
|
54
|
-
t.forEach((
|
|
55
|
-
const y =
|
|
56
|
-
let
|
|
57
|
-
|
|
58
|
-
x:
|
|
59
|
-
y:
|
|
60
|
-
radius:
|
|
61
|
-
data:
|
|
62
|
-
color:
|
|
28
|
+
c = [];
|
|
29
|
+
const t = X.data, e = t.map((d) => d.value), h = Math.max(...e), l = Math.min(...e), u = h - l;
|
|
30
|
+
t.forEach((d, n) => {
|
|
31
|
+
const y = u > 0 ? (d.value - l) / u : 0.5, a = F.minRadius + (F.maxRadius - F.minRadius) * y, M = n / t.length * Math.PI * 2, B = f / 2, s = m / 2, o = Math.min(f, m) / 3;
|
|
32
|
+
let i = B + Math.cos(M) * o, r = s + Math.sin(M) * o;
|
|
33
|
+
i = Math.max(a, Math.min(f - a, i)), r = Math.max(a, Math.min(m - a, r)), c.push({
|
|
34
|
+
x: i,
|
|
35
|
+
y: r,
|
|
36
|
+
radius: a,
|
|
37
|
+
data: d,
|
|
38
|
+
color: F.colors[n % F.colors.length],
|
|
63
39
|
// 随机初始速度(更缓慢移动)
|
|
64
40
|
vx: (Math.random() - 0.5) * 0.2,
|
|
65
|
-
vy: (Math.random() - 0.5) * 0.2
|
|
41
|
+
vy: (Math.random() - 0.5) * 0.2,
|
|
42
|
+
value: d.value
|
|
66
43
|
});
|
|
67
44
|
});
|
|
68
|
-
const
|
|
69
|
-
for (let
|
|
70
|
-
const n =
|
|
71
|
-
for (let
|
|
72
|
-
const
|
|
73
|
-
for (let
|
|
74
|
-
const
|
|
75
|
-
if (
|
|
76
|
-
const
|
|
77
|
-
n[
|
|
78
|
-
} else if (
|
|
79
|
-
const
|
|
80
|
-
n[
|
|
45
|
+
const x = 1500, p = 0.2, g = 0.9;
|
|
46
|
+
for (let d = 0; d < x; d++) {
|
|
47
|
+
const n = c.map(() => ({ x: 0, y: 0 }));
|
|
48
|
+
for (let s = 0; s < c.length; s++) {
|
|
49
|
+
const o = c[s];
|
|
50
|
+
for (let i = s + 1; i < c.length; i++) {
|
|
51
|
+
const r = c[i], v = o.x - r.x, R = o.y - r.y, C = Math.sqrt(v * v + R * R), I = o.radius + r.radius + F.padding;
|
|
52
|
+
if (C < I) {
|
|
53
|
+
const S = (I - C) * p, w = v / C * S, E = R / C * S;
|
|
54
|
+
n[s].x += w, n[s].y += E, n[i].x -= w, n[i].y -= E;
|
|
55
|
+
} else if (C > 0) {
|
|
56
|
+
const S = 1 / C * p * 5, w = v / C * S, E = R / C * S;
|
|
57
|
+
n[s].x += w, n[s].y += E, n[i].x -= w, n[i].y -= E;
|
|
81
58
|
}
|
|
82
59
|
}
|
|
83
60
|
}
|
|
84
|
-
const y = f / 2,
|
|
85
|
-
for (let
|
|
86
|
-
const
|
|
61
|
+
const y = f / 2, a = m / 2, M = 0.01;
|
|
62
|
+
for (let s = 0; s < c.length; s++) {
|
|
63
|
+
const o = c[s], i = y - o.x, r = a - o.y, v = Math.sqrt(i * i + r * r);
|
|
87
64
|
if (v > 0) {
|
|
88
|
-
const
|
|
89
|
-
n[
|
|
65
|
+
const R = v * M, C = i / v * R, I = r / v * R;
|
|
66
|
+
n[s].x += C, n[s].y += I;
|
|
90
67
|
}
|
|
91
68
|
}
|
|
92
69
|
let B = 0;
|
|
93
|
-
for (let
|
|
94
|
-
const
|
|
95
|
-
B +=
|
|
70
|
+
for (let s = 0; s < c.length; s++) {
|
|
71
|
+
const o = c[s], i = n[s], r = i.x * g, v = i.y * g, R = Math.sqrt(r * r + v * v);
|
|
72
|
+
B += R, o.x += r, o.y += v, o.x = Math.max(o.radius, Math.min(f - o.radius, o.x)), o.y = Math.max(o.radius, Math.min(m - o.radius, o.y));
|
|
96
73
|
}
|
|
97
74
|
if (B < 0.1)
|
|
98
75
|
break;
|
|
99
76
|
}
|
|
100
|
-
for (let
|
|
101
|
-
const n =
|
|
102
|
-
for (let y =
|
|
103
|
-
const
|
|
104
|
-
if (
|
|
105
|
-
const
|
|
106
|
-
n.x += Math.cos(
|
|
77
|
+
for (let d = 0; d < c.length; d++) {
|
|
78
|
+
const n = c[d];
|
|
79
|
+
for (let y = d + 1; y < c.length; y++) {
|
|
80
|
+
const a = c[y], M = n.x - a.x, B = n.y - a.y, s = Math.sqrt(M * M + B * B), o = n.radius + a.radius + F.padding;
|
|
81
|
+
if (s < o) {
|
|
82
|
+
const i = Math.atan2(B, M), r = (o - s) / 2;
|
|
83
|
+
n.x += Math.cos(i) * r, n.y += Math.sin(i) * r, a.x -= Math.cos(i) * r, a.y -= Math.sin(i) * r, n.x = Math.max(
|
|
107
84
|
n.radius,
|
|
108
85
|
Math.min(f - n.radius, n.x)
|
|
109
86
|
), n.y = Math.max(
|
|
110
87
|
n.radius,
|
|
111
88
|
Math.min(m - n.radius, n.y)
|
|
112
|
-
),
|
|
113
|
-
|
|
114
|
-
Math.min(f -
|
|
115
|
-
),
|
|
116
|
-
|
|
117
|
-
Math.min(m -
|
|
89
|
+
), a.x = Math.max(
|
|
90
|
+
a.radius,
|
|
91
|
+
Math.min(f - a.radius, a.x)
|
|
92
|
+
), a.y = Math.max(
|
|
93
|
+
a.radius,
|
|
94
|
+
Math.min(m - a.radius, a.y)
|
|
118
95
|
);
|
|
119
96
|
}
|
|
120
97
|
}
|
|
121
98
|
}
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const { x:
|
|
127
|
-
|
|
128
|
-
const g =
|
|
129
|
-
|
|
130
|
-
|
|
99
|
+
}, H = () => {
|
|
100
|
+
if (!V) return;
|
|
101
|
+
const t = V;
|
|
102
|
+
t.clearRect(0, 0, f, m), X.animation && J(), c.forEach((e, h) => {
|
|
103
|
+
const { x: l, y: u, radius: x, color: p } = e;
|
|
104
|
+
t.beginPath(), t.arc(l, u, x, 0, Math.PI * 2);
|
|
105
|
+
const g = t.createRadialGradient(
|
|
106
|
+
l - x * 0.3,
|
|
107
|
+
u - x * 0.3,
|
|
131
108
|
0,
|
|
132
109
|
// 渐变中心(稍微偏移,增加立体感)
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
110
|
+
l,
|
|
111
|
+
u,
|
|
112
|
+
x
|
|
136
113
|
// 渐变边缘
|
|
137
114
|
);
|
|
138
|
-
g.addColorStop(0,
|
|
139
|
-
const
|
|
140
|
-
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
const
|
|
115
|
+
g.addColorStop(0, p), g.addColorStop(1, p + "40"), t.fillStyle = g, t.fill();
|
|
116
|
+
const d = f * 0.2, n = m * 0.2, y = d - l, a = n - u, M = Math.sqrt(y * y + a * a), B = l + y / M * x * 0.6, s = u + a / M * x * 0.6;
|
|
117
|
+
t.beginPath(), t.arc(B, s, x * 0.3, 0, Math.PI * 2), t.fillStyle = "rgba(255, 255, 255, 0.1)", t.fill(), t.fillStyle = F.textColor ?? "", t.textAlign = "center", t.textBaseline = "middle";
|
|
118
|
+
const o = Math.max(10, x / 2.5);
|
|
119
|
+
t.font = `${o}px Arial`;
|
|
120
|
+
const i = e.data.name.split(`
|
|
144
121
|
`);
|
|
145
|
-
|
|
146
|
-
const
|
|
147
|
-
|
|
122
|
+
i.forEach((r, v) => {
|
|
123
|
+
const R = u - (i.length - 1) * o / 2 + v * o;
|
|
124
|
+
t.fillText(r, l, R);
|
|
148
125
|
});
|
|
149
|
-
}),
|
|
150
|
-
},
|
|
151
|
-
|
|
126
|
+
}), X.animation && (D = requestAnimationFrame(H));
|
|
127
|
+
}, J = () => {
|
|
128
|
+
c.forEach((t) => {
|
|
152
129
|
if (t.x += t.vx, t.y += t.vy, t.x - t.radius < 0 && (t.x = t.radius, t.vx = -t.vx * 0.8), t.x + t.radius > f && (t.x = f - t.radius, t.vx = -t.vx * 0.8), t.y - t.radius < 0 && (t.y = t.radius, t.vy = -t.vy * 0.8), t.y + t.radius > m && (t.y = m - t.radius, t.vy = -t.vy * 0.8), Math.random() < 0.01) {
|
|
153
130
|
t.vx += (Math.random() - 0.5) * 0.1, t.vy += (Math.random() - 0.5) * 0.1;
|
|
154
|
-
const
|
|
155
|
-
|
|
131
|
+
const e = 0.3, h = Math.sqrt(t.vx * t.vx + t.vy * t.vy);
|
|
132
|
+
h > e && (t.vx = t.vx / h * e, t.vy = t.vy / h * e);
|
|
156
133
|
}
|
|
157
134
|
});
|
|
158
|
-
for (let t = 0; t <
|
|
159
|
-
for (let
|
|
160
|
-
const
|
|
161
|
-
if (
|
|
162
|
-
const
|
|
163
|
-
|
|
164
|
-
const
|
|
165
|
-
|
|
135
|
+
for (let t = 0; t < c.length; t++)
|
|
136
|
+
for (let e = t + 1; e < c.length; e++) {
|
|
137
|
+
const h = c[t], l = c[e], u = h.x - l.x, x = h.y - l.y, p = Math.sqrt(u * u + x * x), g = h.radius + l.radius;
|
|
138
|
+
if (p < g) {
|
|
139
|
+
const d = Math.atan2(x, u), n = g - p, y = Math.cos(d) * n / 2, a = Math.sin(d) * n / 2;
|
|
140
|
+
h.x += y, h.y += a, l.x -= y, l.y -= a;
|
|
141
|
+
const M = h.vx, B = h.vy;
|
|
142
|
+
h.vx = l.vx * 0.8, h.vy = l.vy * 0.8, l.vx = M * 0.8, l.vy = B * 0.8;
|
|
166
143
|
}
|
|
167
144
|
}
|
|
168
|
-
},
|
|
169
|
-
if (!
|
|
170
|
-
const
|
|
171
|
-
let
|
|
172
|
-
for (let
|
|
173
|
-
const
|
|
174
|
-
if (Math.sqrt(g * g +
|
|
175
|
-
|
|
145
|
+
}, K = (t) => {
|
|
146
|
+
if (!A.value) return;
|
|
147
|
+
const e = A.value.getBoundingClientRect(), h = t.clientX - e.left, l = t.clientY - e.top;
|
|
148
|
+
let u = -1;
|
|
149
|
+
for (let x = 0; x < c.length; x++) {
|
|
150
|
+
const p = c[x], g = h - p.x, d = l - p.y;
|
|
151
|
+
if (Math.sqrt(g * g + d * d) <= p.radius) {
|
|
152
|
+
u = x;
|
|
176
153
|
break;
|
|
177
154
|
}
|
|
178
155
|
}
|
|
179
|
-
|
|
156
|
+
u !== $.value ? ($.value = u, u >= 0 ? (q.value = !0, k.value = c[u].data, N(t)) : (q.value = !1, k.value = null)) : u >= 0 && N(t);
|
|
180
157
|
}, N = (t) => {
|
|
181
158
|
if (_.value) {
|
|
182
|
-
const
|
|
183
|
-
|
|
184
|
-
t.clientX + 10 -
|
|
185
|
-
|
|
186
|
-
),
|
|
187
|
-
t.clientY + 10 -
|
|
188
|
-
|
|
159
|
+
const e = _.value.getBoundingClientRect(), h = 120, l = 60;
|
|
160
|
+
z.value = Math.min(
|
|
161
|
+
t.clientX + 10 - e.left,
|
|
162
|
+
e.width - h
|
|
163
|
+
), L.value = Math.min(
|
|
164
|
+
t.clientY + 10 - e.top,
|
|
165
|
+
e.height - l
|
|
189
166
|
);
|
|
190
167
|
} else
|
|
191
|
-
|
|
192
|
-
},
|
|
193
|
-
|
|
168
|
+
z.value = t.clientX + 10, L.value = t.clientY + 10;
|
|
169
|
+
}, O = () => {
|
|
170
|
+
q.value = !1, k.value = null, $.value = -1;
|
|
194
171
|
};
|
|
195
|
-
return
|
|
196
|
-
() =>
|
|
172
|
+
return Z(
|
|
173
|
+
() => X.data,
|
|
197
174
|
() => {
|
|
198
175
|
G(), H();
|
|
199
176
|
},
|
|
200
177
|
{ deep: !0 }
|
|
201
|
-
),
|
|
202
|
-
|
|
203
|
-
}),
|
|
204
|
-
window.removeEventListener("resize",
|
|
205
|
-
}), (t,
|
|
178
|
+
), b(() => {
|
|
179
|
+
j(), window.addEventListener("resize", j);
|
|
180
|
+
}), tt(() => {
|
|
181
|
+
window.removeEventListener("resize", j), D && (cancelAnimationFrame(D), D = null);
|
|
182
|
+
}), (t, e) => (U(), T("div", {
|
|
206
183
|
class: "bubble-chart-container",
|
|
207
184
|
ref_key: "containerRef",
|
|
208
185
|
ref: _
|
|
209
186
|
}, [
|
|
210
|
-
|
|
187
|
+
nt("canvas", {
|
|
211
188
|
ref_key: "canvasRef",
|
|
212
|
-
ref:
|
|
213
|
-
onMousemove:
|
|
214
|
-
onMouseleave:
|
|
189
|
+
ref: A,
|
|
190
|
+
onMousemove: K,
|
|
191
|
+
onMouseleave: O
|
|
215
192
|
}, null, 544),
|
|
216
|
-
|
|
193
|
+
q.value ? (U(), T("div", {
|
|
217
194
|
key: 0,
|
|
218
195
|
class: "bubble-tooltip",
|
|
219
|
-
style:
|
|
220
|
-
left: `${
|
|
221
|
-
top: `${
|
|
196
|
+
style: at({
|
|
197
|
+
left: `${z.value}px`,
|
|
198
|
+
top: `${L.value}px`
|
|
222
199
|
})
|
|
223
200
|
}, [
|
|
224
|
-
|
|
225
|
-
], 4)) :
|
|
201
|
+
ot(t.$slots, "tooltip", { data: k.value }, void 0, !0)
|
|
202
|
+
], 4)) : et("", !0)
|
|
226
203
|
], 512));
|
|
227
204
|
}
|
|
228
|
-
}, W = /* @__PURE__ */
|
|
229
|
-
W.install = (
|
|
230
|
-
|
|
205
|
+
}), W = /* @__PURE__ */ st(it, [["__scopeId", "data-v-f39dd155"]]);
|
|
206
|
+
W.install = (P) => {
|
|
207
|
+
P.component(W.name, W);
|
|
231
208
|
};
|
|
232
209
|
export {
|
|
233
210
|
W as GBubble,
|
package/lib/GBubble/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.bubble-chart-container[data-v-
|
|
1
|
+
.bubble-chart-container[data-v-f39dd155]{position:relative;width:100%;height:100%;overflow:hidden}canvas[data-v-f39dd155]{display:block;width:100%;height:100%}.bubble-tooltip[data-v-f39dd155]{position:absolute;background:#000c;color:#fff;padding:8px 12px;border-radius:4px;font-size:14px;pointer-events:none;z-index:10;min-width:80px;box-shadow:0 2px 8px #0000004d;border:1px solid #1982e0}
|
package/lib/GBubble.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|
package/lib/GCount/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("vue"),d=t.defineComponent({__name:"index",props:{num:{default:0},delay:{default:0},duration:{default:2},className:{default:""},startWhen:{type:Boolean,default:!0},separator:{default:""},decimalPlaces:{default:0}},emits:["start","end"],setup(x,{expose:S,emit:C}){const e=x,A=C;S({reset:O,start:M});const a=t.useTemplateRef("elementRef"),I=()=>0,u=t.ref(I()),s=t.ref(!1),c=t.ref(!1);let l=null,m=null,r=null,f=!1,v=0,p=0,o=0;const N=n=>1-Math.pow(1-n,3),T=n=>{const i=Math.max(0,Math.floor(e.decimalPlaces)),_={useGrouping:!!e.separator,minimumFractionDigits:i,maximumFractionDigits:i},g=Number(n.toFixed(i)),w=Intl.NumberFormat("en-US",_).format(g);return e.separator?w.replace(/,/g,e.separator):w},h=()=>{a.value&&(a.value.textContent=T(u.value))},y=()=>{l!==null&&(cancelAnimationFrame(l),l=null)},b=()=>{m!==null&&(clearTimeout(m),m=null)},F=n=>{if(!f)return;o||(o=n);const i=(n-o)/1e3,_=Math.max(.001,e.duration),g=Math.min(1,i/_),w=N(g);u.value=v+(p-v)*w,h(),g<1?l=requestAnimationFrame(F):(u.value=p,h(),l=null,A("end"))};function M(){c.value||!s.value||!e.startWhen||(c.value=!0,A("start"),b(),m=setTimeout(()=>{m=null,f&&(v=u.value,p=e.num,o=0,l=requestAnimationFrame(F))},e.delay*1e3))}function W(){!f||!s.value||!e.startWhen||(y(),b(),v=u.value,p=e.num,o=0,l=requestAnimationFrame(F))}function O(){y(),b(),o=0,c.value=!1,u.value=I(),h()}const R=()=>{a.value&&(r=new IntersectionObserver(([n])=>{n.isIntersecting&&!s.value&&(s.value=!0,M(),r&&a.value&&r.unobserve(a.value))},{threshold:0,rootMargin:"0px"}),r.observe(a.value))},q=()=>{f=!1,y(),b(),r&&(r.disconnect(),r=null)};return t.watch(()=>e.num,()=>{c.value?W():s.value&&e.startWhen&&M()}),t.watch(()=>e.startWhen,()=>{e.startWhen&&s.value&&!c.value&&M()}),t.onMounted(()=>{f=!0,h(),R()}),t.onUnmounted(()=>{q()}),(n,i)=>(t.openBlock(),t.createElementBlock("span",{ref_key:"elementRef",ref:a,class:t.normalizeClass(n.className)},null,2))}});d.install=x=>{x.component(d.name,d)};exports.GCount=d;exports.default=d;
|
package/lib/GCount/index.mjs
CHANGED
|
@@ -1,79 +1,92 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
const
|
|
3
|
-
name: "GCount",
|
|
1
|
+
import { defineComponent as q, useTemplateRef as B, ref as y, watch as N, onMounted as V, onUnmounted as E, createElementBlock as G, openBlock as P, normalizeClass as U } from "vue";
|
|
2
|
+
const A = /* @__PURE__ */ q({
|
|
4
3
|
__name: "index",
|
|
5
4
|
props: {
|
|
6
|
-
|
|
7
|
-
from: { default: 0 },
|
|
8
|
-
direction: { default: "up" },
|
|
5
|
+
num: { default: 0 },
|
|
9
6
|
delay: { default: 0 },
|
|
10
7
|
duration: { default: 2 },
|
|
11
8
|
className: { default: "" },
|
|
12
9
|
startWhen: { type: Boolean, default: !0 },
|
|
13
10
|
separator: { default: "" },
|
|
14
|
-
|
|
15
|
-
onEnd: {}
|
|
11
|
+
decimalPlaces: { default: 0 }
|
|
16
12
|
},
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
13
|
+
emits: ["start", "end"],
|
|
14
|
+
setup(w, { expose: W, emit: _ }) {
|
|
15
|
+
const e = w, I = _;
|
|
16
|
+
W({
|
|
17
|
+
reset: D,
|
|
18
|
+
start: h
|
|
19
|
+
});
|
|
20
|
+
const n = B("elementRef"), C = () => 0, r = y(C()), s = y(!1), i = y(!1);
|
|
21
|
+
let a = null, c = null, l = null, m = !1, f = 0, d = 0, u = 0;
|
|
22
|
+
const R = (t) => 1 - Math.pow(1 - t, 3), S = (t) => {
|
|
23
|
+
const o = Math.max(0, Math.floor(e.decimalPlaces)), g = {
|
|
24
24
|
useGrouping: !!e.separator,
|
|
25
|
-
minimumFractionDigits:
|
|
26
|
-
maximumFractionDigits:
|
|
27
|
-
},
|
|
28
|
-
return e.separator ?
|
|
29
|
-
},
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
25
|
+
minimumFractionDigits: o,
|
|
26
|
+
maximumFractionDigits: o
|
|
27
|
+
}, b = Number(t.toFixed(o)), x = Intl.NumberFormat("en-US", g).format(b);
|
|
28
|
+
return e.separator ? x.replace(/,/g, e.separator) : x;
|
|
29
|
+
}, v = () => {
|
|
30
|
+
n.value && (n.value.textContent = S(r.value));
|
|
31
|
+
}, F = () => {
|
|
32
|
+
a !== null && (cancelAnimationFrame(a), a = null);
|
|
33
|
+
}, p = () => {
|
|
34
|
+
c !== null && (clearTimeout(c), c = null);
|
|
35
|
+
}, M = (t) => {
|
|
36
|
+
if (!m) return;
|
|
37
|
+
u || (u = t);
|
|
38
|
+
const o = (t - u) / 1e3, g = Math.max(1e-3, e.duration), b = Math.min(1, o / g), x = R(b);
|
|
39
|
+
r.value = f + (d - f) * x, v(), b < 1 ? a = requestAnimationFrame(M) : (r.value = d, v(), a = null, I("end"));
|
|
40
|
+
};
|
|
41
|
+
function h() {
|
|
42
|
+
i.value || !s.value || !e.startWhen || (i.value = !0, I("start"), p(), c = setTimeout(() => {
|
|
43
|
+
c = null, m && (f = r.value, d = e.num, u = 0, a = requestAnimationFrame(M));
|
|
37
44
|
}, e.delay * 1e3));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
45
|
+
}
|
|
46
|
+
function T() {
|
|
47
|
+
!m || !s.value || !e.startWhen || (F(), p(), f = r.value, d = e.num, u = 0, a = requestAnimationFrame(M));
|
|
48
|
+
}
|
|
49
|
+
function D() {
|
|
50
|
+
F(), p(), u = 0, i.value = !1, r.value = C(), v();
|
|
51
|
+
}
|
|
52
|
+
const O = () => {
|
|
53
|
+
n.value && (l = new IntersectionObserver(
|
|
54
|
+
([t]) => {
|
|
55
|
+
t.isIntersecting && !s.value && (s.value = !0, h(), l && n.value && l.unobserve(n.value));
|
|
42
56
|
},
|
|
43
57
|
{
|
|
44
58
|
threshold: 0,
|
|
45
59
|
rootMargin: "0px"
|
|
46
60
|
}
|
|
47
|
-
),
|
|
48
|
-
},
|
|
49
|
-
|
|
61
|
+
), l.observe(n.value));
|
|
62
|
+
}, k = () => {
|
|
63
|
+
m = !1, F(), p(), l && (l.disconnect(), l = null);
|
|
50
64
|
};
|
|
51
|
-
return
|
|
52
|
-
|
|
65
|
+
return N(
|
|
66
|
+
() => e.num,
|
|
53
67
|
() => {
|
|
54
|
-
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
), F(
|
|
68
|
+
i.value ? T() : s.value && e.startWhen && h();
|
|
69
|
+
}
|
|
70
|
+
), N(
|
|
58
71
|
() => e.startWhen,
|
|
59
72
|
() => {
|
|
60
|
-
e.startWhen &&
|
|
73
|
+
e.startWhen && s.value && !i.value && h();
|
|
61
74
|
}
|
|
62
|
-
),
|
|
63
|
-
|
|
64
|
-
}),
|
|
65
|
-
|
|
66
|
-
}), (
|
|
75
|
+
), V(() => {
|
|
76
|
+
m = !0, v(), O();
|
|
77
|
+
}), E(() => {
|
|
78
|
+
k();
|
|
79
|
+
}), (t, o) => (P(), G("span", {
|
|
67
80
|
ref_key: "elementRef",
|
|
68
|
-
ref:
|
|
69
|
-
class:
|
|
81
|
+
ref: n,
|
|
82
|
+
class: U(t.className)
|
|
70
83
|
}, null, 2));
|
|
71
84
|
}
|
|
72
85
|
});
|
|
73
|
-
|
|
74
|
-
|
|
86
|
+
A.install = (w) => {
|
|
87
|
+
w.component(A.name, A);
|
|
75
88
|
};
|
|
76
89
|
export {
|
|
77
|
-
|
|
78
|
-
|
|
90
|
+
A as GCount,
|
|
91
|
+
A as default
|
|
79
92
|
};
|
package/lib/GCount.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {}
|