vue-chrts 0.0.161 → 0.0.163
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/components/Area/AreaChart.cjs +7 -0
- package/dist/components/Area/AreaChart.cjs.map +1 -0
- package/dist/components/Area/AreaChart.js +129 -0
- package/dist/components/Area/AreaChart.js.map +1 -0
- package/dist/components/Area/AreaChart.vue.d.ts +36 -0
- package/dist/components/Area/AreaChart2.cjs +2 -0
- package/dist/components/Area/AreaChart2.cjs.map +1 -0
- package/dist/components/Area/AreaChart2.js +5 -0
- package/dist/components/Area/AreaChart2.js.map +1 -0
- package/dist/components/Area/index.d.ts +1 -0
- package/dist/components/Area/types.d.ts +84 -0
- package/dist/components/Line/LineChart.cjs +1 -1
- package/dist/components/Line/LineChart.cjs.map +1 -1
- package/dist/components/Line/LineChart.js +52 -21
- package/dist/components/Line/LineChart.js.map +1 -1
- package/dist/components/Line/LineChart.vue.d.ts +3 -1
- package/dist/components/Tooltip.cjs +2 -0
- package/dist/components/Tooltip.cjs.map +1 -0
- package/dist/components/Tooltip.js +38 -0
- package/dist/components/Tooltip.js.map +1 -0
- package/dist/components/Tooltip.vue.d.ts +17 -0
- package/dist/components/Tooltip2.cjs +2 -0
- package/dist/components/Tooltip2.cjs.map +1 -0
- package/dist/components/Tooltip2.js +5 -0
- package/dist/components/Tooltip2.js.map +1 -0
- package/dist/components.d.ts +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),c=require("@unovis/ts"),n=require("@unovis/vue"),g=require("../Tooltip.cjs"),y={key:0,class:"flex items center justify-end"},k=e.defineComponent({__name:"AreaChart",props:{data:{},height:{},xLabel:{},yLabel:{},categories:{},xFormatter:{},yFormatter:{},curveType:{},xNumTicks:{default:r=>r.data.length>24?24/4:r.data.length-1},yNumTicks:{default:r=>r.data.length>24?24/4:r.data.length-1},hideLegend:{type:Boolean},hideTooltip:{type:Boolean},gridLineX:{type:Boolean},domainLineX:{type:Boolean},gridLineY:{type:Boolean},domainLineY:{type:Boolean},paginationPoisition:{}},setup(r){const l=r,s=Object.values(l.categories).map(t=>t.color),p=e.computed(()=>t=>{if(typeof window>"u"||typeof document>"u")return"";try{const o=e.createApp(g.default,{data:t,categories:l.categories}),i=document.createElement("div");o.mount(i);const a=i.innerHTML;return o.unmount(),a}catch{return""}});function m(t){var o;return{y:i=>Number(i[t]),color:((o=l.categories[t])==null?void 0:o.color)??"#3b82f6"}}const f=s.map((t,o)=>`
|
|
2
|
+
<linearGradient id="gradient${o}-${t}" gradientTransform="rotate(90)">
|
|
3
|
+
<stop offset="0%" stop-color="${t}" stop-opacity="1" />
|
|
4
|
+
<stop offset="100%" stop-color="${t}" stop-opacity="0" />
|
|
5
|
+
</linearGradient>
|
|
6
|
+
`).join("");return(t,o)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex flex-col space-y-4",{"flex-col-reverse":l.paginationPoisition==="top"}])},[e.createVNode(e.unref(n.VisXYContainer),{data:t.data,height:t.height,"svg-defs":e.unref(f)},{default:e.withCtx(()=>[t.hideTooltip?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(n.VisTooltip),{key:0,"horizontal-placement":e.unref(c.Position).Right,"vertical-placement":e.unref(c.Position).Top},null,8,["horizontal-placement","vertical-placement"])),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Object.keys(l.categories),(i,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:a},[e.createVNode(e.unref(n.VisArea),e.mergeProps({x:(u,d)=>d,ref_for:!0},m(i),{color:`url(#gradient${a}-${e.unref(s)[a]})`,opacity:.5,"curve-type":t.curveType??e.unref(c.CurveType).MonotoneX}),null,16,["x","color","curve-type"]),e.createVNode(e.unref(n.VisLine),{x:(u,d)=>d,y:u=>u[i],color:e.unref(s)[a],"curve-type":t.curveType??e.unref(c.CurveType).MonotoneX},null,8,["x","y","color","curve-type"])],64))),128)),e.createVNode(e.unref(n.VisAxis),{type:"x","tick-format":t.xFormatter,"num-ticks":t.xNumTicks,label:t.xLabel,"grid-line":t.gridLineX,"domain-line":t.domainLineX,"tick-line":!!t.gridLineX},null,8,["tick-format","num-ticks","label","grid-line","domain-line","tick-line"]),e.createVNode(e.unref(n.VisAxis),{type:"y","num-ticks":t.yNumTicks??t.data.length,"tick-format":t.yFormatter,label:t.yLabel,"grid-line":t.gridLineY,"domain-line":t.domainLineY,"tick-line":!!t.gridLineY},null,8,["num-ticks","tick-format","label","grid-line","domain-line","tick-line"]),t.hideTooltip?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(n.VisCrosshair),{key:1,color:"#666",template:p.value},null,8,["template"]))]),_:1},8,["data","height","svg-defs"]),t.hideLegend?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",y,[e.createVNode(e.unref(n.VisBulletLegend),{items:Object.values(t.categories)},null,8,["items"])]))],2))}});exports.default=k;
|
|
7
|
+
//# sourceMappingURL=AreaChart.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart.cjs","sources":["../../../src/components/Area/AreaChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport { computed, createApp } from \"vue\";\nimport type { BulletLegendItemInterface, NumericAccessor } from \"@unovis/ts\";\nimport { CurveType, Position } from \"@unovis/ts\";\nimport {\n VisArea,\n VisAxis,\n VisBulletLegend,\n VisCrosshair,\n VisLine,\n VisTooltip,\n VisXYContainer,\n} from \"@unovis/vue\";\n\nimport Tooltip from \"./../Tooltip.vue\";\nimport { PaginationPosition } from \"../../types\";\n\ntype AreaChartProps<T> = {\n data: T[];\n height: number;\n xLabel?: string;\n yLabel?: string;\n categories: Record<string, BulletLegendItemInterface>;\n xFormatter: (i: number, idx: number) => string;\n yFormatter?: (i: number, idx?: number) => string | number;\n curveType?: CurveType;\n xNumTicks?: number;\n yNumTicks?: number;\n hideLegend?: boolean;\n hideTooltip?: boolean;\n gridLineX?: boolean;\n domainLineX?: boolean;\n gridLineY?: boolean;\n domainLineY?: boolean;\n paginationPoisition?: PaginationPosition;\n};\n\nconst props = withDefaults(defineProps<AreaChartProps<T>>(), {\n xNumTicks: (props) =>\n props.data.length > 24 ? 24 / 4 : props.data.length - 1,\n yNumTicks: (props) =>\n props.data.length > 24 ? 24 / 4 : props.data.length - 1,\n});\n\nconst colors = Object.values(props.categories).map((c) => c.color);\n\nconst generateTooltip = computed(() => (d: T) => {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return '';\n }\n \n try {\n const app = createApp(Tooltip, {\n data: d,\n categories: props.categories,\n });\n\n const container = document.createElement(\"div\");\n app.mount(container);\n\n const html = container.innerHTML;\n app.unmount();\n\n return html;\n } catch (error) {\n return '';\n }\n});\n\nfunction accessors(id: string): { y: NumericAccessor<T>; color: string } {\n return {\n y: (d: T) => Number(d[id as keyof typeof d]),\n color: props.categories[id]?.color ?? \"#3b82f6\",\n };\n}\n\nconst svgDefs = colors\n .map(\n (color, index) => `\n <linearGradient id=\"gradient${index}-${color}\" gradientTransform=\"rotate(90)\">\n <stop offset=\"0%\" stop-color=\"${color}\" stop-opacity=\"1\" />\n <stop offset=\"100%\" stop-color=\"${color}\" stop-opacity=\"0\" />\n </linearGradient>\n`\n )\n .join(\"\");\n</script>\n\n<template>\n <div\n class=\"flex flex-col space-y-4\"\n :class=\"{\n 'flex-col-reverse': props.paginationPoisition === 'top',\n }\"\n >\n <VisXYContainer :data=\"data\" :height=\"height\" :svg-defs=\"svgDefs\">\n <VisTooltip\n v-if=\"!hideTooltip\"\n :horizontal-placement=\"Position.Right\"\n :vertical-placement=\"Position.Top\"\n />\n <template v-for=\"(i, iKey) in Object.keys(props.categories)\" :key=\"iKey\">\n <VisArea\n :x=\"(_: T, i: number) => i\"\n v-bind=\"accessors(i)\"\n :color=\"`url(#gradient${iKey}-${colors[iKey]})`\"\n :opacity=\"0.5\"\n :curve-type=\"curveType ?? CurveType.MonotoneX\"\n />\n <VisLine\n :x=\"(_: any, i: number) => i\"\n :y=\"(d: T) => d[i as keyof typeof d]\"\n :color=\"colors[iKey]\"\n :curve-type=\"curveType ?? CurveType.MonotoneX\"\n />\n </template>\n\n <VisAxis\n type=\"x\"\n :tick-format=\"xFormatter\"\n :num-ticks=\"xNumTicks\"\n :label=\"xLabel\"\n :grid-line=\"gridLineX\"\n :domain-line=\"domainLineX\"\n :tick-line=\"!!gridLineX\"\n />\n <VisAxis\n type=\"y\"\n :num-ticks=\"yNumTicks ?? data.length\"\n :tick-format=\"yFormatter\"\n :label=\"yLabel\"\n :grid-line=\"gridLineY\"\n :domain-line=\"domainLineY\"\n :tick-line=\"!!gridLineY\"\n />\n <VisCrosshair\n v-if=\"!hideTooltip\"\n color=\"#666\"\n :template=\"generateTooltip\"\n />\n </VisXYContainer>\n <div v-if=\"!hideLegend\" class=\"flex items center justify-end\">\n <VisBulletLegend :items=\"Object.values(categories)\" />\n </div>\n </div>\n</template>\n"],"names":["props","__props","colors","c","generateTooltip","computed","d","app","createApp","Tooltip","container","html","accessors","id","_a","svgDefs","color","index"],"mappings":"osBAqCA,MAAMA,EAAQC,EAORC,EAAS,OAAO,OAAOF,EAAM,UAAU,EAAE,IAAKG,GAAMA,EAAE,KAAK,EAE3DC,EAAkBC,EAAAA,SAAS,IAAOC,GAAS,CAC/C,GAAI,OAAO,OAAW,KAAe,OAAO,SAAa,IAChD,MAAA,GAGL,GAAA,CACI,MAAAC,EAAMC,YAAUC,UAAS,CAC7B,KAAMH,EACN,WAAYN,EAAM,UAAA,CACnB,EAEKU,EAAY,SAAS,cAAc,KAAK,EAC9CH,EAAI,MAAMG,CAAS,EAEnB,MAAMC,EAAOD,EAAU,UACvB,OAAAH,EAAI,QAAQ,EAELI,OACO,CACP,MAAA,EAAA,CACT,CACD,EAED,SAASC,EAAUC,EAAsD,OAChE,MAAA,CACL,EAAIP,GAAS,OAAOA,EAAEO,CAAoB,CAAC,EAC3C,QAAOC,EAAAd,EAAM,WAAWa,CAAE,IAAnB,YAAAC,EAAsB,QAAS,SACxC,CAAA,CAGF,MAAMC,EAAUb,EACb,IACC,CAACc,EAAOC,IAAU;AAAA,gCACUA,CAAK,IAAID,CAAK;AAAA,oCACVA,CAAK;AAAA,sCACHA,CAAK;AAAA;AAAA,CAAA,EAIxC,KAAK,EAAE"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
import { defineComponent as b, computed as B, createApp as V, createElementBlock as c, openBlock as a, normalizeClass as C, createVNode as l, createCommentVNode as u, unref as t, withCtx as X, createBlock as g, Fragment as f, renderList as N, mergeProps as $ } from "vue";
|
|
2
|
+
import { Position as y, CurveType as h } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as Y, VisTooltip as j, VisArea as F, VisLine as A, VisAxis as k, VisCrosshair as P, VisBulletLegend as w } from "@unovis/vue";
|
|
4
|
+
import z from "../Tooltip.js";
|
|
5
|
+
const M = {
|
|
6
|
+
key: 0,
|
|
7
|
+
class: "flex items center justify-end"
|
|
8
|
+
}, H = /* @__PURE__ */ b({
|
|
9
|
+
__name: "AreaChart",
|
|
10
|
+
props: {
|
|
11
|
+
data: {},
|
|
12
|
+
height: {},
|
|
13
|
+
xLabel: {},
|
|
14
|
+
yLabel: {},
|
|
15
|
+
categories: {},
|
|
16
|
+
xFormatter: {},
|
|
17
|
+
yFormatter: {},
|
|
18
|
+
curveType: {},
|
|
19
|
+
xNumTicks: { default: (i) => i.data.length > 24 ? 24 / 4 : i.data.length - 1 },
|
|
20
|
+
yNumTicks: { default: (i) => i.data.length > 24 ? 24 / 4 : i.data.length - 1 },
|
|
21
|
+
hideLegend: { type: Boolean },
|
|
22
|
+
hideTooltip: { type: Boolean },
|
|
23
|
+
gridLineX: { type: Boolean },
|
|
24
|
+
domainLineX: { type: Boolean },
|
|
25
|
+
gridLineY: { type: Boolean },
|
|
26
|
+
domainLineY: { type: Boolean },
|
|
27
|
+
paginationPoisition: {}
|
|
28
|
+
},
|
|
29
|
+
setup(i) {
|
|
30
|
+
const s = i, d = Object.values(s.categories).map((e) => e.color), v = B(() => (e) => {
|
|
31
|
+
if (typeof window > "u" || typeof document > "u")
|
|
32
|
+
return "";
|
|
33
|
+
try {
|
|
34
|
+
const o = V(z, {
|
|
35
|
+
data: e,
|
|
36
|
+
categories: s.categories
|
|
37
|
+
}), n = document.createElement("div");
|
|
38
|
+
o.mount(n);
|
|
39
|
+
const r = n.innerHTML;
|
|
40
|
+
return o.unmount(), r;
|
|
41
|
+
} catch {
|
|
42
|
+
return "";
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
function L(e) {
|
|
46
|
+
var o;
|
|
47
|
+
return {
|
|
48
|
+
y: (n) => Number(n[e]),
|
|
49
|
+
color: ((o = s.categories[e]) == null ? void 0 : o.color) ?? "#3b82f6"
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
const T = d.map(
|
|
53
|
+
(e, o) => `
|
|
54
|
+
<linearGradient id="gradient${o}-${e}" gradientTransform="rotate(90)">
|
|
55
|
+
<stop offset="0%" stop-color="${e}" stop-opacity="1" />
|
|
56
|
+
<stop offset="100%" stop-color="${e}" stop-opacity="0" />
|
|
57
|
+
</linearGradient>
|
|
58
|
+
`
|
|
59
|
+
).join("");
|
|
60
|
+
return (e, o) => (a(), c("div", {
|
|
61
|
+
class: C(["flex flex-col space-y-4", {
|
|
62
|
+
"flex-col-reverse": s.paginationPoisition === "top"
|
|
63
|
+
}])
|
|
64
|
+
}, [
|
|
65
|
+
l(t(Y), {
|
|
66
|
+
data: e.data,
|
|
67
|
+
height: e.height,
|
|
68
|
+
"svg-defs": t(T)
|
|
69
|
+
}, {
|
|
70
|
+
default: X(() => [
|
|
71
|
+
e.hideTooltip ? u("", !0) : (a(), g(t(j), {
|
|
72
|
+
key: 0,
|
|
73
|
+
"horizontal-placement": t(y).Right,
|
|
74
|
+
"vertical-placement": t(y).Top
|
|
75
|
+
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
76
|
+
(a(!0), c(f, null, N(Object.keys(s.categories), (n, r) => (a(), c(f, { key: r }, [
|
|
77
|
+
l(t(F), $({
|
|
78
|
+
x: (m, p) => p,
|
|
79
|
+
ref_for: !0
|
|
80
|
+
}, L(n), {
|
|
81
|
+
color: `url(#gradient${r}-${t(d)[r]})`,
|
|
82
|
+
opacity: 0.5,
|
|
83
|
+
"curve-type": e.curveType ?? t(h).MonotoneX
|
|
84
|
+
}), null, 16, ["x", "color", "curve-type"]),
|
|
85
|
+
l(t(A), {
|
|
86
|
+
x: (m, p) => p,
|
|
87
|
+
y: (m) => m[n],
|
|
88
|
+
color: t(d)[r],
|
|
89
|
+
"curve-type": e.curveType ?? t(h).MonotoneX
|
|
90
|
+
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
91
|
+
], 64))), 128)),
|
|
92
|
+
l(t(k), {
|
|
93
|
+
type: "x",
|
|
94
|
+
"tick-format": e.xFormatter,
|
|
95
|
+
"num-ticks": e.xNumTicks,
|
|
96
|
+
label: e.xLabel,
|
|
97
|
+
"grid-line": e.gridLineX,
|
|
98
|
+
"domain-line": e.domainLineX,
|
|
99
|
+
"tick-line": !!e.gridLineX
|
|
100
|
+
}, null, 8, ["tick-format", "num-ticks", "label", "grid-line", "domain-line", "tick-line"]),
|
|
101
|
+
l(t(k), {
|
|
102
|
+
type: "y",
|
|
103
|
+
"num-ticks": e.yNumTicks ?? e.data.length,
|
|
104
|
+
"tick-format": e.yFormatter,
|
|
105
|
+
label: e.yLabel,
|
|
106
|
+
"grid-line": e.gridLineY,
|
|
107
|
+
"domain-line": e.domainLineY,
|
|
108
|
+
"tick-line": !!e.gridLineY
|
|
109
|
+
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
110
|
+
e.hideTooltip ? u("", !0) : (a(), g(t(P), {
|
|
111
|
+
key: 1,
|
|
112
|
+
color: "#666",
|
|
113
|
+
template: v.value
|
|
114
|
+
}, null, 8, ["template"]))
|
|
115
|
+
]),
|
|
116
|
+
_: 1
|
|
117
|
+
}, 8, ["data", "height", "svg-defs"]),
|
|
118
|
+
e.hideLegend ? u("", !0) : (a(), c("div", M, [
|
|
119
|
+
l(t(w), {
|
|
120
|
+
items: Object.values(e.categories)
|
|
121
|
+
}, null, 8, ["items"])
|
|
122
|
+
]))
|
|
123
|
+
], 2));
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
export {
|
|
127
|
+
H as default
|
|
128
|
+
};
|
|
129
|
+
//# sourceMappingURL=AreaChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart.js","sources":["../../../src/components/Area/AreaChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport { computed, createApp } from \"vue\";\nimport type { BulletLegendItemInterface, NumericAccessor } from \"@unovis/ts\";\nimport { CurveType, Position } from \"@unovis/ts\";\nimport {\n VisArea,\n VisAxis,\n VisBulletLegend,\n VisCrosshair,\n VisLine,\n VisTooltip,\n VisXYContainer,\n} from \"@unovis/vue\";\n\nimport Tooltip from \"./../Tooltip.vue\";\nimport { PaginationPosition } from \"../../types\";\n\ntype AreaChartProps<T> = {\n data: T[];\n height: number;\n xLabel?: string;\n yLabel?: string;\n categories: Record<string, BulletLegendItemInterface>;\n xFormatter: (i: number, idx: number) => string;\n yFormatter?: (i: number, idx?: number) => string | number;\n curveType?: CurveType;\n xNumTicks?: number;\n yNumTicks?: number;\n hideLegend?: boolean;\n hideTooltip?: boolean;\n gridLineX?: boolean;\n domainLineX?: boolean;\n gridLineY?: boolean;\n domainLineY?: boolean;\n paginationPoisition?: PaginationPosition;\n};\n\nconst props = withDefaults(defineProps<AreaChartProps<T>>(), {\n xNumTicks: (props) =>\n props.data.length > 24 ? 24 / 4 : props.data.length - 1,\n yNumTicks: (props) =>\n props.data.length > 24 ? 24 / 4 : props.data.length - 1,\n});\n\nconst colors = Object.values(props.categories).map((c) => c.color);\n\nconst generateTooltip = computed(() => (d: T) => {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return '';\n }\n \n try {\n const app = createApp(Tooltip, {\n data: d,\n categories: props.categories,\n });\n\n const container = document.createElement(\"div\");\n app.mount(container);\n\n const html = container.innerHTML;\n app.unmount();\n\n return html;\n } catch (error) {\n return '';\n }\n});\n\nfunction accessors(id: string): { y: NumericAccessor<T>; color: string } {\n return {\n y: (d: T) => Number(d[id as keyof typeof d]),\n color: props.categories[id]?.color ?? \"#3b82f6\",\n };\n}\n\nconst svgDefs = colors\n .map(\n (color, index) => `\n <linearGradient id=\"gradient${index}-${color}\" gradientTransform=\"rotate(90)\">\n <stop offset=\"0%\" stop-color=\"${color}\" stop-opacity=\"1\" />\n <stop offset=\"100%\" stop-color=\"${color}\" stop-opacity=\"0\" />\n </linearGradient>\n`\n )\n .join(\"\");\n</script>\n\n<template>\n <div\n class=\"flex flex-col space-y-4\"\n :class=\"{\n 'flex-col-reverse': props.paginationPoisition === 'top',\n }\"\n >\n <VisXYContainer :data=\"data\" :height=\"height\" :svg-defs=\"svgDefs\">\n <VisTooltip\n v-if=\"!hideTooltip\"\n :horizontal-placement=\"Position.Right\"\n :vertical-placement=\"Position.Top\"\n />\n <template v-for=\"(i, iKey) in Object.keys(props.categories)\" :key=\"iKey\">\n <VisArea\n :x=\"(_: T, i: number) => i\"\n v-bind=\"accessors(i)\"\n :color=\"`url(#gradient${iKey}-${colors[iKey]})`\"\n :opacity=\"0.5\"\n :curve-type=\"curveType ?? CurveType.MonotoneX\"\n />\n <VisLine\n :x=\"(_: any, i: number) => i\"\n :y=\"(d: T) => d[i as keyof typeof d]\"\n :color=\"colors[iKey]\"\n :curve-type=\"curveType ?? CurveType.MonotoneX\"\n />\n </template>\n\n <VisAxis\n type=\"x\"\n :tick-format=\"xFormatter\"\n :num-ticks=\"xNumTicks\"\n :label=\"xLabel\"\n :grid-line=\"gridLineX\"\n :domain-line=\"domainLineX\"\n :tick-line=\"!!gridLineX\"\n />\n <VisAxis\n type=\"y\"\n :num-ticks=\"yNumTicks ?? data.length\"\n :tick-format=\"yFormatter\"\n :label=\"yLabel\"\n :grid-line=\"gridLineY\"\n :domain-line=\"domainLineY\"\n :tick-line=\"!!gridLineY\"\n />\n <VisCrosshair\n v-if=\"!hideTooltip\"\n color=\"#666\"\n :template=\"generateTooltip\"\n />\n </VisXYContainer>\n <div v-if=\"!hideLegend\" class=\"flex items center justify-end\">\n <VisBulletLegend :items=\"Object.values(categories)\" />\n </div>\n </div>\n</template>\n"],"names":["props","__props","colors","c","generateTooltip","computed","d","app","createApp","Tooltip","container","html","accessors","id","_a","svgDefs","color","index"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCA,UAAMA,IAAQC,GAORC,IAAS,OAAO,OAAOF,EAAM,UAAU,EAAE,IAAI,CAACG,MAAMA,EAAE,KAAK,GAE3DC,IAAkBC,EAAS,MAAM,CAACC,MAAS;AAC/C,UAAI,OAAO,SAAW,OAAe,OAAO,WAAa;AAChD,eAAA;AAGL,UAAA;AACI,cAAAC,IAAMC,EAAUC,GAAS;AAAA,UAC7B,MAAMH;AAAA,UACN,YAAYN,EAAM;AAAA,QAAA,CACnB,GAEKU,IAAY,SAAS,cAAc,KAAK;AAC9C,QAAAH,EAAI,MAAMG,CAAS;AAEnB,cAAMC,IAAOD,EAAU;AACvB,eAAAH,EAAI,QAAQ,GAELI;AAAA,cACO;AACP,eAAA;AAAA,MAAA;AAAA,IACT,CACD;AAED,aAASC,EAAUC,GAAsD;;AAChE,aAAA;AAAA,QACL,GAAG,CAACP,MAAS,OAAOA,EAAEO,CAAoB,CAAC;AAAA,QAC3C,SAAOC,IAAAd,EAAM,WAAWa,CAAE,MAAnB,gBAAAC,EAAsB,UAAS;AAAA,MACxC;AAAA,IAAA;AAGF,UAAMC,IAAUb,EACb;AAAA,MACC,CAACc,GAAOC,MAAU;AAAA,gCACUA,CAAK,IAAID,CAAK;AAAA,oCACVA,CAAK;AAAA,sCACHA,CAAK;AAAA;AAAA;AAAA,IAAA,EAIxC,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { BulletLegendItemInterface, CurveType } from '@unovis/ts';
|
|
2
|
+
import { PaginationPosition } from '../../types';
|
|
3
|
+
|
|
4
|
+
declare const _default: <T>(__VLS_props: Awaited<typeof __VLS_setup>["props"], __VLS_ctx?: __VLS_Prettify<Pick<Awaited<typeof __VLS_setup>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
5
|
+
props: __VLS_Prettify<__VLS_OmitKeepDiscriminatedUnion<(Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>) & {
|
|
6
|
+
data: T[];
|
|
7
|
+
height: number;
|
|
8
|
+
xLabel?: string;
|
|
9
|
+
yLabel?: string;
|
|
10
|
+
categories: Record<string, BulletLegendItemInterface>;
|
|
11
|
+
xFormatter: (i: number, idx: number) => string;
|
|
12
|
+
yFormatter?: (i: number, idx?: number) => string | number;
|
|
13
|
+
curveType?: CurveType;
|
|
14
|
+
xNumTicks?: number;
|
|
15
|
+
yNumTicks?: number;
|
|
16
|
+
hideLegend?: boolean;
|
|
17
|
+
hideTooltip?: boolean;
|
|
18
|
+
gridLineX?: boolean;
|
|
19
|
+
domainLineX?: boolean;
|
|
20
|
+
gridLineY?: boolean;
|
|
21
|
+
domainLineY?: boolean;
|
|
22
|
+
paginationPoisition?: PaginationPosition;
|
|
23
|
+
}, keyof import('vue').VNodeProps | keyof import('vue').AllowedComponentProps>> & {} & (import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps);
|
|
24
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
25
|
+
attrs: any;
|
|
26
|
+
slots: ReturnType<() => {}>;
|
|
27
|
+
emit: typeof __VLS_emit;
|
|
28
|
+
}>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}> & {
|
|
31
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
32
|
+
};
|
|
33
|
+
export default _default;
|
|
34
|
+
type __VLS_Prettify<T> = {
|
|
35
|
+
[K in keyof T]: T[K];
|
|
36
|
+
} & {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as AreaChart } from './AreaChart.vue';
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { PaginationPosition } from '../../types';
|
|
2
|
+
import { BulletLegendItemInterface, CurveType } from '@unovis/ts';
|
|
3
|
+
|
|
4
|
+
export type AreaChartProps<T> = {
|
|
5
|
+
/**
|
|
6
|
+
* The data to be displayed in the area chart.
|
|
7
|
+
* Each element of the array represents a data point.
|
|
8
|
+
* The structure of 'T' should be compatible with the chart's rendering logic.
|
|
9
|
+
*/
|
|
10
|
+
data: T[];
|
|
11
|
+
/**
|
|
12
|
+
* The height of the chart in pixels.
|
|
13
|
+
*/
|
|
14
|
+
height: number;
|
|
15
|
+
/**
|
|
16
|
+
* Optional label for the x-axis.
|
|
17
|
+
*/
|
|
18
|
+
xLabel?: string;
|
|
19
|
+
/**
|
|
20
|
+
* Optional label for the y-axis.
|
|
21
|
+
*/
|
|
22
|
+
yLabel?: string;
|
|
23
|
+
/**
|
|
24
|
+
* A record mapping category keys to `BulletLegendItemInterface` objects.
|
|
25
|
+
* This defines the visual representation and labels for each category in the chart's legend.
|
|
26
|
+
*/
|
|
27
|
+
categories: Record<string, BulletLegendItemInterface>;
|
|
28
|
+
/**
|
|
29
|
+
* A function that formats the x-axis tick labels.
|
|
30
|
+
* @param i The value to be formatted.
|
|
31
|
+
* @param idx The index of the data point.
|
|
32
|
+
* @returns The formatted x-axis label.
|
|
33
|
+
*/
|
|
34
|
+
xFormatter: (i: number, idx: number) => string;
|
|
35
|
+
/**
|
|
36
|
+
* An optional function that formats the y-axis tick labels.
|
|
37
|
+
* @param i The value to be formatted.
|
|
38
|
+
* @param idx The index of the data point (optional).
|
|
39
|
+
* @returns The formatted y-axis label or value.
|
|
40
|
+
*/
|
|
41
|
+
yFormatter?: (i: number, idx?: number) => string | number;
|
|
42
|
+
/**
|
|
43
|
+
* The type of curve to use for the area chart lines.
|
|
44
|
+
* See `CurveType` for available options.
|
|
45
|
+
*/
|
|
46
|
+
curveType?: CurveType;
|
|
47
|
+
/**
|
|
48
|
+
* The desired number of ticks on the x-axis.
|
|
49
|
+
*/
|
|
50
|
+
xNumTicks?: number;
|
|
51
|
+
/**
|
|
52
|
+
* The desired number of ticks on the y-axis.
|
|
53
|
+
*/
|
|
54
|
+
yNumTicks?: number;
|
|
55
|
+
/**
|
|
56
|
+
* If `true`, hides the chart legend.
|
|
57
|
+
*/
|
|
58
|
+
hideLegend?: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* If `true`, hides the chart tooltip.
|
|
61
|
+
*/
|
|
62
|
+
hideTooltip?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* If `true`, displays grid lines along the x-axis.
|
|
65
|
+
*/
|
|
66
|
+
gridLineX?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* If `true`, displays a domain line (axis line) along the x-axis.
|
|
69
|
+
*/
|
|
70
|
+
domainLineX?: boolean;
|
|
71
|
+
/**
|
|
72
|
+
* If `true`, displays grid lines along the y-axis.
|
|
73
|
+
*/
|
|
74
|
+
gridLineY?: boolean;
|
|
75
|
+
/**
|
|
76
|
+
* If `true`, displays a domain line (axis line) along the y-axis.
|
|
77
|
+
*/
|
|
78
|
+
domainLineY?: boolean;
|
|
79
|
+
/**
|
|
80
|
+
* Optional position for pagination controls, if applicable.
|
|
81
|
+
* See `PaginationPosition` for available options.
|
|
82
|
+
*/
|
|
83
|
+
paginationPoisition?: PaginationPosition;
|
|
84
|
+
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),l=require("@unovis/ts"),o=require("@unovis/vue"),d=require("../Tooltip.cjs"),f={class:"flex items center justify-end"},y=e.defineComponent({__name:"LineChart",props:{data:{},height:{},xLabel:{},yLabel:{},categories:{},xFormatter:{type:Function},yFormatter:{type:Function},curveType:{},yNumTicks:{},xNumTicks:{},paginationPosition:{}},setup(s){const n=s,u=t=>Object.values(n.categories)[t].color,m=e.computed(()=>t=>{if(typeof window>"u"||typeof document>"u")return"";try{const r=e.createApp(d.default,{data:t,categories:n.categories}),a=document.createElement("div");r.mount(a);const i=a.innerHTML;return r.unmount(),i}catch{return""}});return(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["space-y-4 flex flex-col",{"flex-col-reverse":n.paginationPosition==="top"}])},[e.createVNode(e.unref(o.VisXYContainer),{data:t.data,height:t.height},{default:e.withCtx(()=>[e.createVNode(e.unref(o.VisTooltip),{"horizontal-placement":e.unref(l.Position).Right,"vertical-placement":e.unref(l.Position).Top},null,8,["horizontal-placement","vertical-placement"]),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(Object.keys(n.categories),(a,i)=>(e.openBlock(),e.createBlock(e.unref(o.VisLine),{key:i,x:(c,p)=>p,y:c=>c[a],color:u(i),"curve-type":t.curveType??e.unref(l.CurveType).MonotoneX},null,8,["x","y","color","curve-type"]))),128)),e.createVNode(e.unref(o.VisAxis),{type:"x","tick-format":t.xFormatter,"num-ticks":t.xNumTicks??4,label:t.xLabel,"label-margin":8,"domain-line":!1,"grid-line":!1},null,8,["tick-format","num-ticks","label"]),e.createVNode(e.unref(o.VisAxis),{type:"y","num-ticks":t.yNumTicks??4,"tick-format":t.yFormatter,label:t.yLabel,"domain-line":!1},null,8,["num-ticks","tick-format","label"]),e.createVNode(e.unref(o.VisCrosshair),{color:"#666",template:m.value},null,8,["template"])]),_:1},8,["data","height"]),e.createElementVNode("div",f,[e.createVNode(e.unref(o.VisBulletLegend),{items:Object.values(t.categories)},null,8,["items"])])],2))}});exports.default=y;
|
|
2
2
|
//# sourceMappingURL=LineChart.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.cjs","sources":["../../../src/components/Line/LineChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\n\nimport {\n VisAxis,\n VisBulletLegend,\n VisLine,\n VisXYContainer,\n VisTooltip,\n} from \"@unovis/vue\";\n\nimport { PaginationPosition } from \"../../types\";\n\ntype LineChartProps<T> = {\n data: T[];\n height: number;\n xLabel?: string;\n yLabel?: string;\n categories: Record<string,
|
|
1
|
+
{"version":3,"file":"LineChart.cjs","sources":["../../../src/components/Line/LineChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport { computed, createApp } from \"vue\";\n\nimport { CurveType, BulletLegendItemInterface, Position } from \"@unovis/ts\";\n\nimport {\n VisAxis,\n VisBulletLegend,\n VisCrosshair,\n VisLine,\n VisXYContainer,\n VisTooltip,\n} from \"@unovis/vue\";\n\nimport Tooltip from \"./../Tooltip.vue\";\nimport { PaginationPosition } from \"../../types\";\n\ntype LineChartProps<T> = {\n data: T[];\n height: number;\n xLabel?: string;\n yLabel?: string;\n categories: Record<string, BulletLegendItemInterface>;\n xFormatter: (i: number, idx: number) => string;\n yFormatter?: (i: number, idx: number) => string;\n curveType?: CurveType;\n yNumTicks?: number;\n xNumTicks?: number;\n paginationPosition?: PaginationPosition;\n};\n\nconst props = defineProps<LineChartProps<T>>();\n\nconst color = (key: number) => Object.values(props.categories)[key].color;\n\nconst generateTooltip = computed(() => (d: T) => {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return '';\n }\n \n try {\n const app = createApp(Tooltip, {\n data: d,\n categories: props.categories,\n });\n\n const container = document.createElement(\"div\");\n app.mount(container);\n\n const html = container.innerHTML;\n app.unmount();\n\n return html;\n } catch (error) {\n return '';\n }\n});\n</script>\n\n<template>\n <div\n class=\"space-y-4 flex flex-col\"\n :class=\"{\n 'flex-col-reverse': props.paginationPosition === 'top',\n }\"\n >\n <VisXYContainer :data=\"data\" :height=\"height\">\n <VisTooltip\n :horizontal-placement=\"Position.Right\"\n :vertical-placement=\"Position.Top\"\n />\n <template v-for=\"(i, iKey) in Object.keys(props.categories)\" :key=\"iKey\">\n <VisLine\n :x=\"(_: any, i: number) => i\"\n :y=\"(d: T) => d[i as keyof typeof d]\"\n :color=\"color(iKey)\"\n :curve-type=\"curveType ?? CurveType.MonotoneX\"\n />\n </template>\n <VisAxis\n type=\"x\"\n :tick-format=\"xFormatter\"\n :num-ticks=\"xNumTicks ?? 4\"\n :label=\"xLabel\"\n :label-margin=\"8\"\n :domain-line=\"false\"\n :grid-line=\"false\"\n />\n <VisAxis\n type=\"y\"\n :num-ticks=\"yNumTicks ?? 4\"\n :tick-format=\"yFormatter\"\n :label=\"yLabel\"\n :domain-line=\"false\"\n />\n <VisCrosshair color=\"#666\" :template=\"generateTooltip\" />\n </VisXYContainer>\n <div class=\"flex items center justify-end\">\n <VisBulletLegend :items=\"Object.values(categories)\" />\n </div>\n </div>\n</template>\n"],"names":["props","__props","color","key","generateTooltip","computed","d","app","createApp","Tooltip","container","html"],"mappings":"0dA+BA,MAAMA,EAAQC,EAERC,EAASC,GAAgB,OAAO,OAAOH,EAAM,UAAU,EAAEG,CAAG,EAAE,MAE9DC,EAAkBC,EAAAA,SAAS,IAAOC,GAAS,CAC/C,GAAI,OAAO,OAAW,KAAe,OAAO,SAAa,IAChD,MAAA,GAGL,GAAA,CACI,MAAAC,EAAMC,YAAUC,UAAS,CAC7B,KAAMH,EACN,WAAYN,EAAM,UAAA,CACnB,EAEKU,EAAY,SAAS,cAAc,KAAK,EAC9CH,EAAI,MAAMG,CAAS,EAEnB,MAAMC,EAAOD,EAAU,UACvB,OAAAH,EAAI,QAAQ,EAELI,OACO,CACP,MAAA,EAAA,CACT,CACD"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import {
|
|
3
|
-
|
|
1
|
+
import { defineComponent as g, computed as h, createApp as k, createElementBlock as s, openBlock as l, normalizeClass as v, createVNode as o, createElementVNode as b, unref as t, withCtx as T, Fragment as L, renderList as V, createBlock as x } from "vue";
|
|
2
|
+
import { Position as m, CurveType as C } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as F, VisTooltip as N, VisLine as j, VisAxis as u, VisCrosshair as B, VisBulletLegend as w } from "@unovis/vue";
|
|
4
|
+
import z from "../Tooltip.js";
|
|
5
|
+
const E = { class: "flex items center justify-end" }, X = /* @__PURE__ */ g({
|
|
4
6
|
__name: "LineChart",
|
|
5
7
|
props: {
|
|
6
8
|
data: {},
|
|
@@ -10,29 +12,49 @@ const N = /* @__PURE__ */ f({
|
|
|
10
12
|
categories: {},
|
|
11
13
|
xFormatter: { type: Function },
|
|
12
14
|
yFormatter: { type: Function },
|
|
15
|
+
curveType: {},
|
|
13
16
|
yNumTicks: {},
|
|
14
17
|
xNumTicks: {},
|
|
15
18
|
paginationPosition: {}
|
|
16
19
|
},
|
|
17
|
-
setup(
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
setup(p) {
|
|
21
|
+
const n = p, d = (e) => Object.values(n.categories)[e].color, f = h(() => (e) => {
|
|
22
|
+
if (typeof window > "u" || typeof document > "u")
|
|
23
|
+
return "";
|
|
24
|
+
try {
|
|
25
|
+
const r = k(z, {
|
|
26
|
+
data: e,
|
|
27
|
+
categories: n.categories
|
|
28
|
+
}), a = document.createElement("div");
|
|
29
|
+
r.mount(a);
|
|
30
|
+
const i = a.innerHTML;
|
|
31
|
+
return r.unmount(), i;
|
|
32
|
+
} catch {
|
|
33
|
+
return "";
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return (e, r) => (l(), s("div", {
|
|
37
|
+
class: v(["space-y-4 flex flex-col", {
|
|
38
|
+
"flex-col-reverse": n.paginationPosition === "top"
|
|
22
39
|
}])
|
|
23
40
|
}, [
|
|
24
|
-
|
|
41
|
+
o(t(F), {
|
|
25
42
|
data: e.data,
|
|
26
43
|
height: e.height
|
|
27
44
|
}, {
|
|
28
|
-
default:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
45
|
+
default: T(() => [
|
|
46
|
+
o(t(N), {
|
|
47
|
+
"horizontal-placement": t(m).Right,
|
|
48
|
+
"vertical-placement": t(m).Top
|
|
49
|
+
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
50
|
+
(l(!0), s(L, null, V(Object.keys(n.categories), (a, i) => (l(), x(t(j), {
|
|
51
|
+
key: i,
|
|
52
|
+
x: (c, y) => y,
|
|
53
|
+
y: (c) => c[a],
|
|
54
|
+
color: d(i),
|
|
55
|
+
"curve-type": e.curveType ?? t(C).MonotoneX
|
|
56
|
+
}, null, 8, ["x", "y", "color", "curve-type"]))), 128)),
|
|
57
|
+
o(t(u), {
|
|
36
58
|
type: "x",
|
|
37
59
|
"tick-format": e.xFormatter,
|
|
38
60
|
"num-ticks": e.xNumTicks ?? 4,
|
|
@@ -41,20 +63,29 @@ const N = /* @__PURE__ */ f({
|
|
|
41
63
|
"domain-line": !1,
|
|
42
64
|
"grid-line": !1
|
|
43
65
|
}, null, 8, ["tick-format", "num-ticks", "label"]),
|
|
44
|
-
|
|
66
|
+
o(t(u), {
|
|
45
67
|
type: "y",
|
|
46
68
|
"num-ticks": e.yNumTicks ?? 4,
|
|
47
69
|
"tick-format": e.yFormatter,
|
|
48
70
|
label: e.yLabel,
|
|
49
71
|
"domain-line": !1
|
|
50
|
-
}, null, 8, ["num-ticks", "tick-format", "label"])
|
|
72
|
+
}, null, 8, ["num-ticks", "tick-format", "label"]),
|
|
73
|
+
o(t(B), {
|
|
74
|
+
color: "#666",
|
|
75
|
+
template: f.value
|
|
76
|
+
}, null, 8, ["template"])
|
|
51
77
|
]),
|
|
52
78
|
_: 1
|
|
53
|
-
}, 8, ["data", "height"])
|
|
79
|
+
}, 8, ["data", "height"]),
|
|
80
|
+
b("div", E, [
|
|
81
|
+
o(t(w), {
|
|
82
|
+
items: Object.values(e.categories)
|
|
83
|
+
}, null, 8, ["items"])
|
|
84
|
+
])
|
|
54
85
|
], 2));
|
|
55
86
|
}
|
|
56
87
|
});
|
|
57
88
|
export {
|
|
58
|
-
|
|
89
|
+
X as default
|
|
59
90
|
};
|
|
60
91
|
//# sourceMappingURL=LineChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.js","sources":["../../../src/components/Line/LineChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\n\nimport {\n VisAxis,\n VisBulletLegend,\n VisLine,\n VisXYContainer,\n VisTooltip,\n} from \"@unovis/vue\";\n\nimport { PaginationPosition } from \"../../types\";\n\ntype LineChartProps<T> = {\n data: T[];\n height: number;\n xLabel?: string;\n yLabel?: string;\n categories: Record<string,
|
|
1
|
+
{"version":3,"file":"LineChart.js","sources":["../../../src/components/Line/LineChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport { computed, createApp } from \"vue\";\n\nimport { CurveType, BulletLegendItemInterface, Position } from \"@unovis/ts\";\n\nimport {\n VisAxis,\n VisBulletLegend,\n VisCrosshair,\n VisLine,\n VisXYContainer,\n VisTooltip,\n} from \"@unovis/vue\";\n\nimport Tooltip from \"./../Tooltip.vue\";\nimport { PaginationPosition } from \"../../types\";\n\ntype LineChartProps<T> = {\n data: T[];\n height: number;\n xLabel?: string;\n yLabel?: string;\n categories: Record<string, BulletLegendItemInterface>;\n xFormatter: (i: number, idx: number) => string;\n yFormatter?: (i: number, idx: number) => string;\n curveType?: CurveType;\n yNumTicks?: number;\n xNumTicks?: number;\n paginationPosition?: PaginationPosition;\n};\n\nconst props = defineProps<LineChartProps<T>>();\n\nconst color = (key: number) => Object.values(props.categories)[key].color;\n\nconst generateTooltip = computed(() => (d: T) => {\n if (typeof window === 'undefined' || typeof document === 'undefined') {\n return '';\n }\n \n try {\n const app = createApp(Tooltip, {\n data: d,\n categories: props.categories,\n });\n\n const container = document.createElement(\"div\");\n app.mount(container);\n\n const html = container.innerHTML;\n app.unmount();\n\n return html;\n } catch (error) {\n return '';\n }\n});\n</script>\n\n<template>\n <div\n class=\"space-y-4 flex flex-col\"\n :class=\"{\n 'flex-col-reverse': props.paginationPosition === 'top',\n }\"\n >\n <VisXYContainer :data=\"data\" :height=\"height\">\n <VisTooltip\n :horizontal-placement=\"Position.Right\"\n :vertical-placement=\"Position.Top\"\n />\n <template v-for=\"(i, iKey) in Object.keys(props.categories)\" :key=\"iKey\">\n <VisLine\n :x=\"(_: any, i: number) => i\"\n :y=\"(d: T) => d[i as keyof typeof d]\"\n :color=\"color(iKey)\"\n :curve-type=\"curveType ?? CurveType.MonotoneX\"\n />\n </template>\n <VisAxis\n type=\"x\"\n :tick-format=\"xFormatter\"\n :num-ticks=\"xNumTicks ?? 4\"\n :label=\"xLabel\"\n :label-margin=\"8\"\n :domain-line=\"false\"\n :grid-line=\"false\"\n />\n <VisAxis\n type=\"y\"\n :num-ticks=\"yNumTicks ?? 4\"\n :tick-format=\"yFormatter\"\n :label=\"yLabel\"\n :domain-line=\"false\"\n />\n <VisCrosshair color=\"#666\" :template=\"generateTooltip\" />\n </VisXYContainer>\n <div class=\"flex items center justify-end\">\n <VisBulletLegend :items=\"Object.values(categories)\" />\n </div>\n </div>\n</template>\n"],"names":["props","__props","color","key","generateTooltip","computed","d","app","createApp","Tooltip","container","html"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,UAAMA,IAAQC,GAERC,IAAQ,CAACC,MAAgB,OAAO,OAAOH,EAAM,UAAU,EAAEG,CAAG,EAAE,OAE9DC,IAAkBC,EAAS,MAAM,CAACC,MAAS;AAC/C,UAAI,OAAO,SAAW,OAAe,OAAO,WAAa;AAChD,eAAA;AAGL,UAAA;AACI,cAAAC,IAAMC,EAAUC,GAAS;AAAA,UAC7B,MAAMH;AAAA,UACN,YAAYN,EAAM;AAAA,QAAA,CACnB,GAEKU,IAAY,SAAS,cAAc,KAAK;AAC9C,QAAAH,EAAI,MAAMG,CAAS;AAEnB,cAAMC,IAAOD,EAAU;AACvB,eAAAH,EAAI,QAAQ,GAELI;AAAA,cACO;AACP,eAAA;AAAA,MAAA;AAAA,IACT,CACD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CurveType, BulletLegendItemInterface } from '@unovis/ts';
|
|
1
2
|
import { PaginationPosition } from '../../types';
|
|
2
3
|
|
|
3
4
|
declare const _default: <T>(__VLS_props: Awaited<typeof __VLS_setup>["props"], __VLS_ctx?: __VLS_Prettify<Pick<Awaited<typeof __VLS_setup>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
@@ -6,9 +7,10 @@ declare const _default: <T>(__VLS_props: Awaited<typeof __VLS_setup>["props"], _
|
|
|
6
7
|
height: number;
|
|
7
8
|
xLabel?: string;
|
|
8
9
|
yLabel?: string;
|
|
9
|
-
categories: Record<string,
|
|
10
|
+
categories: Record<string, BulletLegendItemInterface>;
|
|
10
11
|
xFormatter: (i: number, idx: number) => string;
|
|
11
12
|
yFormatter?: (i: number, idx: number) => string;
|
|
13
|
+
curveType?: CurveType;
|
|
12
14
|
yNumTicks?: number;
|
|
13
15
|
xNumTicks?: number;
|
|
14
16
|
paginationPosition?: PaginationPosition;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),s=e.defineComponent({__name:"Tooltip",props:{data:{},categories:{}},setup(r){const l=r,n=["_index","_stacked","_ending"],i=e.computed(()=>Object.entries(l.data).filter(([o,a])=>{var t;return!n.includes(o)&&((t=l.categories[o])==null?void 0:t.color)}));return(o,a)=>(e.openBlock(),e.createElementBlock("div",null,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(i.value,([t,c])=>(e.openBlock(),e.createElementBlock("div",{key:t,style:{display:"flex","align-items":"center","margin-bottom":"4px"}},[e.createElementVNode("span",{style:e.normalizeStyle([{width:"8px",height:"8px","border-radius":"4px","margin-right":"8px"},{backgroundColor:o.categories[t].color}])},null,4),e.createElementVNode("div",null,[e.createElementVNode("span",{style:e.normalizeStyle([{"font-weight":"600","margin-right":"8px"},{color:"var(--tooltip-label-color)"}])},e.toDisplayString(t)+":",1),e.createElementVNode("span",{style:e.normalizeStyle([{"font-weight":"400"},{color:"var(--tooltip-value-color)"}])},e.toDisplayString(c),1)])]))),128))]))}});exports.default=s;
|
|
2
|
+
//# sourceMappingURL=Tooltip.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.cjs","sources":["../../src/components/Tooltip.vue"],"sourcesContent":["<script lang=\"ts\" setup generic=\"T\">\nimport { BulletLegendItemInterface } from \"@unovis/ts\";\nimport { computed } from \"vue\";\n\nconst props = defineProps<{\n data: T;\n categories: Record<string, BulletLegendItemInterface>;\n}>();\n\nconst keyBlockList = [\"_index\", \"_stacked\", \"_ending\"];\n\nconst visibleEntries = computed(() => {\n return Object.entries(props.data).filter(\n ([key, _]) => !keyBlockList.includes(key) && props.categories[key]?.color\n );\n});\n</script>\n\n<template>\n <div>\n <div v-for=\"[key, value] in visibleEntries\" :key=\"key\" style=\"display: flex; align-items: center; margin-bottom: 4px;\">\n <span\n style=\"width: 8px; height: 8px; border-radius: 4px; margin-right: 8px;\"\n :style=\"{ backgroundColor: categories[key].color }\"\n ></span>\n <div>\n <span style=\"font-weight: 600; margin-right: 8px;\" :style=\"{ color: 'var(--tooltip-label-color)' }\">{{ key }}:</span>\n <span style=\"font-weight: 400;\" :style=\"{ color: 'var(--tooltip-value-color)' }\">{{ value }}</span>\n </div>\n </div>\n </div>\n</template>\n"],"names":["props","__props","keyBlockList","visibleEntries","computed","key","_","_a"],"mappings":"gNAIA,MAAMA,EAAQC,EAKRC,EAAe,CAAC,SAAU,WAAY,SAAS,EAE/CC,EAAiBC,EAAAA,SAAS,IACvB,OAAO,QAAQJ,EAAM,IAAI,EAAE,OAChC,CAAC,CAACK,EAAKC,CAAC,IAAM,OAAA,OAACJ,EAAa,SAASG,CAAG,KAAKE,EAAAP,EAAM,WAAWK,CAAG,IAApB,YAAAE,EAAuB,OACtE,CACD"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { defineComponent as g, computed as m, createElementBlock as r, openBlock as l, Fragment as x, renderList as _, createElementVNode as o, normalizeStyle as n, toDisplayString as a } from "vue";
|
|
2
|
+
const h = /* @__PURE__ */ g({
|
|
3
|
+
__name: "Tooltip",
|
|
4
|
+
props: {
|
|
5
|
+
data: {},
|
|
6
|
+
categories: {}
|
|
7
|
+
},
|
|
8
|
+
setup(s) {
|
|
9
|
+
const i = s, c = ["_index", "_stacked", "_ending"], p = m(() => Object.entries(i.data).filter(
|
|
10
|
+
([t, d]) => {
|
|
11
|
+
var e;
|
|
12
|
+
return !c.includes(t) && ((e = i.categories[t]) == null ? void 0 : e.color);
|
|
13
|
+
}
|
|
14
|
+
));
|
|
15
|
+
return (t, d) => (l(), r("div", null, [
|
|
16
|
+
(l(!0), r(x, null, _(p.value, ([e, u]) => (l(), r("div", {
|
|
17
|
+
key: e,
|
|
18
|
+
style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
|
|
19
|
+
}, [
|
|
20
|
+
o("span", {
|
|
21
|
+
style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, { backgroundColor: t.categories[e].color }])
|
|
22
|
+
}, null, 4),
|
|
23
|
+
o("div", null, [
|
|
24
|
+
o("span", {
|
|
25
|
+
style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
|
|
26
|
+
}, a(e) + ":", 1),
|
|
27
|
+
o("span", {
|
|
28
|
+
style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
|
|
29
|
+
}, a(u), 1)
|
|
30
|
+
])
|
|
31
|
+
]))), 128))
|
|
32
|
+
]));
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
export {
|
|
36
|
+
h as default
|
|
37
|
+
};
|
|
38
|
+
//# sourceMappingURL=Tooltip.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip.js","sources":["../../src/components/Tooltip.vue"],"sourcesContent":["<script lang=\"ts\" setup generic=\"T\">\nimport { BulletLegendItemInterface } from \"@unovis/ts\";\nimport { computed } from \"vue\";\n\nconst props = defineProps<{\n data: T;\n categories: Record<string, BulletLegendItemInterface>;\n}>();\n\nconst keyBlockList = [\"_index\", \"_stacked\", \"_ending\"];\n\nconst visibleEntries = computed(() => {\n return Object.entries(props.data).filter(\n ([key, _]) => !keyBlockList.includes(key) && props.categories[key]?.color\n );\n});\n</script>\n\n<template>\n <div>\n <div v-for=\"[key, value] in visibleEntries\" :key=\"key\" style=\"display: flex; align-items: center; margin-bottom: 4px;\">\n <span\n style=\"width: 8px; height: 8px; border-radius: 4px; margin-right: 8px;\"\n :style=\"{ backgroundColor: categories[key].color }\"\n ></span>\n <div>\n <span style=\"font-weight: 600; margin-right: 8px;\" :style=\"{ color: 'var(--tooltip-label-color)' }\">{{ key }}:</span>\n <span style=\"font-weight: 400;\" :style=\"{ color: 'var(--tooltip-value-color)' }\">{{ value }}</span>\n </div>\n </div>\n </div>\n</template>\n"],"names":["props","__props","keyBlockList","visibleEntries","computed","key","_","_a"],"mappings":";;;;;;;;AAIA,UAAMA,IAAQC,GAKRC,IAAe,CAAC,UAAU,YAAY,SAAS,GAE/CC,IAAiBC,EAAS,MACvB,OAAO,QAAQJ,EAAM,IAAI,EAAE;AAAA,MAChC,CAAC,CAACK,GAAKC,CAAC,MAAM;;AAAA,gBAACJ,EAAa,SAASG,CAAG,OAAKE,IAAAP,EAAM,WAAWK,CAAG,MAApB,gBAAAE,EAAuB;AAAA;AAAA,IACtE,CACD;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { BulletLegendItemInterface } from '@unovis/ts';
|
|
2
|
+
|
|
3
|
+
declare const _default: <T>(__VLS_props: Awaited<typeof __VLS_setup>["props"], __VLS_ctx?: __VLS_Prettify<Pick<Awaited<typeof __VLS_setup>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
|
|
4
|
+
props: __VLS_Prettify<__VLS_OmitKeepDiscriminatedUnion<(Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>) & {
|
|
5
|
+
data: T;
|
|
6
|
+
categories: Record<string, BulletLegendItemInterface>;
|
|
7
|
+
}, keyof import('vue').VNodeProps | keyof import('vue').AllowedComponentProps>> & {} & (import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps);
|
|
8
|
+
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
9
|
+
attrs: any;
|
|
10
|
+
slots: ReturnType<() => {}>;
|
|
11
|
+
emit: typeof __VLS_emit;
|
|
12
|
+
}>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
13
|
+
[key: string]: any;
|
|
14
|
+
}> & {
|
|
15
|
+
__ctx?: Awaited<typeof __VLS_setup>;
|
|
16
|
+
};
|
|
17
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Tooltip2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
package/dist/components.d.ts
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./components/Line/LineChart.cjs");exports.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./components/Area/AreaChart.cjs"),t=require("./components/Line/LineChart.cjs");exports.AreaChart=e.default;exports.LineChart=t.default;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { default as
|
|
1
|
+
import { default as e } from "./components/Area/AreaChart.js";
|
|
2
|
+
import { default as f } from "./components/Line/LineChart.js";
|
|
2
3
|
export {
|
|
3
|
-
|
|
4
|
+
e as AreaChart,
|
|
5
|
+
f as LineChart
|
|
4
6
|
};
|
|
5
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
|