vue-chrts 0.1.0-beta.2-internal-17 → 0.1.0-beta.2-internal-19
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/vue-chrts.js +8524 -0
- package/dist/vue-chrts.umd.cjs +373 -0
- package/package.json +8 -21
- package/dist/components/Area/AreaChart.cjs +0 -7
- package/dist/components/Area/AreaChart.cjs.map +0 -1
- package/dist/components/Area/AreaChart.d.ts +0 -17
- package/dist/components/Area/AreaChart.js +0 -134
- package/dist/components/Area/AreaChart.js.map +0 -1
- package/dist/components/Area/AreaChart2.cjs +0 -2
- package/dist/components/Area/AreaChart2.cjs.map +0 -1
- package/dist/components/Area/AreaChart2.js +0 -5
- package/dist/components/Area/AreaChart2.js.map +0 -1
- package/dist/components/Area/index.d.ts +0 -2
- package/dist/components/Area/types.d.ts +0 -83
- package/dist/components/AreaStacked/AreaStackedChart.cjs +0 -2
- package/dist/components/AreaStacked/AreaStackedChart.cjs.map +0 -1
- package/dist/components/AreaStacked/AreaStackedChart.d.ts +0 -20
- package/dist/components/AreaStacked/AreaStackedChart.js +0 -70
- package/dist/components/AreaStacked/AreaStackedChart.js.map +0 -1
- package/dist/components/AreaStacked/AreaStackedChart2.cjs +0 -2
- package/dist/components/AreaStacked/AreaStackedChart2.cjs.map +0 -1
- package/dist/components/AreaStacked/AreaStackedChart2.js +0 -5
- package/dist/components/AreaStacked/AreaStackedChart2.js.map +0 -1
- package/dist/components/AreaStacked/index.d.ts +0 -1
- package/dist/components/Bar/BarChart.cjs +0 -2
- package/dist/components/Bar/BarChart.cjs.map +0 -1
- package/dist/components/Bar/BarChart.d.ts +0 -36
- package/dist/components/Bar/BarChart.js +0 -114
- package/dist/components/Bar/BarChart.js.map +0 -1
- package/dist/components/Bar/BarChart2.cjs +0 -2
- package/dist/components/Bar/BarChart2.cjs.map +0 -1
- package/dist/components/Bar/BarChart2.js +0 -5
- package/dist/components/Bar/BarChart2.js.map +0 -1
- package/dist/components/Bar/index.d.ts +0 -1
- package/dist/components/Crosshair/Crosshair.cjs +0 -2
- package/dist/components/Crosshair/Crosshair.cjs.map +0 -1
- package/dist/components/Crosshair/Crosshair.d.ts +0 -38
- package/dist/components/Crosshair/Crosshair.js +0 -40
- package/dist/components/Crosshair/Crosshair.js.map +0 -1
- 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
- package/dist/components/Donut/DonutChart.cjs +0 -6
- package/dist/components/Donut/DonutChart.cjs.map +0 -1
- package/dist/components/Donut/DonutChart.d.ts +0 -22
- package/dist/components/Donut/DonutChart.js +0 -59
- package/dist/components/Donut/DonutChart.js.map +0 -1
- package/dist/components/Donut/DonutChart2.cjs +0 -2
- package/dist/components/Donut/DonutChart2.cjs.map +0 -1
- package/dist/components/Donut/DonutChart2.js +0 -5
- package/dist/components/Donut/DonutChart2.js.map +0 -1
- package/dist/components/Donut/index.cjs +0 -2
- package/dist/components/Donut/index.cjs.map +0 -1
- package/dist/components/Donut/index.d.ts +0 -17
- package/dist/components/Donut/index.js +0 -5
- package/dist/components/Donut/index.js.map +0 -1
- package/dist/components/Line/LineChart.cjs +0 -2
- package/dist/components/Line/LineChart.cjs.map +0 -1
- package/dist/components/Line/LineChart.d.ts +0 -27
- package/dist/components/Line/LineChart.js +0 -91
- package/dist/components/Line/LineChart.js.map +0 -1
- package/dist/components/Line/LineChart2.cjs +0 -2
- package/dist/components/Line/LineChart2.cjs.map +0 -1
- package/dist/components/Line/LineChart2.js +0 -5
- package/dist/components/Line/LineChart2.js.map +0 -1
- package/dist/components/Line/index.d.ts +0 -1
- package/dist/components/Tooltip.cjs +0 -2
- package/dist/components/Tooltip.cjs.map +0 -1
- package/dist/components/Tooltip.d.ts +0 -17
- package/dist/components/Tooltip.js +0 -38
- package/dist/components/Tooltip.js.map +0 -1
- package/dist/components/Tooltip2.cjs +0 -2
- package/dist/components/Tooltip2.cjs.map +0 -1
- package/dist/components/Tooltip2.js +0 -5
- package/dist/components/Tooltip2.js.map +0 -1
- package/dist/components.d.ts +0 -6
- package/dist/index.cjs +0 -2
- package/dist/index.cjs.map +0 -1
- package/dist/index.d.ts +0 -6
- package/dist/index.js +0 -23
- package/dist/index.js.map +0 -1
- package/dist/types/components/Area/AreaChart.vue.d.ts +0 -16
- package/dist/types/components/Area/index.d.ts +0 -2
- package/dist/types/components/Area/types.d.ts +0 -82
- package/dist/types/components/AreaStacked/AreaStackedChart.vue.d.ts +0 -22
- package/dist/types/components/AreaStacked/index.d.ts +0 -1
- package/dist/types/components/Bar/BarChart.vue.d.ts +0 -35
- package/dist/types/components/Bar/index.d.ts +0 -1
- package/dist/types/components/Crosshair/Crosshair.vue.d.ts +0 -12
- package/dist/types/components/Crosshair/index.d.ts +0 -1
- package/dist/types/components/Donut/DonutChart.vue.d.ts +0 -29
- package/dist/types/components/Donut/index.d.ts +0 -17
- package/dist/types/components/Line/LineChart.vue.d.ts +0 -29
- package/dist/types/components/Line/index.d.ts +0 -1
- package/dist/types/components/Tooltip.vue.d.ts +0 -19
- package/dist/types/components.d.ts +0 -6
- package/dist/types/index.d.ts +0 -6
- package/dist/types/types.d.ts +0 -4
- package/dist/types/utils.d.ts +0 -1
- package/dist/types.cjs +0 -2
- package/dist/types.cjs.map +0 -1
- package/dist/types.d.ts +0 -4
- package/dist/types.js +0 -5
- package/dist/types.js.map +0 -1
- package/dist/utils.cjs +0 -2
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.js +0 -19
- package/dist/utils.js.map +0 -1
package/package.json
CHANGED
|
@@ -1,34 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vue-chrts",
|
|
3
|
-
"version": "0.1.0-beta.2-internal-
|
|
3
|
+
"version": "0.1.0-beta.2-internal-19",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"files": [
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
],
|
|
6
|
+
"files": ["dist"],
|
|
7
|
+
"main": "./dist/my-lib.umd.cjs",
|
|
8
|
+
"module": "./dist/my-lib.js",
|
|
10
9
|
"exports": {
|
|
11
10
|
".": {
|
|
12
|
-
"
|
|
13
|
-
"require": "./dist/
|
|
14
|
-
"import": "./dist/index.js"
|
|
15
|
-
},
|
|
16
|
-
"./*": {
|
|
17
|
-
"types": "./*/dist/index.d.ts",
|
|
18
|
-
"require": "./*/dist/index.cjs",
|
|
19
|
-
"import": "./*/dist/index.js"
|
|
11
|
+
"import": "./dist/my-lib.js",
|
|
12
|
+
"require": "./dist/my-lib.umd.cjs"
|
|
20
13
|
}
|
|
21
14
|
},
|
|
22
|
-
"main": "./dist/vue-chrts.umd.js",
|
|
23
|
-
"module": "./dist/vue-chrts.es.js",
|
|
24
|
-
"types": "./dist/types/index.d.ts",
|
|
25
|
-
"typings": "./index.d.ts",
|
|
26
|
-
"sideEffects": false,
|
|
27
15
|
"scripts": {
|
|
28
16
|
"dev": "vite",
|
|
29
|
-
"build": "vite build
|
|
30
|
-
"
|
|
31
|
-
"build:types": "vue-tsc --declaration --emitDeclarationOnly --outDir dist/types",
|
|
17
|
+
"build": "vite build",
|
|
18
|
+
"preview": "vite preview",
|
|
32
19
|
"deploy": "pnpm build && npm publish"
|
|
33
20
|
},
|
|
34
21
|
"peerDependencies": {
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),v=require("../../utils.cjs"),c=require("@unovis/ts"),i=require("@unovis/vue"),h=require("../Tooltip.cjs"),T=require("../../types.cjs"),B=e.defineComponent({__name:"AreaChart",props:{data:{},height:{},xLabel:{},yLabel:{},categories:{},xFormatter:{},yFormatter:{},curveType:{},xNumTicks:{default:a=>a.data.length>24?24/4:a.data.length-1},yNumTicks:{default:a=>a.data.length>24?24/4:a.data.length-1},hideLegend:{type:Boolean},hideTooltip:{type:Boolean},gridLineX:{type:Boolean},domainLineX:{type:Boolean},gridLineY:{type:Boolean},domainLineY:{type:Boolean},paginationPosition:{}},setup(a){const o=a,u=Object.values(o.categories).map(t=>t.color),g=e.computed(()=>t=>{if(typeof window>"u"||typeof document>"u")return"";try{const n=e.createApp(h.default,{data:t,categories:o.categories}),r=document.createElement("div");n.mount(r);const l=r.innerHTML;return n.unmount(),l}catch{return""}});function y(t){var n;return{y:r=>Number(r[t]),color:((n=o.categories[t])==null?void 0:n.color)??"#3b82f6"}}const k=u.map((t,n)=>`
|
|
2
|
-
<linearGradient id="gradient${n}-${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(""),f=e.computed(()=>o.paginationPosition===T.PaginationPosition.Top),s=e.computed(()=>v.getDistributedIndices(o.data.length,o.xNumTicks)),d=e.computed(()=>{var t;return!((t=o.data)!=null&&t.length)||!s||s.value.length===0?[]:s.value.map(n=>o.data[n])});return(t,n)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex flex-col space-y-4",{"flex-col-reverse":f.value}])},[e.createVNode(e.unref(i.VisXYContainer),{data:d.value,height:t.height,"svg-defs":e.unref(k)},{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(o.categories),(r,l)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:l},[e.createVNode(e.unref(i.VisArea),e.mergeProps({x:(p,m)=>m,ref_for:!0},y(r),{color:`url(#gradient${l}-${e.unref(u)[l]})`,opacity:.5,"curve-type":t.curveType??e.unref(c.CurveType).MonotoneX}),null,16,["x","color","curve-type"]),e.createVNode(e.unref(i.VisLine),{x:(p,m)=>m,y:p=>p[r],color:e.unref(u)[l],"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","num-ticks":d.value.length,"tick-format":r=>t.xFormatter(d.value[r]),label:t.xLabel,"grid-line":t.gridLineX,"domain-line":t.domainLineX,"tick-line":!!t.gridLineX},null,8,["num-ticks","tick-format","label","grid-line","domain-line","tick-line"]),e.createVNode(e.unref(i.VisAxis),{type:"y","num-ticks":t.yNumTicks,"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(i.VisCrosshair),{key:1,color:"#666",template:g.value},null,8,["template"]))]),_:1},8,["data","height","svg-defs"]),t.hideLegend?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items center justify-end",{"pb-4":f.value}])},[e.createVNode(e.unref(i.VisBulletLegend),{items:Object.values(t.categories)},null,8,["items"])],2))],2))}});exports.default=B;
|
|
7
|
-
//# sourceMappingURL=AreaChart.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 { getDistributedIndices } from '../../utils'\nimport {\n type NumericAccessor,\n CurveType,\n Position,\n} 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\";\nimport { AreaChartProps } from \"./types\";\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\nconst PaginationPositionTop = computed(\n () => props.paginationPosition === PaginationPosition.Top\n);\n\nconst tickIndices = computed(() => getDistributedIndices(props.data.length, props.xNumTicks))\n\nconst filteredDataByIndices = computed(() => {\n if (!props.data?.length || !tickIndices || tickIndices.value.length === 0) {\n return [];\n }\n return tickIndices.value.map((index) => props.data[index]);\n})\n\n</script>\n\n<template>\n <div\n class=\"flex flex-col space-y-4\"\n :class=\"{ 'flex-col-reverse': PaginationPositionTop }\"\n >\n <VisXYContainer :data=\"filteredDataByIndices\" :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 :num-ticks=\"filteredDataByIndices.length\"\n :tick-format=\"(i: number) => xFormatter(filteredDataByIndices[i])\"\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\"\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\n v-if=\"!hideLegend\"\n class=\"flex items center justify-end\"\n :class=\"{ 'pb-4': PaginationPositionTop }\"\n >\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","PaginationPositionTop","PaginationPosition","tickIndices","getDistributedIndices","filteredDataByIndices"],"mappings":"6sBAsBA,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,EAEJE,EAAwBb,EAAA,SAC5B,IAAML,EAAM,qBAAuBmB,qBAAmB,GACxD,EAEMC,EAAcf,WAAS,IAAOgB,wBAAsBrB,EAAM,KAAK,OAAQA,EAAM,SAAS,CAAC,EAEvFsB,EAAwBjB,EAAAA,SAAS,IAAM,OACvC,MAAA,GAACS,EAAAd,EAAM,OAAN,MAAAc,EAAY,SAAU,CAACM,GAAeA,EAAY,MAAM,SAAW,EAC/D,CAAC,EAEHA,EAAY,MAAM,IAAKH,GAAUjB,EAAM,KAAKiB,CAAK,CAAC,CAAA,CAC1D"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { AreaChartProps } from './types';
|
|
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>) & AreaChartProps<T>, keyof import('vue').VNodeProps | keyof import('vue').AllowedComponentProps>> & {} & (import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps);
|
|
5
|
-
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
6
|
-
attrs: any;
|
|
7
|
-
slots: ReturnType<() => {}>;
|
|
8
|
-
emit: typeof __VLS_emit;
|
|
9
|
-
}>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
10
|
-
[key: string]: any;
|
|
11
|
-
}> & {
|
|
12
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
13
|
-
};
|
|
14
|
-
export default _default;
|
|
15
|
-
type __VLS_Prettify<T> = {
|
|
16
|
-
[K in keyof T]: T[K];
|
|
17
|
-
} & {};
|
|
@@ -1,134 +0,0 @@
|
|
|
1
|
-
import { defineComponent as X, computed as c, createApp as N, createElementBlock as d, openBlock as l, normalizeClass as v, createVNode as s, createCommentVNode as y, unref as t, withCtx as $, createBlock as k, Fragment as L, renderList as Y, mergeProps as j } from "vue";
|
|
2
|
-
import { getDistributedIndices as F } from "../../utils.js";
|
|
3
|
-
import { Position as T, CurveType as b } from "@unovis/ts";
|
|
4
|
-
import { VisXYContainer as A, VisTooltip as w, VisArea as z, VisLine as D, VisAxis as B, VisCrosshair as I, VisBulletLegend as M } from "@unovis/vue";
|
|
5
|
-
import O from "../Tooltip.js";
|
|
6
|
-
import { PaginationPosition as E } from "../../types.js";
|
|
7
|
-
const Q = /* @__PURE__ */ X({
|
|
8
|
-
__name: "AreaChart",
|
|
9
|
-
props: {
|
|
10
|
-
data: {},
|
|
11
|
-
height: {},
|
|
12
|
-
xLabel: {},
|
|
13
|
-
yLabel: {},
|
|
14
|
-
categories: {},
|
|
15
|
-
xFormatter: {},
|
|
16
|
-
yFormatter: {},
|
|
17
|
-
curveType: {},
|
|
18
|
-
xNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
|
|
19
|
-
yNumTicks: { default: (a) => a.data.length > 24 ? 24 / 4 : a.data.length - 1 },
|
|
20
|
-
hideLegend: { type: Boolean },
|
|
21
|
-
hideTooltip: { type: Boolean },
|
|
22
|
-
gridLineX: { type: Boolean },
|
|
23
|
-
domainLineX: { type: Boolean },
|
|
24
|
-
gridLineY: { type: Boolean },
|
|
25
|
-
domainLineY: { type: Boolean },
|
|
26
|
-
paginationPosition: {}
|
|
27
|
-
},
|
|
28
|
-
setup(a) {
|
|
29
|
-
const i = a, u = Object.values(i.categories).map((e) => e.color), V = c(() => (e) => {
|
|
30
|
-
if (typeof window > "u" || typeof document > "u")
|
|
31
|
-
return "";
|
|
32
|
-
try {
|
|
33
|
-
const o = N(O, {
|
|
34
|
-
data: e,
|
|
35
|
-
categories: i.categories
|
|
36
|
-
}), n = document.createElement("div");
|
|
37
|
-
o.mount(n);
|
|
38
|
-
const r = n.innerHTML;
|
|
39
|
-
return o.unmount(), r;
|
|
40
|
-
} catch {
|
|
41
|
-
return "";
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
function C(e) {
|
|
45
|
-
var o;
|
|
46
|
-
return {
|
|
47
|
-
y: (n) => Number(n[e]),
|
|
48
|
-
color: ((o = i.categories[e]) == null ? void 0 : o.color) ?? "#3b82f6"
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
const P = u.map(
|
|
52
|
-
(e, o) => `
|
|
53
|
-
<linearGradient id="gradient${o}-${e}" gradientTransform="rotate(90)">
|
|
54
|
-
<stop offset="0%" stop-color="${e}" stop-opacity="1" />
|
|
55
|
-
<stop offset="100%" stop-color="${e}" stop-opacity="0" />
|
|
56
|
-
</linearGradient>
|
|
57
|
-
`
|
|
58
|
-
).join(""), h = c(
|
|
59
|
-
() => i.paginationPosition === E.Top
|
|
60
|
-
), m = c(() => F(i.data.length, i.xNumTicks)), p = c(() => {
|
|
61
|
-
var e;
|
|
62
|
-
return !((e = i.data) != null && e.length) || !m || m.value.length === 0 ? [] : m.value.map((o) => i.data[o]);
|
|
63
|
-
});
|
|
64
|
-
return (e, o) => (l(), d("div", {
|
|
65
|
-
class: v(["flex flex-col space-y-4", { "flex-col-reverse": h.value }])
|
|
66
|
-
}, [
|
|
67
|
-
s(t(A), {
|
|
68
|
-
data: p.value,
|
|
69
|
-
height: e.height,
|
|
70
|
-
"svg-defs": t(P)
|
|
71
|
-
}, {
|
|
72
|
-
default: $(() => [
|
|
73
|
-
e.hideTooltip ? y("", !0) : (l(), k(t(w), {
|
|
74
|
-
key: 0,
|
|
75
|
-
"horizontal-placement": t(T).Right,
|
|
76
|
-
"vertical-placement": t(T).Top
|
|
77
|
-
}, null, 8, ["horizontal-placement", "vertical-placement"])),
|
|
78
|
-
(l(!0), d(L, null, Y(Object.keys(i.categories), (n, r) => (l(), d(L, { key: r }, [
|
|
79
|
-
s(t(z), j({
|
|
80
|
-
x: (g, f) => f,
|
|
81
|
-
ref_for: !0
|
|
82
|
-
}, C(n), {
|
|
83
|
-
color: `url(#gradient${r}-${t(u)[r]})`,
|
|
84
|
-
opacity: 0.5,
|
|
85
|
-
"curve-type": e.curveType ?? t(b).MonotoneX
|
|
86
|
-
}), null, 16, ["x", "color", "curve-type"]),
|
|
87
|
-
s(t(D), {
|
|
88
|
-
x: (g, f) => f,
|
|
89
|
-
y: (g) => g[n],
|
|
90
|
-
color: t(u)[r],
|
|
91
|
-
"curve-type": e.curveType ?? t(b).MonotoneX
|
|
92
|
-
}, null, 8, ["x", "y", "color", "curve-type"])
|
|
93
|
-
], 64))), 128)),
|
|
94
|
-
s(t(B), {
|
|
95
|
-
type: "x",
|
|
96
|
-
"num-ticks": p.value.length,
|
|
97
|
-
"tick-format": (n) => e.xFormatter(p.value[n]),
|
|
98
|
-
label: e.xLabel,
|
|
99
|
-
"grid-line": e.gridLineX,
|
|
100
|
-
"domain-line": e.domainLineX,
|
|
101
|
-
"tick-line": !!e.gridLineX
|
|
102
|
-
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
103
|
-
s(t(B), {
|
|
104
|
-
type: "y",
|
|
105
|
-
"num-ticks": e.yNumTicks,
|
|
106
|
-
"tick-format": e.yFormatter,
|
|
107
|
-
label: e.yLabel,
|
|
108
|
-
"grid-line": e.gridLineY,
|
|
109
|
-
"domain-line": e.domainLineY,
|
|
110
|
-
"tick-line": !!e.gridLineY
|
|
111
|
-
}, null, 8, ["num-ticks", "tick-format", "label", "grid-line", "domain-line", "tick-line"]),
|
|
112
|
-
e.hideTooltip ? y("", !0) : (l(), k(t(I), {
|
|
113
|
-
key: 1,
|
|
114
|
-
color: "#666",
|
|
115
|
-
template: V.value
|
|
116
|
-
}, null, 8, ["template"]))
|
|
117
|
-
]),
|
|
118
|
-
_: 1
|
|
119
|
-
}, 8, ["data", "height", "svg-defs"]),
|
|
120
|
-
e.hideLegend ? y("", !0) : (l(), d("div", {
|
|
121
|
-
key: 0,
|
|
122
|
-
class: v(["flex items center justify-end", { "pb-4": h.value }])
|
|
123
|
-
}, [
|
|
124
|
-
s(t(M), {
|
|
125
|
-
items: Object.values(e.categories)
|
|
126
|
-
}, null, 8, ["items"])
|
|
127
|
-
], 2))
|
|
128
|
-
], 2));
|
|
129
|
-
}
|
|
130
|
-
});
|
|
131
|
-
export {
|
|
132
|
-
Q as default
|
|
133
|
-
};
|
|
134
|
-
//# sourceMappingURL=AreaChart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 { getDistributedIndices } from '../../utils'\nimport {\n type NumericAccessor,\n CurveType,\n Position,\n} 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\";\nimport { AreaChartProps } from \"./types\";\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\nconst PaginationPositionTop = computed(\n () => props.paginationPosition === PaginationPosition.Top\n);\n\nconst tickIndices = computed(() => getDistributedIndices(props.data.length, props.xNumTicks))\n\nconst filteredDataByIndices = computed(() => {\n if (!props.data?.length || !tickIndices || tickIndices.value.length === 0) {\n return [];\n }\n return tickIndices.value.map((index) => props.data[index]);\n})\n\n</script>\n\n<template>\n <div\n class=\"flex flex-col space-y-4\"\n :class=\"{ 'flex-col-reverse': PaginationPositionTop }\"\n >\n <VisXYContainer :data=\"filteredDataByIndices\" :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 :num-ticks=\"filteredDataByIndices.length\"\n :tick-format=\"(i: number) => xFormatter(filteredDataByIndices[i])\"\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\"\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\n v-if=\"!hideLegend\"\n class=\"flex items center justify-end\"\n :class=\"{ 'pb-4': PaginationPositionTop }\"\n >\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","PaginationPositionTop","PaginationPosition","tickIndices","getDistributedIndices","filteredDataByIndices"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBA,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,GAEJE,IAAwBb;AAAA,MAC5B,MAAML,EAAM,uBAAuBmB,EAAmB;AAAA,IACxD,GAEMC,IAAcf,EAAS,MAAOgB,EAAsBrB,EAAM,KAAK,QAAQA,EAAM,SAAS,CAAC,GAEvFsB,IAAwBjB,EAAS,MAAM;;AACvC,aAAA,GAACS,IAAAd,EAAM,SAAN,QAAAc,EAAY,WAAU,CAACM,KAAeA,EAAY,MAAM,WAAW,IAC/D,CAAC,IAEHA,EAAY,MAAM,IAAI,CAACH,MAAUjB,EAAM,KAAKiB,CAAK,CAAC;AAAA,IAAA,CAC1D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AreaChart2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AreaChart2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { PaginationPosition } from '../../types';
|
|
2
|
-
import { BulletLegendItemInterface, CurveType } from '@unovis/ts';
|
|
3
|
-
|
|
4
|
-
export interface 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 item The x-axis value to be formatted.
|
|
31
|
-
* @returns The formatted x-axis label.
|
|
32
|
-
*/
|
|
33
|
-
xFormatter: (item: T) => string | number;
|
|
34
|
-
/**
|
|
35
|
-
* An optional function that formats the y-axis tick labels.
|
|
36
|
-
* @param i The value to be formatted.
|
|
37
|
-
* @param idx The index of the data point (optional).
|
|
38
|
-
* @returns The formatted y-axis label or value.
|
|
39
|
-
*/
|
|
40
|
-
yFormatter?: (i: number, idx?: number) => string | number;
|
|
41
|
-
/**
|
|
42
|
-
* The type of curve to use for the area chart lines.
|
|
43
|
-
* See `CurveType` for available options.
|
|
44
|
-
*/
|
|
45
|
-
curveType?: CurveType;
|
|
46
|
-
/**
|
|
47
|
-
* The desired number of ticks on the x-axis.
|
|
48
|
-
*/
|
|
49
|
-
xNumTicks?: number;
|
|
50
|
-
/**
|
|
51
|
-
* The desired number of ticks on the y-axis.
|
|
52
|
-
*/
|
|
53
|
-
yNumTicks?: number;
|
|
54
|
-
/**
|
|
55
|
-
* If `true`, hides the chart legend.
|
|
56
|
-
*/
|
|
57
|
-
hideLegend?: boolean;
|
|
58
|
-
/**
|
|
59
|
-
* If `true`, hides the chart tooltip.
|
|
60
|
-
*/
|
|
61
|
-
hideTooltip?: boolean;
|
|
62
|
-
/**
|
|
63
|
-
* If `true`, displays grid lines along the x-axis.
|
|
64
|
-
*/
|
|
65
|
-
gridLineX?: boolean;
|
|
66
|
-
/**
|
|
67
|
-
* If `true`, displays a domain line (axis line) along the x-axis.
|
|
68
|
-
*/
|
|
69
|
-
domainLineX?: boolean;
|
|
70
|
-
/**
|
|
71
|
-
* If `true`, displays grid lines along the y-axis.
|
|
72
|
-
*/
|
|
73
|
-
gridLineY?: boolean;
|
|
74
|
-
/**
|
|
75
|
-
* If `true`, displays a domain line (axis line) along the y-axis.
|
|
76
|
-
*/
|
|
77
|
-
domainLineY?: boolean;
|
|
78
|
-
/**
|
|
79
|
-
* Optional position for pagination controls, if applicable.
|
|
80
|
-
* See `PaginationPosition` for available options.
|
|
81
|
-
*/
|
|
82
|
-
paginationPosition?: PaginationPosition;
|
|
83
|
-
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),r=require("@unovis/vue"),d=require("@unovis/ts"),p=require("../Tooltip.cjs"),m={class:"flex flex-col space-y-4"},f={class:"flex items center justify-end"},h=e.defineComponent({__name:"AreaStackedChart",props:{data:{},height:{},categories:{},hideTooltip:{type:Boolean}},setup(a){const i=a,c=e.computed(()=>t=>{if(typeof window>"u"||typeof document>"u")return"";try{const o=e.createApp(p.default,{data:t,categories:i.categories}),n=document.createElement("div");o.mount(n);const l=n.innerHTML;return o.unmount(),l}catch{return""}}),s=t=>Number.parseInt(t.time),u=[t=>t.firstTime,t=>t.returning];return(t,o)=>(e.openBlock(),e.createElementBlock("div",m,[e.createVNode(e.unref(r.VisXYContainer),{data:t.data,height:t.height},{default:e.withCtx(()=>[e.createVNode(e.unref(r.VisArea),{x:s,y:u,color:Object.values(i.categories).map(n=>n.color),"curve-type":e.unref(d.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}),t.hideTooltip?e.createCommentVNode("",!0):(e.openBlock(),e.createBlock(e.unref(r.VisCrosshair),{key:0,color:"#666",template:c.value},null,8,["template"]))]),_:1},8,["data","height"]),e.createElementVNode("div",f,[e.createVNode(e.unref(r.VisBulletLegend),{items:Object.values(t.categories)},null,8,["items"])])]))}});exports.default=h;
|
|
2
|
-
//# sourceMappingURL=AreaStackedChart.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
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 height: number;\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=\"height\">\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","generateTooltip","computed","d","app","createApp","Tooltip","container","html","x","y"],"mappings":"yZAmBA,MAAMA,EAAQC,EAERC,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,WAAYJ,EAAM,UAAA,CACnB,EAEKQ,EAAY,SAAS,cAAc,KAAK,EAC9CH,EAAI,MAAMG,CAAS,EAEnB,MAAMC,EAAOD,EAAU,UACvB,OAAAH,EAAI,QAAQ,EAELI,OACO,CACP,MAAA,EAAA,CACT,CACD,EAEKC,EAAKN,GACF,OAAO,SAASA,EAAE,IAAI,EAEzBO,EAAI,CAAEP,GAAWA,EAAE,UAAYA,GAAWA,EAAE,SAAS"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { BulletLegendItemInterface } from '@unovis/ts';
|
|
2
|
-
|
|
3
|
-
export type AreaStackedChartProps<T> = {
|
|
4
|
-
data: T[];
|
|
5
|
-
height: number;
|
|
6
|
-
categories: Record<string, BulletLegendItemInterface>;
|
|
7
|
-
hideTooltip?: boolean;
|
|
8
|
-
};
|
|
9
|
-
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<{
|
|
10
|
-
props: __VLS_Prettify<__VLS_OmitKeepDiscriminatedUnion<(Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>) & AreaStackedChartProps<T>, keyof import('vue').VNodeProps | keyof import('vue').AllowedComponentProps>> & {} & (import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps);
|
|
11
|
-
expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
|
|
12
|
-
attrs: any;
|
|
13
|
-
slots: ReturnType<() => {}>;
|
|
14
|
-
emit: typeof __VLS_emit;
|
|
15
|
-
}>) => import('vue').VNode<import('vue').RendererNode, import('vue').RendererElement, {
|
|
16
|
-
[key: string]: any;
|
|
17
|
-
}> & {
|
|
18
|
-
__ctx?: Awaited<typeof __VLS_setup>;
|
|
19
|
-
};
|
|
20
|
-
export default _default;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { defineComponent as d, computed as f, createApp as h, createElementBlock as y, openBlock as a, createVNode as o, createElementVNode as g, unref as t, withCtx as v, createBlock as _, createCommentVNode as V } from "vue";
|
|
2
|
-
import { VisXYContainer as k, VisArea as C, VisAxis as c, VisCrosshair as T, VisBulletLegend as b } from "@unovis/vue";
|
|
3
|
-
import { CurveType as x } from "@unovis/ts";
|
|
4
|
-
import B from "../Tooltip.js";
|
|
5
|
-
const N = { class: "flex flex-col space-y-4" }, A = { class: "flex items center justify-end" }, O = /* @__PURE__ */ d({
|
|
6
|
-
__name: "AreaStackedChart",
|
|
7
|
-
props: {
|
|
8
|
-
data: {},
|
|
9
|
-
height: {},
|
|
10
|
-
categories: {},
|
|
11
|
-
hideTooltip: { type: Boolean }
|
|
12
|
-
},
|
|
13
|
-
setup(s) {
|
|
14
|
-
const i = s, l = f(() => (e) => {
|
|
15
|
-
if (typeof window > "u" || typeof document > "u")
|
|
16
|
-
return "";
|
|
17
|
-
try {
|
|
18
|
-
const r = h(B, {
|
|
19
|
-
data: e,
|
|
20
|
-
categories: i.categories
|
|
21
|
-
}), n = document.createElement("div");
|
|
22
|
-
r.mount(n);
|
|
23
|
-
const p = n.innerHTML;
|
|
24
|
-
return r.unmount(), p;
|
|
25
|
-
} catch {
|
|
26
|
-
return "";
|
|
27
|
-
}
|
|
28
|
-
}), m = (e) => Number.parseInt(e.time), u = [(e) => e.firstTime, (e) => e.returning];
|
|
29
|
-
return (e, r) => (a(), y("div", N, [
|
|
30
|
-
o(t(k), {
|
|
31
|
-
data: e.data,
|
|
32
|
-
height: e.height
|
|
33
|
-
}, {
|
|
34
|
-
default: v(() => [
|
|
35
|
-
o(t(C), {
|
|
36
|
-
x: m,
|
|
37
|
-
y: u,
|
|
38
|
-
color: Object.values(i.categories).map((n) => n.color),
|
|
39
|
-
"curve-type": t(x).Linear
|
|
40
|
-
}, null, 8, ["color", "curve-type"]),
|
|
41
|
-
o(t(c), {
|
|
42
|
-
type: "x",
|
|
43
|
-
label: "Time",
|
|
44
|
-
"num-ticks": 12
|
|
45
|
-
}),
|
|
46
|
-
o(t(c), {
|
|
47
|
-
type: "y",
|
|
48
|
-
label: "Number of visitors",
|
|
49
|
-
"num-ticks": 3
|
|
50
|
-
}),
|
|
51
|
-
e.hideTooltip ? V("", !0) : (a(), _(t(T), {
|
|
52
|
-
key: 0,
|
|
53
|
-
color: "#666",
|
|
54
|
-
template: l.value
|
|
55
|
-
}, null, 8, ["template"]))
|
|
56
|
-
]),
|
|
57
|
-
_: 1
|
|
58
|
-
}, 8, ["data", "height"]),
|
|
59
|
-
g("div", A, [
|
|
60
|
-
o(t(b), {
|
|
61
|
-
items: Object.values(e.categories)
|
|
62
|
-
}, null, 8, ["items"])
|
|
63
|
-
])
|
|
64
|
-
]));
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
export {
|
|
68
|
-
O as default
|
|
69
|
-
};
|
|
70
|
-
//# sourceMappingURL=AreaStackedChart.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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 height: number;\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=\"height\">\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","generateTooltip","computed","d","app","createApp","Tooltip","container","html","x","y"],"mappings":";;;;;;;;;;;;;AAmBA,UAAMA,IAAQC,GAERC,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,YAAYJ,EAAM;AAAA,QAAA,CACnB,GAEKQ,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,GAEKC,IAAI,CAACN,MACF,OAAO,SAASA,EAAE,IAAI,GAEzBO,IAAI,CAAC,CAACP,MAAWA,EAAE,WAAW,CAACA,MAAWA,EAAE,SAAS;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AreaStackedChart2.cjs","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AreaStackedChart2.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default as AreaStackedChart } from './AreaStackedChart';
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("vue"),t=require("@unovis/ts"),r=require("@unovis/vue"),f=require("../Tooltip.cjs"),p=require("../../types.cjs"),m=e.defineComponent({__name:"BarChart",props:{data:{},stacked:{type:Boolean},height:{},xLabel:{},yLabel:{},categories:{},xFormatter:{},yFormatter:{},yNumTicks:{},xNumTicks:{},yAxis:{},groupPadding:{},barPadding:{},radius:{},hideLegend:{type:Boolean},orientation:{default:t.Orientation.Vertical},paginationPosition:{default:p.PaginationPosition.Bottom}},setup(g){const o=g,d=e.computed(()=>o.yAxis.map(n=>a=>a[n])),s=(n,a)=>Object.values(o.categories)[a].color,u=e.computed(()=>n=>{if(typeof window>"u"||typeof document>"u")return"";try{const a=e.createApp(f.default,{data:n,categories:o.categories}),l=document.createElement("div");a.mount(l);const i=l.innerHTML;return a.unmount(),i}catch{return""}}),c=e.computed(()=>o.paginationPosition===p.PaginationPosition.Top);return(n,a)=>(e.openBlock(),e.createElementBlock("div",{class:e.normalizeClass(["flex flex-col space-y-4",{"flex-col-reverse":c.value}])},[e.createVNode(e.unref(r.VisXYContainer),{height:n.height},{default:e.withCtx(()=>[e.createVNode(e.unref(r.VisTooltip),{triggers:{[e.unref(t.GroupedBar).selectors.bar]:u.value,[e.unref(t.StackedBar).selectors.bar]:u.value}},null,8,["triggers"]),n.stacked?(e.openBlock(),e.createBlock(e.unref(r.VisStackedBar),{key:1,data:n.data,x:(l,i)=>i,y:d.value,"grid-line":!1,"domain-line":!1,color:s,"rounded-corners":n.radius??0,"group-padding":n.groupPadding??0,"bar-padding":n.barPadding??.2,orientation:n.orientation??e.unref(t.Orientation).Vertical},null,8,["data","x","y","rounded-corners","group-padding","bar-padding","orientation"])):(e.openBlock(),e.createBlock(e.unref(r.VisGroupedBar),{key:0,data:n.data,x:(l,i)=>i,y:d.value,"grid-line":!1,"domain-line":!1,color:s,"rounded-corners":n.radius??0,"group-padding":n.groupPadding??0,"bar-padding":n.barPadding??.2,orientation:n.orientation??e.unref(t.Orientation).Vertical},null,8,["data","x","y","rounded-corners","group-padding","bar-padding","orientation"])),e.createVNode(e.unref(r.VisAxis),{type:"x",label:n.xLabel,"grid-line":!1,"domain-line":!1,"tick-format":n.xFormatter,"num-ticks":n.xNumTicks,"tick-line":!1},null,8,["label","tick-format","num-ticks"]),e.createVNode(e.unref(r.VisAxis),{type:"y",label:n.yLabel,"grid-line":n.orientation!==e.unref(t.Orientation).Horizontal,"domain-line":!1,"tick-format":n.yFormatter},null,8,["label","grid-line","tick-format"])]),_:1},8,["height"]),n.hideLegend?e.createCommentVNode("",!0):(e.openBlock(),e.createElementBlock("div",{key:0,class:e.normalizeClass(["flex items center justify-end",{"pb-4":c.value}])},[e.createVNode(e.unref(r.VisBulletLegend),{items:Object.values(n.categories)},null,8,["items"])],2))],2))}});exports.default=m;
|
|
2
|
-
//# sourceMappingURL=BarChart.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.cjs","sources":["../../../src/components/Bar/BarChart.vue"],"sourcesContent":["<script setup lang=\"ts\" generic=\"T\">\nimport { computed, ComputedRef, createApp } from \"vue\";\nimport { BulletLegendItemInterface, GroupedBar, Orientation, StackedBar } from \"@unovis/ts\";\n\nimport {\n VisAxis,\n VisBulletLegend,\n VisGroupedBar,\n VisStackedBar,\n VisTooltip,\n VisXYContainer,\n} from \"@unovis/vue\";\n\nimport Tooltip from \"./../Tooltip.vue\";\nimport { PaginationPosition } from \"../../types\";\n\ntype BarChartProps<T> = {\n data: T[];\n stacked?: boolean;\n height: number;\n xLabel?: string;\n yLabel?: string;\n categories: Record<string, BulletLegendItemInterface>;\n xFormatter: (i: number, idx?: number) => string | number;\n yFormatter?: (i: number, idx?: number) => string | number;\n yNumTicks?: number;\n xNumTicks?: number;\n yAxis: (keyof T)[];\n groupPadding?: number;\n barPadding?: number;\n radius?: number;\n hideLegend?: boolean;\n orientation?: Orientation;\n paginationPosition?: PaginationPosition;\n};\n\nconst props = withDefaults(defineProps<BarChartProps<T>>(), {\n orientation: Orientation.Vertical,\n paginationPosition: PaginationPosition.Bottom,\n});\n\nconst yAxis: ComputedRef<((d: T) => T[keyof T])[]> = computed(() => {\n return props.yAxis.map((key) => (d: T) => {\n return d[key];\n });\n});\n\nconst color = (_: T, i: number) => Object.values(props.categories)[i].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\nconst PaginationPositionTop = computed(\n () => props.paginationPosition === PaginationPosition.Top\n);\n</script>\n\n<template>\n <div\n class=\"flex flex-col space-y-4\"\n :class=\"{ 'flex-col-reverse': PaginationPositionTop }\"\n >\n <VisXYContainer :height=\"height\">\n <VisTooltip\n :triggers=\"{\n [GroupedBar.selectors.bar]: generateTooltip,\n [StackedBar.selectors.bar]: generateTooltip,\n }\"\n />\n\n <VisGroupedBar\n v-if=\"!stacked\"\n :data=\"data\"\n :x=\"(_: T, i: number) => i\"\n :y=\"yAxis\"\n :grid-line=\"false\"\n :domain-line=\"false\"\n :color=\"color\"\n :rounded-corners=\"radius ?? 0\"\n :group-padding=\"groupPadding ?? 0\"\n :bar-padding=\"barPadding ?? 0.2\"\n :orientation=\"orientation ?? Orientation.Vertical\"\n />\n <VisStackedBar\n v-else\n :data=\"data\"\n :x=\"(_: T, i: number) => i\"\n :y=\"yAxis\"\n :grid-line=\"false\"\n :domain-line=\"false\"\n :color=\"color\"\n :rounded-corners=\"radius ?? 0\"\n :group-padding=\"groupPadding ?? 0\"\n :bar-padding=\"barPadding ?? 0.2\"\n :orientation=\"orientation ?? Orientation.Vertical\"\n />\n <VisAxis\n type=\"x\"\n :label=\"xLabel\"\n :grid-line=\"false\"\n :domain-line=\"false\"\n :tick-format=\"xFormatter\"\n :num-ticks=\"xNumTicks\"\n :tick-line=\"false\"\n />\n <VisAxis\n type=\"y\"\n :label=\"yLabel\"\n :grid-line=\"orientation !== Orientation.Horizontal\"\n :domain-line=\"false\"\n :tick-format=\"yFormatter\"\n />\n </VisXYContainer>\n <div\n v-if=\"!hideLegend\"\n class=\"flex items center justify-end\"\n :class=\"{ 'pb-4': PaginationPositionTop }\"\n >\n <VisBulletLegend :items=\"Object.values(categories)\" />\n </div>\n </div>\n</template>\n"],"names":["props","__props","yAxis","computed","key","d","color","_","i","generateTooltip","app","createApp","Tooltip","container","html","PaginationPositionTop","PaginationPosition"],"mappings":"ulBAoCA,MAAMA,EAAQC,EAKRC,EAA+CC,EAAAA,SAAS,IACrDH,EAAM,MAAM,IAAKI,GAASC,GACxBA,EAAED,CAAG,CACb,CACF,EAEKE,EAAQ,CAACC,EAAMC,IAAc,OAAO,OAAOR,EAAM,UAAU,EAAEQ,CAAC,EAAE,MAEhEC,EAAkBN,EAAAA,SAAS,IAAOE,GAAS,CAC/C,GAAI,OAAO,OAAW,KAAe,OAAO,SAAa,IAChD,MAAA,GAGL,GAAA,CACI,MAAAK,EAAMC,YAAUC,UAAS,CAC7B,KAAMP,EACN,WAAYL,EAAM,UAAA,CACnB,EAEKa,EAAY,SAAS,cAAc,KAAK,EAC9CH,EAAI,MAAMG,CAAS,EAEnB,MAAMC,EAAOD,EAAU,UACvB,OAAAH,EAAI,QAAQ,EAELI,OACO,CACP,MAAA,EAAA,CACT,CACD,EAEKC,EAAwBZ,EAAA,SAC5B,IAAMH,EAAM,qBAAuBgB,qBAAmB,GACxD"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { BulletLegendItemInterface, Orientation } 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
|
-
stacked?: boolean;
|
|
8
|
-
height: number;
|
|
9
|
-
xLabel?: string;
|
|
10
|
-
yLabel?: string;
|
|
11
|
-
categories: Record<string, BulletLegendItemInterface>;
|
|
12
|
-
xFormatter: (i: number, idx?: number) => string | number;
|
|
13
|
-
yFormatter?: (i: number, idx?: number) => string | number;
|
|
14
|
-
yNumTicks?: number;
|
|
15
|
-
xNumTicks?: number;
|
|
16
|
-
yAxis: (keyof T)[];
|
|
17
|
-
groupPadding?: number;
|
|
18
|
-
barPadding?: number;
|
|
19
|
-
radius?: number;
|
|
20
|
-
hideLegend?: boolean;
|
|
21
|
-
orientation?: Orientation;
|
|
22
|
-
paginationPosition?: 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
|
-
} & {};
|