vue-chrts 0.0.151 → 0.0.152
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 +3 -3
- package/dist/components/Area/AreaChart.cjs.map +1 -1
- package/dist/components/Area/AreaChart.js +34 -38
- package/dist/components/Area/AreaChart.js.map +1 -1
- package/dist/components/AreaStacked/AreaStackedChart.cjs +1 -1
- package/dist/components/AreaStacked/AreaStackedChart.cjs.map +1 -1
- package/dist/components/AreaStacked/AreaStackedChart.js +29 -32
- package/dist/components/AreaStacked/AreaStackedChart.js.map +1 -1
- package/dist/components/Line/LineChart.cjs +1 -1
- package/dist/components/Line/LineChart.cjs.map +1 -1
- package/dist/components/Line/LineChart.js +27 -31
- package/dist/components/Line/LineChart.js.map +1 -1
- package/dist/components.d.ts +0 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +0 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/dist/components/Crosshair/Crosshair.cjs +0 -2
- package/dist/components/Crosshair/Crosshair.cjs.map +0 -1
- package/dist/components/Crosshair/Crosshair.js +0 -40
- package/dist/components/Crosshair/Crosshair.js.map +0 -1
- package/dist/components/Crosshair/Crosshair.vue.d.ts +0 -38
- package/dist/components/Crosshair/Crosshair2.cjs +0 -2
- package/dist/components/Crosshair/Crosshair2.cjs.map +0 -1
- package/dist/components/Crosshair/Crosshair2.js +0 -5
- package/dist/components/Crosshair/Crosshair2.js.map +0 -1
- package/dist/components/Crosshair/index.d.ts +0 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),c=require("@unovis/ts"),
|
|
2
|
-
<linearGradient id="gradient${
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),c=require("@unovis/ts"),i=require("@unovis/vue"),f=require("../Tooltip.cjs"),g={key:0,class:"flex items center justify-end"},y=e.defineComponent({__name:"AreaChart",props:{data:{},height:{},xLabel:{},yLabel:{},categories:{},xFormatter:{},yFormatter:{},curveType:{},xNumTicks:{default:o=>o.data.length>24?24/4:o.data.length-1},yNumTicks:{default:o=>o.data.length>24?24/4:o.data.length-1},hideLegend:{type:Boolean},hideTooltip:{type:Boolean},gridLineX:{type:Boolean},domainLineX:{type:Boolean},gridLineY:{type:Boolean},domainLineY:{type:Boolean},paginationPoisition:{}},setup(o){const l=o,s=Object.values(l.categories).map(t=>t.color);e.computed(()=>t=>{if(typeof window>"u"||typeof document>"u")return"";try{const n=e.createApp(f.default,{data:t,categories:l.categories}),r=document.createElement("div");n.mount(r);const a=r.innerHTML;return n.unmount(),a}catch{return""}});function p(t){var n;return{y:r=>Number(r[t]),color:((n=l.categories[t])==null?void 0:n.color)??"#3b82f6"}}const m=s.map((t,n)=>`
|
|
2
|
+
<linearGradient id="gradient${n}-${t}" gradientTransform="rotate(90)">
|
|
3
3
|
<stop offset="0%" stop-color="${t}" stop-opacity="1" />
|
|
4
4
|
<stop offset="100%" stop-color="${t}" stop-opacity="0" />
|
|
5
5
|
</linearGradient>
|
|
6
|
-
`).join("");return(t,
|
|
6
|
+
`).join("");return(t,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex flex-col space-y-4",{"flex-col-reverse":l.paginationPoisition==="top"}])},[e.createVNode(e.unref(i.VisXYContainer),{data:t.data,height:t.height,"svg-defs":e.unref(m)},{default:e.withCtx(()=>[t.hideTooltip?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(i.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),(r,a)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:a},[e.createVNode(e.unref(i.VisArea),e.mergeProps({x:(u,d)=>d,ref_for:!0},p(r),{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(i.VisLine),{x:(u,d)=>d,y:u=>u[r],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(i.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(i.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"])]),_:1},8,["data","height","svg-defs"]),t.hideLegend?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",g,[e.createVNode(e.unref(i.VisBulletLegend),{items:Object.values(t.categories)},null,8,["items"])]))],2))}});exports.default=y;
|
|
7
7
|
//# sourceMappingURL=AreaChart.cjs.map
|
|
@@ -1 +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
|
|
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","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,EAEzCC,EAAA,SAAS,IAAOC,GAAS,CAC/C,GAAI,OAAO,OAAW,KAAe,OAAO,SAAa,IAChD,MAAA,GAGL,GAAA,CACI,MAAAC,EAAMC,YAAUC,UAAS,CAC7B,KAAMH,EACN,WAAYL,EAAM,UAAA,CACnB,EAEKS,EAAY,SAAS,cAAc,KAAK,EAC9CH,EAAI,MAAMG,CAAS,EAEnB,MAAMC,EAAOD,EAAU,UACvB,OAAAH,EAAI,QAAQ,EAELI,OACO,CACP,MAAA,EAAA,CAEV,CAAA,EAED,SAASC,EAAUC,EAAsD,OAChE,MAAA,CACL,EAAIP,GAAS,OAAOA,EAAEO,CAAoB,CAAC,EAC3C,QAAOC,EAAAb,EAAM,WAAWY,CAAE,IAAnB,YAAAC,EAAsB,QAAS,SACxC,CAAA,CAGF,MAAMC,EAAUZ,EACb,IACC,CAACa,EAAOC,IAAU;AAAA,gCACUA,CAAK,IAAID,CAAK;AAAA,oCACVA,CAAK;AAAA,sCACHA,CAAK;AAAA;AAAA,CAAA,EAIxC,KAAK,EAAE"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as v, computed as T, createApp as b, createElementBlock as c, openBlock as s, normalizeClass as B, createVNode as a, createCommentVNode as u, unref as t, withCtx as V, createBlock as X, Fragment as g, renderList as C, mergeProps as N } from "vue";
|
|
2
|
+
import { Position as f, CurveType as y } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as $, VisTooltip as Y, VisArea as j, VisLine as F, VisAxis as h, VisBulletLegend as A } from "@unovis/vue";
|
|
4
|
+
import P from "../Tooltip.js";
|
|
5
|
+
const w = {
|
|
6
6
|
key: 0,
|
|
7
7
|
class: "flex items center justify-end"
|
|
8
|
-
},
|
|
8
|
+
}, G = /* @__PURE__ */ v({
|
|
9
9
|
__name: "AreaChart",
|
|
10
10
|
props: {
|
|
11
11
|
data: {},
|
|
@@ -27,13 +27,14 @@ const M = {
|
|
|
27
27
|
paginationPoisition: {}
|
|
28
28
|
},
|
|
29
29
|
setup(i) {
|
|
30
|
-
const
|
|
30
|
+
const l = i, d = Object.values(l.categories).map((e) => e.color);
|
|
31
|
+
T(() => (e) => {
|
|
31
32
|
if (typeof window > "u" || typeof document > "u")
|
|
32
33
|
return "";
|
|
33
34
|
try {
|
|
34
|
-
const o =
|
|
35
|
+
const o = b(P, {
|
|
35
36
|
data: e,
|
|
36
|
-
categories:
|
|
37
|
+
categories: l.categories
|
|
37
38
|
}), n = document.createElement("div");
|
|
38
39
|
o.mount(n);
|
|
39
40
|
const r = n.innerHTML;
|
|
@@ -42,14 +43,14 @@ const M = {
|
|
|
42
43
|
return "";
|
|
43
44
|
}
|
|
44
45
|
});
|
|
45
|
-
function
|
|
46
|
+
function k(e) {
|
|
46
47
|
var o;
|
|
47
48
|
return {
|
|
48
49
|
y: (n) => Number(n[e]),
|
|
49
|
-
color: ((o =
|
|
50
|
+
color: ((o = l.categories[e]) == null ? void 0 : o.color) ?? "#3b82f6"
|
|
50
51
|
};
|
|
51
52
|
}
|
|
52
|
-
const
|
|
53
|
+
const L = d.map(
|
|
53
54
|
(e, o) => `
|
|
54
55
|
<linearGradient id="gradient${o}-${e}" gradientTransform="rotate(90)">
|
|
55
56
|
<stop offset="0%" stop-color="${e}" stop-opacity="1" />
|
|
@@ -57,39 +58,39 @@ const M = {
|
|
|
57
58
|
</linearGradient>
|
|
58
59
|
`
|
|
59
60
|
).join("");
|
|
60
|
-
return (e, o) => (
|
|
61
|
-
class:
|
|
62
|
-
"flex-col-reverse":
|
|
61
|
+
return (e, o) => (s(), c("div", {
|
|
62
|
+
class: B(["flex flex-col space-y-4", {
|
|
63
|
+
"flex-col-reverse": l.paginationPoisition === "top"
|
|
63
64
|
}])
|
|
64
65
|
}, [
|
|
65
|
-
|
|
66
|
+
a(t($), {
|
|
66
67
|
data: e.data,
|
|
67
68
|
height: e.height,
|
|
68
|
-
"svg-defs": t(
|
|
69
|
+
"svg-defs": t(L)
|
|
69
70
|
}, {
|
|
70
|
-
default:
|
|
71
|
-
e.hideTooltip ? u("", !0) : (
|
|
71
|
+
default: V(() => [
|
|
72
|
+
e.hideTooltip ? u("", !0) : (s(), X(t(Y), {
|
|
72
73
|
key: 0,
|
|
73
|
-
"horizontal-placement": t(
|
|
74
|
-
"vertical-placement": t(
|
|
74
|
+
"horizontal-placement": t(f).Right,
|
|
75
|
+
"vertical-placement": t(f).Top
|
|
75
76
|
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
76
|
-
(
|
|
77
|
-
|
|
77
|
+
(s(!0), c(g, null, C(Object.keys(l.categories), (n, r) => (s(), c(g, { key: r }, [
|
|
78
|
+
a(t(j), N({
|
|
78
79
|
x: (m, p) => p,
|
|
79
80
|
ref_for: !0
|
|
80
|
-
},
|
|
81
|
+
}, k(n), {
|
|
81
82
|
color: `url(#gradient${r}-${t(d)[r]})`,
|
|
82
83
|
opacity: 0.5,
|
|
83
|
-
"curve-type": e.curveType ?? t(
|
|
84
|
+
"curve-type": e.curveType ?? t(y).MonotoneX
|
|
84
85
|
}), null, 16, ["x", "color", "curve-type"]),
|
|
85
|
-
|
|
86
|
+
a(t(F), {
|
|
86
87
|
x: (m, p) => p,
|
|
87
88
|
y: (m) => m[n],
|
|
88
89
|
color: t(d)[r],
|
|
89
|
-
"curve-type": e.curveType ?? t(
|
|
90
|
+
"curve-type": e.curveType ?? t(y).MonotoneX
|
|
90
91
|
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
91
92
|
], 64))), 128)),
|
|
92
|
-
|
|
93
|
+
a(t(h), {
|
|
93
94
|
type: "x",
|
|
94
95
|
"tick-format": e.xFormatter,
|
|
95
96
|
"num-ticks": e.xNumTicks,
|
|
@@ -98,7 +99,7 @@ const M = {
|
|
|
98
99
|
"domain-line": e.domainLineX,
|
|
99
100
|
"tick-line": !!e.gridLineX
|
|
100
101
|
}, null, 8, ["tick-format", "num-ticks", "label", "grid-line", "domain-line", "tick-line"]),
|
|
101
|
-
|
|
102
|
+
a(t(h), {
|
|
102
103
|
type: "y",
|
|
103
104
|
"num-ticks": e.yNumTicks ?? e.data.length,
|
|
104
105
|
"tick-format": e.yFormatter,
|
|
@@ -106,17 +107,12 @@ const M = {
|
|
|
106
107
|
"grid-line": e.gridLineY,
|
|
107
108
|
"domain-line": e.domainLineY,
|
|
108
109
|
"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"]))
|
|
110
|
+
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"])
|
|
115
111
|
]),
|
|
116
112
|
_: 1
|
|
117
113
|
}, 8, ["data", "height", "svg-defs"]),
|
|
118
|
-
e.hideLegend ? u("", !0) : (
|
|
119
|
-
|
|
114
|
+
e.hideLegend ? u("", !0) : (s(), c("div", w, [
|
|
115
|
+
a(t(A), {
|
|
120
116
|
items: Object.values(e.categories)
|
|
121
117
|
}, null, 8, ["items"])
|
|
122
118
|
]))
|
|
@@ -124,6 +120,6 @@ const M = {
|
|
|
124
120
|
}
|
|
125
121
|
});
|
|
126
122
|
export {
|
|
127
|
-
|
|
123
|
+
G as default
|
|
128
124
|
};
|
|
129
125
|
//# sourceMappingURL=AreaChart.js.map
|
|
@@ -1 +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
|
|
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","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;AAEzC,IAAAC,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,YAAYL,EAAM;AAAA,QAAA,CACnB,GAEKS,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,IAEV,CAAA;AAED,aAASC,EAAUC,GAAsD;;AAChE,aAAA;AAAA,QACL,GAAG,CAACP,MAAS,OAAOA,EAAEO,CAAoB,CAAC;AAAA,QAC3C,SAAOC,IAAAb,EAAM,WAAWY,CAAE,MAAnB,gBAAAC,EAAsB,UAAS;AAAA,MACxC;AAAA,IAAA;AAGF,UAAMC,IAAUZ,EACb;AAAA,MACC,CAACa,GAAOC,MAAU;AAAA,gCACUA,CAAK,IAAID,CAAK;AAAA,oCACVA,CAAK;AAAA,sCACHA,CAAK;AAAA;AAAA;AAAA,IAAA,EAIxC,KAAK,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=require("@unovis/vue"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=require("@unovis/vue"),l=require("@unovis/ts"),d=require("../Tooltip.cjs"),p={class:"flex flex-col space-y-4"},m={class:"flex items center justify-end"},f=e.defineComponent({__name:"AreaStackedChart",props:{data:{},categories:{},hideTooltip:{type:Boolean}},setup(s){const c=s;e.computed(()=>t=>{if(typeof window>"u"||typeof document>"u")return"";try{const n=e.createApp(d.default,{data:t,categories:c.categories}),o=document.createElement("div");n.mount(o);const a=o.innerHTML;return n.unmount(),a}catch{return""}});const i=t=>Number.parseInt(t.time),u=[t=>t.firstTime,t=>t.returning];return(t,n)=>(e.openBlock(),e.createElementBlock("div",p,[e.createVNode(e.unref(r.VisXYContainer),{data:t.data,height:200},{default:e.withCtx(()=>[e.createVNode(e.unref(r.VisArea),{x:i,y:u,color:Object.values(c.categories).map(o=>o.color),"curve-type":e.unref(l.CurveType).Linear},null,8,["color","curve-type"]),e.createVNode(e.unref(r.VisAxis),{type:"x",label:"Time","num-ticks":12}),e.createVNode(e.unref(r.VisAxis),{type:"y",label:"Number of visitors","num-ticks":3})]),_:1},8,["data"]),e.createElementVNode("div",m,[e.createVNode(e.unref(r.VisBulletLegend),{items:Object.values(t.categories)},null,8,["items"])])]))}});exports.default=f;
|
|
2
2
|
//# sourceMappingURL=AreaStackedChart.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AreaStackedChart.cjs","sources":["../../../src/components/AreaStacked/AreaStackedChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport {\n VisXYContainer,\n VisAxis,\n VisArea,\n VisBulletLegend,\n VisCrosshair,\n} from \"@unovis/vue\";\nimport { BulletLegendItemInterface, CurveType } from \"@unovis/ts\";\nimport Tooltip from \"./../Tooltip.vue\";\nimport { computed, createApp } from \"vue\";\n\nexport type AreaStackedChartProps<T> = {\n data: T[];\n categories: Record<string, BulletLegendItemInterface>;\n hideTooltip?: boolean;\n};\n\nconst props = defineProps<AreaStackedChartProps<T>>();\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\nconst x = (d: any) => {\n return Number.parseInt(d.time);\n};\nconst y = [(d: any) => d.firstTime, (d: any) => d.returning];\n</script>\n\n<template>\n <div class=\"flex flex-col space-y-4\">\n <VisXYContainer :data=\"data\" :height=\"200\">\n <VisArea\n :x=\"x\"\n :y=\"y\"\n :color=\"Object.values(props.categories).map((i) => i.color)\"\n :curve-type=\"CurveType.Linear\"\n />\n <VisAxis type=\"x\" label=\"Time\" :num-ticks=\"12\" />\n <VisAxis type=\"y\" label=\"Number of visitors\" :num-ticks=\"3\" />\n <VisCrosshair\n v-if=\"!hideTooltip\"\n color=\"#666\"\n :template=\"generateTooltip\"\n
|
|
1
|
+
{"version":3,"file":"AreaStackedChart.cjs","sources":["../../../src/components/AreaStacked/AreaStackedChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport {\n VisXYContainer,\n VisAxis,\n VisArea,\n VisBulletLegend,\n VisCrosshair,\n} from \"@unovis/vue\";\nimport { BulletLegendItemInterface, CurveType } from \"@unovis/ts\";\nimport Tooltip from \"./../Tooltip.vue\";\nimport { computed, createApp } from \"vue\";\n\nexport type AreaStackedChartProps<T> = {\n data: T[];\n categories: Record<string, BulletLegendItemInterface>;\n hideTooltip?: boolean;\n};\n\nconst props = defineProps<AreaStackedChartProps<T>>();\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\nconst x = (d: any) => {\n return Number.parseInt(d.time);\n};\nconst y = [(d: any) => d.firstTime, (d: any) => d.returning];\n</script>\n\n<template>\n <div class=\"flex flex-col space-y-4\">\n <VisXYContainer :data=\"data\" :height=\"200\">\n <VisArea\n :x=\"x\"\n :y=\"y\"\n :color=\"Object.values(props.categories).map((i) => i.color)\"\n :curve-type=\"CurveType.Linear\"\n />\n <VisAxis type=\"x\" label=\"Time\" :num-ticks=\"12\" />\n <VisAxis type=\"y\" label=\"Number of visitors\" :num-ticks=\"3\" />\n <!-- <VisCrosshair\n v-if=\"!hideTooltip\"\n color=\"#666\"\n :template=\"generateTooltip\"\n /> -->\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","computed","d","app","createApp","Tooltip","container","html","x","y"],"mappings":"+YAkBA,MAAMA,EAAQC,EAEUC,EAAA,SAAS,IAAOC,GAAS,CAC/C,GAAI,OAAO,OAAW,KAAe,OAAO,SAAa,IAChD,MAAA,GAGL,GAAA,CACI,MAAAC,EAAMC,YAAUC,UAAS,CAC7B,KAAMH,EACN,WAAYH,EAAM,UAAA,CACnB,EAEKO,EAAY,SAAS,cAAc,KAAK,EAC9CH,EAAI,MAAMG,CAAS,EAEnB,MAAMC,EAAOD,EAAU,UACvB,OAAAH,EAAI,QAAQ,EAELI,OACO,CACP,MAAA,EAAA,CAEV,CAAA,EAEK,MAAAC,EAAKN,GACF,OAAO,SAASA,EAAE,IAAI,EAEzBO,EAAI,CAAEP,GAAWA,EAAE,UAAYA,GAAWA,EAAE,SAAS"}
|
|
@@ -1,62 +1,59 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { VisXYContainer as
|
|
3
|
-
import { CurveType as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as l, computed as p, createApp as d, createElementBlock as f, openBlock as y, createVNode as r, createElementVNode as _, unref as t, withCtx as h } from "vue";
|
|
2
|
+
import { VisXYContainer as v, VisArea as g, VisAxis as a, VisBulletLegend as x } from "@unovis/vue";
|
|
3
|
+
import { CurveType as b } from "@unovis/ts";
|
|
4
|
+
import V from "../Tooltip.js";
|
|
5
|
+
const k = { class: "flex flex-col space-y-4" }, C = { class: "flex items center justify-end" }, j = /* @__PURE__ */ l({
|
|
6
6
|
__name: "AreaStackedChart",
|
|
7
7
|
props: {
|
|
8
8
|
data: {},
|
|
9
9
|
categories: {},
|
|
10
10
|
hideTooltip: { type: Boolean }
|
|
11
11
|
},
|
|
12
|
-
setup(
|
|
13
|
-
const
|
|
12
|
+
setup(c) {
|
|
13
|
+
const i = c;
|
|
14
|
+
p(() => (e) => {
|
|
14
15
|
if (typeof window > "u" || typeof document > "u")
|
|
15
16
|
return "";
|
|
16
17
|
try {
|
|
17
|
-
const
|
|
18
|
+
const o = d(V, {
|
|
18
19
|
data: e,
|
|
19
|
-
categories:
|
|
20
|
+
categories: i.categories
|
|
20
21
|
}), n = document.createElement("div");
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
return
|
|
22
|
+
o.mount(n);
|
|
23
|
+
const u = n.innerHTML;
|
|
24
|
+
return o.unmount(), u;
|
|
24
25
|
} catch {
|
|
25
26
|
return "";
|
|
26
27
|
}
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
});
|
|
29
|
+
const s = (e) => Number.parseInt(e.time), m = [(e) => e.firstTime, (e) => e.returning];
|
|
30
|
+
return (e, o) => (y(), f("div", k, [
|
|
31
|
+
r(t(v), {
|
|
30
32
|
data: e.data,
|
|
31
33
|
height: 200
|
|
32
34
|
}, {
|
|
33
|
-
default:
|
|
34
|
-
|
|
35
|
-
x:
|
|
36
|
-
y:
|
|
37
|
-
color: Object.values(
|
|
38
|
-
"curve-type": t(
|
|
35
|
+
default: h(() => [
|
|
36
|
+
r(t(g), {
|
|
37
|
+
x: s,
|
|
38
|
+
y: m,
|
|
39
|
+
color: Object.values(i.categories).map((n) => n.color),
|
|
40
|
+
"curve-type": t(b).Linear
|
|
39
41
|
}, null, 8, ["color", "curve-type"]),
|
|
40
|
-
|
|
42
|
+
r(t(a), {
|
|
41
43
|
type: "x",
|
|
42
44
|
label: "Time",
|
|
43
45
|
"num-ticks": 12
|
|
44
46
|
}),
|
|
45
|
-
|
|
47
|
+
r(t(a), {
|
|
46
48
|
type: "y",
|
|
47
49
|
label: "Number of visitors",
|
|
48
50
|
"num-ticks": 3
|
|
49
|
-
})
|
|
50
|
-
e.hideTooltip ? V("", !0) : (i(), g(t(T), {
|
|
51
|
-
key: 0,
|
|
52
|
-
color: "#666",
|
|
53
|
-
template: l.value
|
|
54
|
-
}, null, 8, ["template"]))
|
|
51
|
+
})
|
|
55
52
|
]),
|
|
56
53
|
_: 1
|
|
57
54
|
}, 8, ["data"]),
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
_("div", C, [
|
|
56
|
+
r(t(x), {
|
|
60
57
|
items: Object.values(e.categories)
|
|
61
58
|
}, null, 8, ["items"])
|
|
62
59
|
])
|
|
@@ -64,6 +61,6 @@ const N = { class: "flex flex-col space-y-4" }, A = { class: "flex items center
|
|
|
64
61
|
}
|
|
65
62
|
});
|
|
66
63
|
export {
|
|
67
|
-
|
|
64
|
+
j as default
|
|
68
65
|
};
|
|
69
66
|
//# sourceMappingURL=AreaStackedChart.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AreaStackedChart.js","sources":["../../../src/components/AreaStacked/AreaStackedChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport {\n VisXYContainer,\n VisAxis,\n VisArea,\n VisBulletLegend,\n VisCrosshair,\n} from \"@unovis/vue\";\nimport { BulletLegendItemInterface, CurveType } from \"@unovis/ts\";\nimport Tooltip from \"./../Tooltip.vue\";\nimport { computed, createApp } from \"vue\";\n\nexport type AreaStackedChartProps<T> = {\n data: T[];\n categories: Record<string, BulletLegendItemInterface>;\n hideTooltip?: boolean;\n};\n\nconst props = defineProps<AreaStackedChartProps<T>>();\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\nconst x = (d: any) => {\n return Number.parseInt(d.time);\n};\nconst y = [(d: any) => d.firstTime, (d: any) => d.returning];\n</script>\n\n<template>\n <div class=\"flex flex-col space-y-4\">\n <VisXYContainer :data=\"data\" :height=\"200\">\n <VisArea\n :x=\"x\"\n :y=\"y\"\n :color=\"Object.values(props.categories).map((i) => i.color)\"\n :curve-type=\"CurveType.Linear\"\n />\n <VisAxis type=\"x\" label=\"Time\" :num-ticks=\"12\" />\n <VisAxis type=\"y\" label=\"Number of visitors\" :num-ticks=\"3\" />\n <VisCrosshair\n v-if=\"!hideTooltip\"\n color=\"#666\"\n :template=\"generateTooltip\"\n
|
|
1
|
+
{"version":3,"file":"AreaStackedChart.js","sources":["../../../src/components/AreaStacked/AreaStackedChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport {\n VisXYContainer,\n VisAxis,\n VisArea,\n VisBulletLegend,\n VisCrosshair,\n} from \"@unovis/vue\";\nimport { BulletLegendItemInterface, CurveType } from \"@unovis/ts\";\nimport Tooltip from \"./../Tooltip.vue\";\nimport { computed, createApp } from \"vue\";\n\nexport type AreaStackedChartProps<T> = {\n data: T[];\n categories: Record<string, BulletLegendItemInterface>;\n hideTooltip?: boolean;\n};\n\nconst props = defineProps<AreaStackedChartProps<T>>();\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\nconst x = (d: any) => {\n return Number.parseInt(d.time);\n};\nconst y = [(d: any) => d.firstTime, (d: any) => d.returning];\n</script>\n\n<template>\n <div class=\"flex flex-col space-y-4\">\n <VisXYContainer :data=\"data\" :height=\"200\">\n <VisArea\n :x=\"x\"\n :y=\"y\"\n :color=\"Object.values(props.categories).map((i) => i.color)\"\n :curve-type=\"CurveType.Linear\"\n />\n <VisAxis type=\"x\" label=\"Time\" :num-ticks=\"12\" />\n <VisAxis type=\"y\" label=\"Number of visitors\" :num-ticks=\"3\" />\n <!-- <VisCrosshair\n v-if=\"!hideTooltip\"\n color=\"#666\"\n :template=\"generateTooltip\"\n /> -->\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","computed","d","app","createApp","Tooltip","container","html","x","y"],"mappings":";;;;;;;;;;;;AAkBA,UAAMA,IAAQC;AAEU,IAAAC,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,YAAYH,EAAM;AAAA,QAAA,CACnB,GAEKO,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,IAEV,CAAA;AAEK,UAAAC,IAAI,CAACN,MACF,OAAO,SAASA,EAAE,IAAI,GAEzBO,IAAI,CAAC,CAACP,MAAWA,EAAE,WAAW,CAACA,MAAWA,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),l=require("@unovis/ts"),
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),l=require("@unovis/ts"),n=require("@unovis/vue"),p=require("../Tooltip.cjs"),d={class:"flex items center justify-end"},f=e.defineComponent({__name:"LineChart",props:{data:{},height:{},xLabel:{},yLabel:{},categories:{},xFormatter:{type:Function},yFormatter:{type:Function},curveType:{},yNumTicks:{},xNumTicks:{},paginationPosition:{}},setup(u){const o=u,s=t=>Object.values(o.categories)[t].color;return e.computed(()=>t=>{if(typeof window>"u"||typeof document>"u")return"";try{const r=e.createApp(p.default,{data:t,categories:o.categories}),i=document.createElement("div");r.mount(i);const a=i.innerHTML;return r.unmount(),a}catch{return""}}),(t,r)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["space-y-4 flex flex-col",{"flex-col-reverse":o.paginationPosition==="top"}])},[e.createVNode(e.unref(n.VisXYContainer),{data:t.data,height:t.height},{default:e.withCtx(()=>[e.createVNode(e.unref(n.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(o.categories),(i,a)=>(e.openBlock(),e.createBlock(e.unref(n.VisLine),{key:a,x:(c,m)=>m,y:c=>c[i],color:s(a),"curve-type":t.curveType??e.unref(l.CurveType).MonotoneX},null,8,["x","y","color","curve-type"]))),128)),e.createVNode(e.unref(n.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(n.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"])]),_:1},8,["data","height"]),e.createElementVNode("div",d,[e.createVNode(e.unref(n.VisBulletLegend),{items:Object.values(t.categories)},null,8,["items"])])],2))}});exports.default=f;
|
|
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\">\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\"
|
|
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","computed","d","app","createApp","Tooltip","container","html"],"mappings":"0dA+BA,MAAMA,EAAQC,EAERC,EAASC,GAAgB,OAAO,OAAOH,EAAM,UAAU,EAAEG,CAAG,EAAE,MAE5CC,OAAAA,EAAA,SAAS,IAAOC,GAAS,CAC/C,GAAI,OAAO,OAAW,KAAe,OAAO,SAAa,IAChD,MAAA,GAGL,GAAA,CACI,MAAAC,EAAMC,YAAUC,UAAS,CAC7B,KAAMH,EACN,WAAYL,EAAM,UAAA,CACnB,EAEKS,EAAY,SAAS,cAAc,KAAK,EAC9CH,EAAI,MAAMG,CAAS,EAEnB,MAAMC,EAAOD,EAAU,UACvB,OAAAH,EAAI,QAAQ,EAELI,OACO,CACP,MAAA,EAAA,CAEV,CAAA"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { Position as m, CurveType as
|
|
3
|
-
import { VisXYContainer as
|
|
4
|
-
import
|
|
5
|
-
const
|
|
1
|
+
import { defineComponent as y, computed as g, createApp as h, createElementBlock as s, openBlock as l, normalizeClass as k, createVNode as o, createElementVNode as v, unref as t, withCtx as b, Fragment as T, renderList as L, createBlock as x } from "vue";
|
|
2
|
+
import { Position as m, CurveType as F } from "@unovis/ts";
|
|
3
|
+
import { VisXYContainer as V, VisTooltip as C, VisLine as N, VisAxis as u, VisBulletLegend as j } from "@unovis/vue";
|
|
4
|
+
import B from "../Tooltip.js";
|
|
5
|
+
const w = { class: "flex items center justify-end" }, A = /* @__PURE__ */ y({
|
|
6
6
|
__name: "LineChart",
|
|
7
7
|
props: {
|
|
8
8
|
data: {},
|
|
@@ -18,41 +18,41 @@ const E = { class: "flex items center justify-end" }, X = /* @__PURE__ */ g({
|
|
|
18
18
|
paginationPosition: {}
|
|
19
19
|
},
|
|
20
20
|
setup(p) {
|
|
21
|
-
const n = p, d = (e) => Object.values(n.categories)[e].color
|
|
21
|
+
const n = p, d = (e) => Object.values(n.categories)[e].color;
|
|
22
|
+
return g(() => (e) => {
|
|
22
23
|
if (typeof window > "u" || typeof document > "u")
|
|
23
24
|
return "";
|
|
24
25
|
try {
|
|
25
|
-
const
|
|
26
|
+
const i = h(B, {
|
|
26
27
|
data: e,
|
|
27
28
|
categories: n.categories
|
|
28
|
-
}),
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
return
|
|
29
|
+
}), r = document.createElement("div");
|
|
30
|
+
i.mount(r);
|
|
31
|
+
const a = r.innerHTML;
|
|
32
|
+
return i.unmount(), a;
|
|
32
33
|
} catch {
|
|
33
34
|
return "";
|
|
34
35
|
}
|
|
35
|
-
})
|
|
36
|
-
|
|
37
|
-
class: v(["space-y-4 flex flex-col", {
|
|
36
|
+
}), (e, i) => (l(), s("div", {
|
|
37
|
+
class: k(["space-y-4 flex flex-col", {
|
|
38
38
|
"flex-col-reverse": n.paginationPosition === "top"
|
|
39
39
|
}])
|
|
40
40
|
}, [
|
|
41
|
-
o(t(
|
|
41
|
+
o(t(V), {
|
|
42
42
|
data: e.data,
|
|
43
43
|
height: e.height
|
|
44
44
|
}, {
|
|
45
|
-
default:
|
|
46
|
-
o(t(
|
|
45
|
+
default: b(() => [
|
|
46
|
+
o(t(C), {
|
|
47
47
|
"horizontal-placement": t(m).Right,
|
|
48
48
|
"vertical-placement": t(m).Top
|
|
49
49
|
}, null, 8, ["horizontal-placement", "vertical-placement"]),
|
|
50
|
-
(l(!0), s(
|
|
51
|
-
key:
|
|
52
|
-
x: (c,
|
|
53
|
-
y: (c) => c[
|
|
54
|
-
color: d(
|
|
55
|
-
"curve-type": e.curveType ?? t(
|
|
50
|
+
(l(!0), s(T, null, L(Object.keys(n.categories), (r, a) => (l(), x(t(N), {
|
|
51
|
+
key: a,
|
|
52
|
+
x: (c, f) => f,
|
|
53
|
+
y: (c) => c[r],
|
|
54
|
+
color: d(a),
|
|
55
|
+
"curve-type": e.curveType ?? t(F).MonotoneX
|
|
56
56
|
}, null, 8, ["x", "y", "color", "curve-type"]))), 128)),
|
|
57
57
|
o(t(u), {
|
|
58
58
|
type: "x",
|
|
@@ -69,16 +69,12 @@ const E = { class: "flex items center justify-end" }, X = /* @__PURE__ */ g({
|
|
|
69
69
|
"tick-format": e.yFormatter,
|
|
70
70
|
label: e.yLabel,
|
|
71
71
|
"domain-line": !1
|
|
72
|
-
}, null, 8, ["num-ticks", "tick-format", "label"])
|
|
73
|
-
o(t(B), {
|
|
74
|
-
color: "#666",
|
|
75
|
-
template: f.value
|
|
76
|
-
}, null, 8, ["template"])
|
|
72
|
+
}, null, 8, ["num-ticks", "tick-format", "label"])
|
|
77
73
|
]),
|
|
78
74
|
_: 1
|
|
79
75
|
}, 8, ["data", "height"]),
|
|
80
|
-
|
|
81
|
-
o(t(
|
|
76
|
+
v("div", w, [
|
|
77
|
+
o(t(j), {
|
|
82
78
|
items: Object.values(e.categories)
|
|
83
79
|
}, null, 8, ["items"])
|
|
84
80
|
])
|
|
@@ -86,6 +82,6 @@ const E = { class: "flex items center justify-end" }, X = /* @__PURE__ */ g({
|
|
|
86
82
|
}
|
|
87
83
|
});
|
|
88
84
|
export {
|
|
89
|
-
|
|
85
|
+
A as default
|
|
90
86
|
};
|
|
91
87
|
//# 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\">\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\"
|
|
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","computed","d","app","createApp","Tooltip","container","html"],"mappings":";;;;;;;;;;;;;;;;;;;;AA+BA,UAAMA,IAAQC,GAERC,IAAQ,CAACC,MAAgB,OAAO,OAAOH,EAAM,UAAU,EAAEG,CAAG,EAAE;AAE5C,WAAAC,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,YAAYL,EAAM;AAAA,QAAA,CACnB,GAEKS,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,IAEV,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
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("./utils.cjs"),t=require("./components/Area/AreaChart.cjs"),r=require("./components/AreaStacked/AreaStackedChart.cjs"),u=require("./components/Line/LineChart.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./utils.cjs"),t=require("./components/Area/AreaChart.cjs"),r=require("./components/AreaStacked/AreaStackedChart.cjs"),u=require("./components/Line/LineChart.cjs"),a=require("./components/Bar/BarChart.cjs"),_=require("./components/Donut/DonutChart.cjs");exports.hasAutoOrScrollCss=e.hasAutoOrScrollCss;exports.isBrowser=e.isBrowser;exports.isIE=e.isIE;exports.isVerticalOrientation=e.isVerticalOrientation;exports.AreaChart=t.default;exports.AreaStackedChart=r.default;exports.LineChart=u.default;exports.BarChart=a.default;exports.DonutChart=_.default;
|
|
2
2
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.js
CHANGED
|
@@ -4,12 +4,10 @@ import { default as u } from "./components/AreaStacked/AreaStackedChart.js";
|
|
|
4
4
|
import { default as h } from "./components/Line/LineChart.js";
|
|
5
5
|
import { default as p } from "./components/Bar/BarChart.js";
|
|
6
6
|
import { default as C } from "./components/Donut/DonutChart.js";
|
|
7
|
-
import { default as c } from "./components/Crosshair/Crosshair.js";
|
|
8
7
|
export {
|
|
9
8
|
l as AreaChart,
|
|
10
9
|
u as AreaStackedChart,
|
|
11
10
|
p as BarChart,
|
|
12
|
-
c as Crosshair,
|
|
13
11
|
C as DonutChart,
|
|
14
12
|
h as LineChart,
|
|
15
13
|
t as hasAutoOrScrollCss,
|
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":";;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),d=require("@unovis/ts"),i=require("@unovis/vue"),_=e.defineComponent({__name:"Crosshair",props:{colors:{default:()=>[]},index:{},items:{},customTooltip:{}},setup(s){const o=s,r=new WeakMap;function c(t){if(r.has(t))return r.get(t);if(typeof window<"u"){const n=document.createElement("div"),u=Object.entries(d.omit(t,[o.index])).map(([p,m])=>({...o.items.find(f=>f.name===p),value:m})),l=o.customTooltip??i.VisTooltip;return e.createApp(l,{title:t[o.index].toString(),data:u}).mount(n),r.set(t,n.innerHTML),n.innerHTML}}function a(t,n){return o.colors[n]??"transparent"}return(t,n)=>(e.openBlock(),e.createElementBlock(e.Fragment,null,[e.createVNode(e.unref(i.VisTooltip),{"horizontal-shift":20,"vertical-shift":20}),e.createVNode(e.unref(i.VisCrosshair),{template:c,color:a})],64))}});exports.default=_;
|
|
2
|
-
//# sourceMappingURL=Crosshair.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Crosshair.cjs","sources":["../../../src/components/Crosshair/Crosshair.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { BulletLegendItemInterface } from '@unovis/ts'\nimport { omit } from '@unovis/ts'\nimport { VisCrosshair, VisTooltip } from '@unovis/vue'\nimport { type Component, createApp } from 'vue'\n\nconst props = withDefaults(defineProps<{\n colors: string[]\n index: string\n items: BulletLegendItemInterface[]\n customTooltip?: Component\n}>(), {\n colors: () => [],\n})\n\n// Use weakmap to store reference to each datapoint for Tooltip\nconst wm = new WeakMap()\nfunction template(d: any) {\n if (wm.has(d)) {\n return wm.get(d)\n }\n else {\n if (typeof window !== 'undefined') {\n const componentDiv = document.createElement('div')\n const omittedData = Object.entries(omit(d, [props.index])).map(([key, value]) => {\n const legendReference = props.items.find(i => i.name === key)\n return { ...legendReference, value }\n })\n const TooltipComponent = props.customTooltip ?? VisTooltip\n createApp(TooltipComponent, { title: d[props.index].toString(), data: omittedData }).mount(componentDiv)\n wm.set(d, componentDiv.innerHTML)\n return componentDiv.innerHTML\n }\n\n }\n}\n\nfunction color(_: unknown, i: number) {\n return props.colors[i] ?? 'transparent'\n}\n</script>\n\n<template>\n <VisTooltip :horizontal-shift=\"20\" :vertical-shift=\"20\" />\n <VisCrosshair :template=\"template\" :color=\"color\" />\n</template>"],"names":["props","__props","wm","template","d","componentDiv","omittedData","omit","key","value","i","TooltipComponent","VisTooltip","createApp","color","_"],"mappings":"wSAMA,MAAMA,EAAQC,EAURC,MAAS,QACf,SAASC,EAASC,EAAQ,CACpB,GAAAF,EAAG,IAAIE,CAAC,EACH,OAAAF,EAAG,IAAIE,CAAC,EAGX,GAAA,OAAO,OAAW,IAAa,CAC3B,MAAAC,EAAe,SAAS,cAAc,KAAK,EAC3CC,EAAc,OAAO,QAAQC,EAAK,KAAAH,EAAG,CAACJ,EAAM,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAACQ,EAAKC,CAAK,KAElE,CAAE,GADeT,EAAM,MAAM,KAAUU,GAAAA,EAAE,OAASF,CAAG,EAC/B,MAAAC,CAAM,EACpC,EACGE,EAAmBX,EAAM,eAAiBY,EAAA,WAChDC,OAAAA,EAAAA,UAAUF,EAAkB,CAAE,MAAOP,EAAEJ,EAAM,KAAK,EAAE,SAAS,EAAG,KAAMM,CAAa,CAAA,EAAE,MAAMD,CAAY,EACpGH,EAAA,IAAIE,EAAGC,EAAa,SAAS,EACzBA,EAAa,SAAA,CAGtB,CAGO,SAAAS,EAAMC,EAAYL,EAAW,CAC7B,OAAAV,EAAM,OAAOU,CAAC,GAAK,aAAA"}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { defineComponent as h, createElementBlock as _, openBlock as T, Fragment as g, createVNode as r, unref as i, createApp as x } from "vue";
|
|
2
|
-
import { omit as w } from "@unovis/ts";
|
|
3
|
-
import { VisTooltip as s, VisCrosshair as C } from "@unovis/vue";
|
|
4
|
-
const B = /* @__PURE__ */ h({
|
|
5
|
-
__name: "Crosshair",
|
|
6
|
-
props: {
|
|
7
|
-
colors: { default: () => [] },
|
|
8
|
-
index: {},
|
|
9
|
-
items: {},
|
|
10
|
-
customTooltip: {}
|
|
11
|
-
},
|
|
12
|
-
setup(c) {
|
|
13
|
-
const n = c, o = /* @__PURE__ */ new WeakMap();
|
|
14
|
-
function a(e) {
|
|
15
|
-
if (o.has(e))
|
|
16
|
-
return o.get(e);
|
|
17
|
-
if (typeof window < "u") {
|
|
18
|
-
const t = document.createElement("div"), p = Object.entries(w(e, [n.index])).map(([f, u]) => ({ ...n.items.find((d) => d.name === f), value: u })), l = n.customTooltip ?? s;
|
|
19
|
-
return x(l, { title: e[n.index].toString(), data: p }).mount(t), o.set(e, t.innerHTML), t.innerHTML;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
function m(e, t) {
|
|
23
|
-
return n.colors[t] ?? "transparent";
|
|
24
|
-
}
|
|
25
|
-
return (e, t) => (T(), _(g, null, [
|
|
26
|
-
r(i(s), {
|
|
27
|
-
"horizontal-shift": 20,
|
|
28
|
-
"vertical-shift": 20
|
|
29
|
-
}),
|
|
30
|
-
r(i(C), {
|
|
31
|
-
template: a,
|
|
32
|
-
color: m
|
|
33
|
-
})
|
|
34
|
-
], 64));
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
export {
|
|
38
|
-
B as default
|
|
39
|
-
};
|
|
40
|
-
//# sourceMappingURL=Crosshair.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Crosshair.js","sources":["../../../src/components/Crosshair/Crosshair.vue"],"sourcesContent":["<script setup lang=\"ts\">\nimport type { BulletLegendItemInterface } from '@unovis/ts'\nimport { omit } from '@unovis/ts'\nimport { VisCrosshair, VisTooltip } from '@unovis/vue'\nimport { type Component, createApp } from 'vue'\n\nconst props = withDefaults(defineProps<{\n colors: string[]\n index: string\n items: BulletLegendItemInterface[]\n customTooltip?: Component\n}>(), {\n colors: () => [],\n})\n\n// Use weakmap to store reference to each datapoint for Tooltip\nconst wm = new WeakMap()\nfunction template(d: any) {\n if (wm.has(d)) {\n return wm.get(d)\n }\n else {\n if (typeof window !== 'undefined') {\n const componentDiv = document.createElement('div')\n const omittedData = Object.entries(omit(d, [props.index])).map(([key, value]) => {\n const legendReference = props.items.find(i => i.name === key)\n return { ...legendReference, value }\n })\n const TooltipComponent = props.customTooltip ?? VisTooltip\n createApp(TooltipComponent, { title: d[props.index].toString(), data: omittedData }).mount(componentDiv)\n wm.set(d, componentDiv.innerHTML)\n return componentDiv.innerHTML\n }\n\n }\n}\n\nfunction color(_: unknown, i: number) {\n return props.colors[i] ?? 'transparent'\n}\n</script>\n\n<template>\n <VisTooltip :horizontal-shift=\"20\" :vertical-shift=\"20\" />\n <VisCrosshair :template=\"template\" :color=\"color\" />\n</template>"],"names":["props","__props","wm","template","d","componentDiv","omittedData","omit","key","value","i","TooltipComponent","VisTooltip","createApp","color","_"],"mappings":";;;;;;;;;;;;AAMA,UAAMA,IAAQC,GAURC,wBAAS,QAAQ;AACvB,aAASC,EAASC,GAAQ;AACpB,UAAAF,EAAG,IAAIE,CAAC;AACH,eAAAF,EAAG,IAAIE,CAAC;AAGX,UAAA,OAAO,SAAW,KAAa;AAC3B,cAAAC,IAAe,SAAS,cAAc,KAAK,GAC3CC,IAAc,OAAO,QAAQC,EAAKH,GAAG,CAACJ,EAAM,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,CAACQ,GAAKC,CAAK,OAElE,EAAE,GADeT,EAAM,MAAM,KAAK,CAAKU,MAAAA,EAAE,SAASF,CAAG,GAC/B,OAAAC,EAAM,EACpC,GACGE,IAAmBX,EAAM,iBAAiBY;AAChD,eAAAC,EAAUF,GAAkB,EAAE,OAAOP,EAAEJ,EAAM,KAAK,EAAE,SAAS,GAAG,MAAMM,EAAa,CAAA,EAAE,MAAMD,CAAY,GACpGH,EAAA,IAAIE,GAAGC,EAAa,SAAS,GACzBA,EAAa;AAAA,MAAA;AAAA,IAGtB;AAGO,aAAAS,EAAMC,GAAYL,GAAW;AAC7B,aAAAV,EAAM,OAAOU,CAAC,KAAK;AAAA,IAAA;;;;;;;;;;;;;"}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { BulletLegendItemInterface } from '@unovis/ts';
|
|
2
|
-
import { Component } from 'vue';
|
|
3
|
-
|
|
4
|
-
declare const _default: import('vue').DefineComponent<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
5
|
-
colors: string[];
|
|
6
|
-
index: string;
|
|
7
|
-
items: BulletLegendItemInterface[];
|
|
8
|
-
customTooltip?: Component;
|
|
9
|
-
}>, {
|
|
10
|
-
colors: () => any[];
|
|
11
|
-
}>>, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {}, string, import('vue').PublicProps, Readonly<import('vue').ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
12
|
-
colors: string[];
|
|
13
|
-
index: string;
|
|
14
|
-
items: BulletLegendItemInterface[];
|
|
15
|
-
customTooltip?: Component;
|
|
16
|
-
}>, {
|
|
17
|
-
colors: () => any[];
|
|
18
|
-
}>>> & Readonly<{}>, {
|
|
19
|
-
colors: string[];
|
|
20
|
-
}, {}, {}, {}, string, import('vue').ComponentProvideOptions, true, {}, any>;
|
|
21
|
-
export default _default;
|
|
22
|
-
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
23
|
-
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
24
|
-
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
25
|
-
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
26
|
-
} : {
|
|
27
|
-
type: import('vue').PropType<T[K]>;
|
|
28
|
-
required: true;
|
|
29
|
-
};
|
|
30
|
-
};
|
|
31
|
-
type __VLS_WithDefaults<P, D> = {
|
|
32
|
-
[K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
|
|
33
|
-
default: D[K];
|
|
34
|
-
}> : P[K];
|
|
35
|
-
};
|
|
36
|
-
type __VLS_Prettify<T> = {
|
|
37
|
-
[K in keyof T]: T[K];
|
|
38
|
-
} & {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Crosshair2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Crosshair2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as Crosshair } from './Crosshair.vue';
|