vue-chrts 0.2.0-test.9 → 0.2.1

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.
@@ -0,0 +1,163 @@
1
+ import { defineComponent as U, useSlots as j, useTemplateRef as w, ref as R, computed as d, createElementBlock as c, openBlock as a, normalizeClass as T, createVNode as u, createCommentVNode as p, createElementVNode as X, unref as i, withCtx as S, createBlock as m, Fragment as L, renderList as Y, mergeProps as C, renderSlot as A } from "vue";
2
+ import { Position as b, CurveType as D } from "@unovis/ts";
3
+ import { createMarkers as z, getFirstPropertyValue as I } from "../../utils.js";
4
+ import x from "../Tooltip.js";
5
+ import { VisXYContainer as H, VisTooltip as K, VisArea as q, VisLine as J, VisAxis as B, VisCrosshair as Q, VisBulletLegend as Z } from "@unovis/vue";
6
+ import { LegendPosition as _ } from "../../types.js";
7
+ const ee = {
8
+ ref: "slotWrapper",
9
+ class: "hidden"
10
+ }, y = 24, V = 4, te = 0.5, F = "#3b82f6", se = /* @__PURE__ */ U({
11
+ __name: "AreaChart",
12
+ props: {
13
+ data: {},
14
+ height: {},
15
+ xLabel: {},
16
+ yLabel: {},
17
+ padding: { default: () => ({ top: 5, right: 5, bottom: 5, left: 5 }) },
18
+ categories: {},
19
+ markerConfig: {},
20
+ xFormatter: {},
21
+ yFormatter: {},
22
+ curveType: {},
23
+ lineWidth: { default: 2 },
24
+ lineDashArray: {},
25
+ xNumTicks: { default: (n) => n.data.length > y ? y / V : n.data.length - 1 },
26
+ xExplicitTicks: {},
27
+ minMaxTicksOnly: { type: Boolean },
28
+ yNumTicks: { default: (n) => n.data.length > y ? y / V : n.data.length - 1 },
29
+ hideLegend: { type: Boolean },
30
+ hideTooltip: { type: Boolean },
31
+ legendPosition: {},
32
+ xDomainLine: { type: Boolean },
33
+ yDomainLine: { type: Boolean },
34
+ xTickLine: { type: Boolean },
35
+ yTickLine: { type: Boolean },
36
+ xGridLine: { type: Boolean },
37
+ yGridLine: { type: Boolean },
38
+ hideXAxis: { type: Boolean },
39
+ hideYAxis: { type: Boolean },
40
+ crosshairConfig: { default: () => ({
41
+ color: "#666"
42
+ }) }
43
+ },
44
+ emits: ["click"],
45
+ setup(n, { emit: $ }) {
46
+ const G = $, r = n, O = j(), h = w("slotWrapper"), s = R(), f = d(
47
+ () => Object.values(r.categories).map((e) => e.color)
48
+ ), N = d(() => r.markerConfig ? z(r.markerConfig) : ""), g = d(() => r.legendPosition === _.Top), E = d(() => {
49
+ const e = (t, o) => `
50
+ <linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
51
+ <stop offset="0%" stop-color="${o}" stop-opacity="1" />
52
+ <stop offset="100%" stop-color="${o}" stop-opacity="0" />
53
+ </linearGradient>
54
+ `, l = (t, o) => `
55
+ <linearGradient id="gradient${t}-${o}" gradientTransform="rotate(90)">
56
+ <stop offset="0%" style="stop-color:var(--vis-color0);stop-opacity:1" />
57
+ <stop offset="100%" style="stop-color:var(--vis-color0);stop-opacity:0" />
58
+ </linearGradient>
59
+ `;
60
+ return f.value.map(
61
+ (t, o) => t != null && t.includes("#") ? e(o, t) : l(o, t ?? F)
62
+ ).join("");
63
+ });
64
+ function P(e) {
65
+ var l;
66
+ return {
67
+ y: (t) => Number(t[e]),
68
+ color: ((l = r.categories[e]) == null ? void 0 : l.color) ?? F
69
+ };
70
+ }
71
+ function W(e) {
72
+ return typeof window > "u" ? "" : h.value ? h.value.innerHTML : "";
73
+ }
74
+ function M(e) {
75
+ return s.value = e, W();
76
+ }
77
+ return (e, l) => (a(), c("div", {
78
+ class: T(["flex flex-col", { "flex-col-reverse": g.value, markers: !!r.markerConfig }]),
79
+ onClick: l[0] || (l[0] = (t) => G("click", t, s.value))
80
+ }, [
81
+ u(i(H), {
82
+ data: e.data,
83
+ height: e.height,
84
+ padding: e.padding,
85
+ "svg-defs": E.value + N.value
86
+ }, {
87
+ default: S(() => [
88
+ e.hideTooltip ? p("", !0) : (a(), m(i(K), {
89
+ key: 0,
90
+ "horizontal-placement": i(b).Right,
91
+ "vertical-placement": i(b).Top
92
+ }, null, 8, ["horizontal-placement", "vertical-placement"])),
93
+ (a(!0), c(L, null, Y(Object.keys(r.categories), (t, o) => (a(), c(L, { key: t }, [
94
+ u(i(q), C({
95
+ x: (k, v) => v
96
+ }, { ref_for: !0 }, P(t), {
97
+ color: `url(#gradient${o}-${f.value[o]})`,
98
+ opacity: te,
99
+ "curve-type": e.curveType ?? i(D).MonotoneX
100
+ }), null, 16, ["x", "color", "curve-type"]),
101
+ u(i(J), {
102
+ x: (k, v) => v,
103
+ y: (k) => k[t],
104
+ color: f.value[o],
105
+ "curve-type": e.curveType ?? i(D).MonotoneX,
106
+ "line-width": e.lineWidth,
107
+ lineDashArray: e.lineDashArray ? e.lineDashArray[o] : void 0
108
+ }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"])
109
+ ], 64))), 128)),
110
+ e.hideXAxis ? p("", !0) : (a(), m(i(B), {
111
+ key: 1,
112
+ type: "x",
113
+ label: e.xLabel,
114
+ "label-margin": 8,
115
+ "num-ticks": e.xNumTicks,
116
+ "tick-format": e.xFormatter,
117
+ "tick-values": e.xExplicitTicks,
118
+ "grid-line": e.xGridLine,
119
+ "domain-line": e.xDomainLine,
120
+ "tick-line": e.xTickLine,
121
+ "min-max-ticks-only": e.minMaxTicksOnly
122
+ }, null, 8, ["label", "num-ticks", "tick-format", "tick-values", "grid-line", "domain-line", "tick-line", "min-max-ticks-only"])),
123
+ e.hideYAxis ? p("", !0) : (a(), m(i(B), {
124
+ key: 2,
125
+ type: "y",
126
+ label: e.yLabel,
127
+ "num-ticks": e.yNumTicks,
128
+ "tick-format": e.yFormatter,
129
+ "grid-line": e.yGridLine,
130
+ "domain-line": e.yDomainLine,
131
+ "tick-line": e.yTickLine
132
+ }, null, 8, ["label", "num-ticks", "tick-format", "grid-line", "domain-line", "tick-line"])),
133
+ e.hideTooltip ? p("", !0) : (a(), m(i(Q), C({ key: 3 }, e.crosshairConfig, { template: M }), null, 16))
134
+ ]),
135
+ _: 1
136
+ }, 8, ["data", "height", "padding", "svg-defs"]),
137
+ e.hideLegend ? p("", !0) : (a(), c("div", {
138
+ key: 0,
139
+ class: T(["flex items-center justify-end", { "pb-4": g.value, "pt-4": !g.value }])
140
+ }, [
141
+ u(i(Z), {
142
+ items: Object.values(e.categories)
143
+ }, null, 8, ["items"])
144
+ ], 2)),
145
+ X("div", ee, [
146
+ i(O).tooltip ? A(e.$slots, "tooltip", {
147
+ key: 0,
148
+ values: s.value
149
+ }) : s.value ? A(e.$slots, "fallback", { key: 1 }, () => [
150
+ u(x, {
151
+ data: s.value,
152
+ categories: e.categories,
153
+ toolTipTitle: i(I)(s.value) ?? "",
154
+ yFormatter: r.yFormatter
155
+ }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
156
+ ]) : p("", !0)
157
+ ], 512)
158
+ ], 2));
159
+ }
160
+ });
161
+ export {
162
+ se as default
163
+ };
@@ -0,0 +1,21 @@
1
+ import { AreaChartProps } from './types';
2
+ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
+ readonly onClick?: ((event: MouseEvent, values?: T | undefined) => any) | undefined;
5
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & AreaChartProps<T> & Partial<{}>> & import('vue').PublicProps;
6
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
+ attrs: any;
8
+ slots: {
9
+ tooltip?(_: {
10
+ values: T | undefined;
11
+ }): any;
12
+ fallback?(_: {}): any;
13
+ };
14
+ emit: (e: "click", event: MouseEvent, values?: T) => void;
15
+ }>) => import('vue').VNode & {
16
+ __ctx?: Awaited<typeof __VLS_setup>;
17
+ };
18
+ export default _default;
19
+ type __VLS_PrettifyLocal<T> = {
20
+ [K in keyof T]: T[K];
21
+ } & {};
@@ -0,0 +1,4 @@
1
+ import f from "./AreaChart.js";
2
+ export {
3
+ f as default
4
+ };
@@ -1,4 +1,4 @@
1
- import { axisFormatter, LegendPosition, MarkerConfig } from '../../types';
1
+ import { axisFormatter, CrosshairConfig, LegendPosition, MarkerConfig } from '../../types';
2
2
  import { BulletLegendItemInterface, CurveType } from '@unovis/ts';
3
3
  export interface AreaChartProps<T> {
4
4
  /**
@@ -64,7 +64,7 @@ export interface AreaChartProps<T> {
64
64
  /**
65
65
  * Line dash array, see SVG's stroke-dasharray. Default: `undefined`
66
66
  */
67
- lineDashArray?: number[];
67
+ lineDashArray?: number[][];
68
68
  /**
69
69
  * The desired number of ticks on the x-axis.
70
70
  */
@@ -129,19 +129,5 @@ export interface AreaChartProps<T> {
129
129
  /**
130
130
  * Crosshair configuration object for customizing the appearance of the crosshair line.
131
131
  */
132
- crosshairConfig?: {
133
- /**
134
- * The color of the crosshair line. Accepts any valid CSS color string.
135
- * Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
136
- */
137
- color?: string;
138
- /**
139
- * The stroke color of the crosshair line. Accepts any valid CSS color string.
140
- */
141
- strokeColor?: string;
142
- /**
143
- * The stroke width of the crosshair line in pixels.
144
- */
145
- strokeWidth?: number;
146
- };
132
+ crosshairConfig?: CrosshairConfig;
147
133
  }
@@ -0,0 +1,77 @@
1
+ import { defineComponent as y, computed as f, createApp as h, createElementBlock as g, openBlock as a, createVNode as n, createElementVNode as B, unref as t, withCtx as L, createBlock as v, createCommentVNode as C, mergeProps as k } from "vue";
2
+ import { VisXYContainer as b, VisArea as x, VisAxis as s, VisCrosshair as T, VisBulletLegend as V } from "@unovis/vue";
3
+ import { CurveType as _ } from "@unovis/ts";
4
+ import N from "../Tooltip.js";
5
+ const A = { class: "flex flex-col space-y-4" }, j = { class: "flex items center justify-end" }, O = /* @__PURE__ */ y({
6
+ __name: "AreaStackedChart",
7
+ props: {
8
+ data: {},
9
+ height: {},
10
+ categories: {},
11
+ hideTooltip: { type: Boolean },
12
+ xLabel: {},
13
+ yLabel: {},
14
+ padding: {},
15
+ hideLegend: { type: Boolean },
16
+ xGridLine: { type: Boolean },
17
+ xDomainLine: { type: Boolean },
18
+ yGridLine: { type: Boolean },
19
+ yDomainLine: { type: Boolean },
20
+ xTickLine: { type: Boolean },
21
+ yTickLine: { type: Boolean },
22
+ crosshairConfig: {}
23
+ },
24
+ setup(c) {
25
+ const i = c, l = f(() => (e, m) => {
26
+ if (typeof window > "u" || typeof document > "u")
27
+ return "";
28
+ try {
29
+ const o = h(N, {
30
+ data: e,
31
+ categories: i.categories
32
+ }), r = document.createElement("div");
33
+ o.mount(r);
34
+ const u = r.innerHTML;
35
+ return o.unmount(), u;
36
+ } catch {
37
+ return "";
38
+ }
39
+ }), p = (e) => Number.parseInt(e.time), d = [(e) => e.firstTime, (e) => e.returning];
40
+ return (e, m) => (a(), g("div", A, [
41
+ n(t(b), {
42
+ data: e.data,
43
+ padding: e.padding,
44
+ height: e.height
45
+ }, {
46
+ default: L(() => [
47
+ n(t(x), {
48
+ x: p,
49
+ y: d,
50
+ color: Object.values(i.categories).map((o) => o.color),
51
+ "curve-type": t(_).Linear
52
+ }, null, 8, ["color", "curve-type"]),
53
+ n(t(s), {
54
+ type: "x",
55
+ label: "Time",
56
+ "num-ticks": 12
57
+ }),
58
+ n(t(s), {
59
+ type: "y",
60
+ label: "Number of visitors",
61
+ "num-ticks": 3
62
+ }),
63
+ e.hideTooltip ? C("", !0) : (a(), v(t(T), k({ key: 0 }, e.crosshairConfig, { template: l.value }), null, 16, ["template"]))
64
+ ]),
65
+ _: 1
66
+ }, 8, ["data", "padding", "height"]),
67
+ B("div", j, [
68
+ n(t(V), {
69
+ items: Object.values(e.categories)
70
+ }, null, 8, ["items"])
71
+ ])
72
+ ]));
73
+ }
74
+ });
75
+ export {
76
+ O as default
77
+ };
@@ -0,0 +1,14 @@
1
+ import { AreaStackedChartProps } from './types';
2
+ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & AreaStackedChartProps<T> & Partial<{}>> & import('vue').PublicProps;
4
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
5
+ attrs: any;
6
+ slots: {};
7
+ emit: {};
8
+ }>) => import('vue').VNode & {
9
+ __ctx?: Awaited<typeof __VLS_setup>;
10
+ };
11
+ export default _default;
12
+ type __VLS_PrettifyLocal<T> = {
13
+ [K in keyof T]: T[K];
14
+ } & {};
@@ -0,0 +1,4 @@
1
+ import f from "./AreaStackedChart.js";
2
+ export {
3
+ f as default
4
+ };
@@ -1,5 +1,4 @@
1
- import { BulletLegendItemInterface, Orientation } from '@unovis/ts';
2
- import { LegendPosition, axisFormatter } from '../../types';
1
+ import { BulletLegendItemInterface, Orientation, LegendPosition, axisFormatter } from '../../types';
3
2
  type BarChartPropsBase<T> = {
4
3
  /**
5
4
  * The data to be displayed in the bar chart.
@@ -0,0 +1,85 @@
1
+ import { defineComponent as V, useSlots as b, useTemplateRef as w, ref as D, createElementBlock as u, openBlock as c, Fragment as S, createElementVNode as o, createCommentVNode as p, createVNode as n, renderSlot as s, unref as l, withCtx as T, normalizeStyle as W, toDisplayString as B } from "vue";
2
+ import { Donut as L } from "@unovis/ts";
3
+ import { DonutType as $ } from "./types.js";
4
+ import { VisSingleContainer as H, VisTooltip as N, VisDonut as j, VisBulletLegend as z } from "@unovis/vue";
5
+ const A = {
6
+ ref: "slotWrapper",
7
+ class: "hidden"
8
+ }, E = { class: "flex items-center px-[15px] py-[10px]" }, R = {
9
+ key: 0,
10
+ class: "flex items-center justify-center mt-4"
11
+ }, U = /* @__PURE__ */ V({
12
+ __name: "DonutChart",
13
+ props: {
14
+ type: {},
15
+ data: {},
16
+ arcWidth: {},
17
+ height: {},
18
+ radius: {},
19
+ hideLegend: { type: Boolean },
20
+ labels: {},
21
+ padAngle: {}
22
+ },
23
+ emits: ["click"],
24
+ setup(f, { emit: m }) {
25
+ const g = m, r = f, h = b(), i = w("slotWrapper"), t = D(), v = (e) => e, y = r.type === $.Half;
26
+ function k(e) {
27
+ return t.value = e, C();
28
+ }
29
+ function C(e) {
30
+ return typeof window > "u" ? "" : i.value ? i.value.innerHTML : "";
31
+ }
32
+ return (e, d) => (c(), u(S, null, [
33
+ o("div", {
34
+ class: "flex items-center justify-center",
35
+ onClick: d[0] || (d[0] = (a) => g("click", a, t.value))
36
+ }, [
37
+ n(l(H), {
38
+ data: e.data,
39
+ height: e.height,
40
+ margin: {}
41
+ }, {
42
+ default: T(() => [
43
+ n(l(N), {
44
+ "horizontal-shift": 20,
45
+ "vertical-shift": 20,
46
+ triggers: {
47
+ [l(L).selectors.segment]: k
48
+ }
49
+ }, null, 8, ["triggers"]),
50
+ n(l(j), {
51
+ value: v,
52
+ "corner-radius": e.radius,
53
+ "arc-width": e.arcWidth ?? 20,
54
+ color: r.labels.map((a) => a.color),
55
+ "angle-range": y ? [-1.5707963267948966, 1.5707963267948966] : [],
56
+ "pad-angle": r.padAngle || 0
57
+ }, null, 8, ["corner-radius", "arc-width", "color", "angle-range", "pad-angle"])
58
+ ]),
59
+ _: 1
60
+ }, 8, ["data", "height"]),
61
+ s(e.$slots, "default"),
62
+ o("div", A, [
63
+ l(h).tooltip ? s(e.$slots, "tooltip", {
64
+ key: 0,
65
+ values: t.value
66
+ }) : t.value ? s(e.$slots, "fallback", { key: 1 }, () => [
67
+ o("div", E, [
68
+ o("div", {
69
+ class: "w-2 h-2 rounded-full mr-2",
70
+ style: W(`background-color: ${r.labels[t.value.index].color} ;`)
71
+ }, null, 4),
72
+ o("div", null, B(t.value.data), 1)
73
+ ])
74
+ ]) : p("", !0)
75
+ ], 512)
76
+ ]),
77
+ e.hideLegend ? p("", !0) : (c(), u("div", R, [
78
+ n(l(z), { items: e.labels }, null, 8, ["items"])
79
+ ]))
80
+ ], 64));
81
+ }
82
+ });
83
+ export {
84
+ U as default
85
+ };
@@ -0,0 +1,22 @@
1
+ import { DonutChartProps } from './types';
2
+ declare const _default: <T extends {}>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
+ readonly onClick?: ((event: MouseEvent, values?: any) => any) | undefined;
5
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & DonutChartProps & Partial<{}>> & import('vue').PublicProps;
6
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
+ attrs: any;
8
+ slots: {
9
+ default?(_: {}): any;
10
+ tooltip?(_: {
11
+ values: any;
12
+ }): any;
13
+ fallback?(_: {}): any;
14
+ };
15
+ emit: (e: "click", event: MouseEvent, values?: any) => void;
16
+ }>) => import('vue').VNode & {
17
+ __ctx?: Awaited<typeof __VLS_setup>;
18
+ };
19
+ export default _default;
20
+ type __VLS_PrettifyLocal<T> = {
21
+ [K in keyof T]: T[K];
22
+ } & {};
@@ -0,0 +1,4 @@
1
+ import f from "./DonutChart.js";
2
+ export {
3
+ f as default
4
+ };
@@ -10,8 +10,12 @@ export type DonutChartProps = {
10
10
  */
11
11
  data: number[];
12
12
  /**
13
- * The height of the chart in pixels.
13
+ * The arc width of the chart in pixels.
14
14
  */
15
+ arcWidth?: number;
16
+ /**
17
+ * The height of the chart in pixels.
18
+ */
15
19
  height: number;
16
20
  /**
17
21
  * The radius of the donut in pixels.
@@ -0,0 +1,4 @@
1
+ var r = /* @__PURE__ */ ((l) => (l.Half = "half", l.Full = "full", l))(r || {});
2
+ export {
3
+ r as DonutType
4
+ };
@@ -0,0 +1,143 @@
1
+ import { defineComponent as P, computed as k, useSlots as O, useTemplateRef as j, ref as w, createElementBlock as c, openBlock as n, normalizeClass as g, createVNode as s, createCommentVNode as l, createElementVNode as x, unref as i, withCtx as M, createBlock as d, Fragment as W, renderList as E, mergeProps as G, renderSlot as h } from "vue";
2
+ import { Position as v, CurveType as X } from "@unovis/ts";
3
+ import { createMarkers as $, getFirstPropertyValue as z } from "../../utils.js";
4
+ import R from "../Tooltip.js";
5
+ import { VisXYContainer as Y, VisTooltip as S, VisLine as H, VisAxis as T, VisCrosshair as U, VisBulletLegend as q } from "@unovis/vue";
6
+ import { LegendPosition as I } from "../../types.js";
7
+ const J = {
8
+ ref: "slotWrapper",
9
+ class: "hidden"
10
+ }, te = /* @__PURE__ */ P({
11
+ __name: "LineChart",
12
+ props: {
13
+ data: {},
14
+ height: {},
15
+ xLabel: {},
16
+ yLabel: {},
17
+ padding: { default: () => ({
18
+ top: 5,
19
+ right: 5,
20
+ bottom: 5,
21
+ left: 5
22
+ }) },
23
+ categories: {},
24
+ markerConfig: {},
25
+ xFormatter: {},
26
+ yFormatter: {},
27
+ curveType: {},
28
+ lineWidth: { default: 2 },
29
+ lineDashArray: {},
30
+ xNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
31
+ xExplicitTicks: {},
32
+ minMaxTicksOnly: { type: Boolean },
33
+ yNumTicks: { default: (o) => o.data.length > 24 ? 24 / 4 : o.data.length - 1 },
34
+ hideTooltip: { type: Boolean },
35
+ hideLegend: { type: Boolean },
36
+ legendPosition: {},
37
+ xGridLine: { type: Boolean },
38
+ xDomainLine: { type: Boolean },
39
+ yGridLine: { type: Boolean },
40
+ yDomainLine: { type: Boolean },
41
+ xTickLine: { type: Boolean },
42
+ yTickLine: { type: Boolean },
43
+ hideXAxis: { type: Boolean },
44
+ hideYAxis: { type: Boolean },
45
+ crosshairConfig: { default: () => ({
46
+ color: "#666"
47
+ }) }
48
+ },
49
+ emits: ["click"],
50
+ setup(o, { emit: L }) {
51
+ const C = L, t = o, b = k(() => t.markerConfig ? $(t.markerConfig) : ""), B = O(), p = j("slotWrapper"), a = w();
52
+ function D(e) {
53
+ return typeof window > "u" ? "" : p.value ? p.value.innerHTML : "";
54
+ }
55
+ function V(e) {
56
+ return a.value = e, D();
57
+ }
58
+ const y = k(
59
+ () => t.legendPosition === I.Top
60
+ ), A = Object.values(t.categories).map(
61
+ (e, r) => `var(--vis-color${r})`
62
+ ), F = (e) => Object.values(t.categories)[e].color ?? A[e];
63
+ return (e, r) => (n(), c("div", {
64
+ class: g(["flex flex-col space-y-4", {
65
+ "flex-col-reverse": y.value,
66
+ markers: !!t.markerConfig
67
+ }]),
68
+ onClick: r[0] || (r[0] = (m) => C("click", m, a.value))
69
+ }, [
70
+ s(i(Y), {
71
+ data: e.data,
72
+ padding: e.padding,
73
+ height: e.height,
74
+ svgDefs: b.value
75
+ }, {
76
+ default: M(() => [
77
+ s(i(S), {
78
+ "horizontal-placement": i(v).Right,
79
+ "vertical-placement": i(v).Top
80
+ }, null, 8, ["horizontal-placement", "vertical-placement"]),
81
+ (n(!0), c(W, null, E(Object.keys(t.categories), (m, u) => (n(), d(i(H), {
82
+ key: u,
83
+ x: (f, N) => N,
84
+ y: (f) => f[m],
85
+ color: F(u),
86
+ "curve-type": e.curveType ?? i(X).MonotoneX,
87
+ "line-width": e.lineWidth,
88
+ lineDashArray: e.lineDashArray ? e.lineDashArray[u] : void 0
89
+ }, null, 8, ["x", "y", "color", "curve-type", "line-width", "lineDashArray"]))), 128)),
90
+ e.hideXAxis ? l("", !0) : (n(), d(i(T), {
91
+ key: 0,
92
+ type: "x",
93
+ "tick-format": e.xFormatter,
94
+ label: e.xLabel,
95
+ "label-margin": 8,
96
+ "domain-line": e.xDomainLine,
97
+ "grid-line": e.xGridLine,
98
+ "tick-line": e.xTickLine,
99
+ "num-ticks": e.xNumTicks,
100
+ "tick-values": e.xExplicitTicks,
101
+ "min-max-ticks-only": e.minMaxTicksOnly
102
+ }, null, 8, ["tick-format", "label", "domain-line", "grid-line", "tick-line", "num-ticks", "tick-values", "min-max-ticks-only"])),
103
+ e.hideYAxis ? l("", !0) : (n(), d(i(T), {
104
+ key: 1,
105
+ type: "y",
106
+ "tick-format": e.yFormatter,
107
+ label: e.yLabel,
108
+ "num-ticks": e.yNumTicks,
109
+ "domain-line": e.yDomainLine,
110
+ "grid-line": e.yGridLine,
111
+ "tick-line": e.yTickLine
112
+ }, null, 8, ["tick-format", "label", "num-ticks", "domain-line", "grid-line", "tick-line"])),
113
+ e.hideTooltip ? l("", !0) : (n(), d(i(U), G({ key: 2 }, e.crosshairConfig, { template: V }), null, 16))
114
+ ]),
115
+ _: 1
116
+ }, 8, ["data", "padding", "height", "svgDefs"]),
117
+ e.hideLegend ? l("", !0) : (n(), c("div", {
118
+ key: 0,
119
+ class: g(["flex items center justify-end", { "pb-4": y.value }])
120
+ }, [
121
+ s(i(q), {
122
+ items: Object.values(e.categories)
123
+ }, null, 8, ["items"])
124
+ ], 2)),
125
+ x("div", J, [
126
+ i(B).tooltip ? h(e.$slots, "tooltip", {
127
+ key: 0,
128
+ values: a.value
129
+ }) : a.value ? h(e.$slots, "fallback", { key: 1 }, () => [
130
+ s(R, {
131
+ data: a.value,
132
+ categories: e.categories,
133
+ toolTipTitle: i(z)(a.value) ?? "",
134
+ yFormatter: t.yFormatter
135
+ }, null, 8, ["data", "categories", "toolTipTitle", "yFormatter"])
136
+ ]) : l("", !0)
137
+ ], 512)
138
+ ], 2));
139
+ }
140
+ });
141
+ export {
142
+ te as default
143
+ };
@@ -0,0 +1,21 @@
1
+ import { LineChartProps } from './types';
2
+ declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
3
+ props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{
4
+ readonly onClick?: ((event: MouseEvent, values?: T | undefined) => any) | undefined;
5
+ } & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, "onClick"> & LineChartProps<T> & Partial<{}>> & import('vue').PublicProps;
6
+ expose(exposed: import('vue').ShallowUnwrapRef<{}>): void;
7
+ attrs: any;
8
+ slots: {
9
+ tooltip?(_: {
10
+ values: T | undefined;
11
+ }): any;
12
+ fallback?(_: {}): any;
13
+ };
14
+ emit: (e: "click", event: MouseEvent, values?: T) => void;
15
+ }>) => import('vue').VNode & {
16
+ __ctx?: Awaited<typeof __VLS_setup>;
17
+ };
18
+ export default _default;
19
+ type __VLS_PrettifyLocal<T> = {
20
+ [K in keyof T]: T[K];
21
+ } & {};
@@ -0,0 +1,4 @@
1
+ import f from "./LineChart.js";
2
+ export {
3
+ f as default
4
+ };
@@ -1,5 +1,4 @@
1
- import { BulletLegendItemInterface, CurveType } from '@unovis/ts';
2
- import { axisFormatter, LegendPosition, MarkerConfig } from '../../types';
1
+ import { axisFormatter, BulletLegendItemInterface, CrosshairConfig, CurveType, LegendPosition, MarkerConfig } from '../../types';
3
2
  export interface LineChartProps<T> {
4
3
  /**
5
4
  * The data to be displayed in the line chart.
@@ -64,7 +63,7 @@ export interface LineChartProps<T> {
64
63
  /**
65
64
  * Line dash array, see SVG's stroke-dasharray. Default: `undefined`
66
65
  */
67
- lineDashArray?: number[];
66
+ lineDashArray?: number[][];
68
67
  /**
69
68
  * The desired number of ticks on the x-axis.
70
69
  */
@@ -129,19 +128,5 @@ export interface LineChartProps<T> {
129
128
  /**
130
129
  * Crosshair configuration object for customizing the appearance of the crosshair line.
131
130
  */
132
- crosshairConfig?: {
133
- /**
134
- * The color of the crosshair line. Accepts any valid CSS color string.
135
- * Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
136
- */
137
- color?: string;
138
- /**
139
- * The stroke color of the crosshair line. Accepts any valid CSS color string.
140
- */
141
- strokeColor?: string;
142
- /**
143
- * The stroke width of the crosshair line in pixels.
144
- */
145
- strokeWidth?: number;
146
- };
131
+ crosshairConfig?: CrosshairConfig;
147
132
  }
@@ -1,5 +1,5 @@
1
- import { defineComponent as b, computed as v, createElementBlock as r, openBlock as l, createElementVNode as o, toDisplayString as i, Fragment as y, renderList as h, normalizeStyle as n } from "vue";
2
- const f = {
1
+ import { defineComponent as b, computed as v, createElementBlock as r, openBlock as i, createElementVNode as o, toDisplayString as l, Fragment as y, renderList as h, normalizeStyle as a } from "vue";
2
+ const f = { class: "px-[15px] py-[10px]" }, _ = {
3
3
  class: "capitalize border-b mb-1 pb-1",
4
4
  style: {
5
5
  color: "var(--tooltip-value-color)",
@@ -14,29 +14,29 @@ const f = {
14
14
  yFormatter: { type: Function }
15
15
  },
16
16
  setup(p) {
17
- const a = p, d = ["_index", "_stacked", "_ending"], m = v(() => Object.entries(a.data ?? []).filter(
18
- ([e, g]) => !d.includes(e) && Object.keys(a.categories).includes(e)
17
+ const n = p, d = ["_index", "_stacked", "_ending"], m = v(() => Object.entries(n.data ?? []).filter(
18
+ ([e, g]) => !d.includes(e) && Object.keys(n.categories).includes(e)
19
19
  ));
20
- return (e, g) => (l(), r("div", null, [
21
- o("div", f, i(e.toolTipTitle), 1),
22
- (l(!0), r(y, null, h(m.value, ([t, s], u) => {
20
+ return (e, g) => (i(), r("div", f, [
21
+ o("div", _, l(e.toolTipTitle), 1),
22
+ (i(!0), r(y, null, h(m.value, ([t, s], u) => {
23
23
  var c;
24
- return l(), r("div", {
24
+ return i(), r("div", {
25
25
  key: t,
26
26
  style: { display: "flex", "align-items": "center", "margin-bottom": "4px" }
27
27
  }, [
28
28
  o("span", {
29
- style: n([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
29
+ style: a([{ width: "8px", height: "8px", "border-radius": "4px", "margin-right": "8px" }, {
30
30
  backgroundColor: (c = e.categories[t]) != null && c.color ? e.categories[t].color : `var(--vis-color${u})`
31
31
  }])
32
32
  }, null, 4),
33
33
  o("div", null, [
34
34
  o("span", {
35
- style: n([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
36
- }, i(e.categories[t].name) + ":", 1),
35
+ style: a([{ "font-weight": "600", "margin-right": "8px" }, { color: "var(--tooltip-label-color)" }])
36
+ }, l(e.categories[t].name) + ":", 1),
37
37
  o("span", {
38
- style: n([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
- }, i(e.yFormatter ? e.yFormatter(s) : s), 1)
38
+ style: a([{ "font-weight": "400" }, { color: "var(--tooltip-value-color)" }])
39
+ }, l(e.yFormatter ? e.yFormatter(s) : s), 1)
40
40
  ])
41
41
  ]);
42
42
  }), 128))
@@ -1,5 +1,4 @@
1
- import { axisFormatter } from '../types';
2
- import { BulletLegendItemInterface } from '@unovis/ts';
1
+ import { axisFormatter, BulletLegendItemInterface } from '../types';
3
2
  declare const _default: <T>(__VLS_props: NonNullable<Awaited<typeof __VLS_setup>>["props"], __VLS_ctx?: __VLS_PrettifyLocal<Pick<NonNullable<Awaited<typeof __VLS_setup>>, "attrs" | "emit" | "slots">>, __VLS_expose?: NonNullable<Awaited<typeof __VLS_setup>>["expose"], __VLS_setup?: Promise<{
4
3
  props: __VLS_PrettifyLocal<Pick<Partial<{}> & Omit<{} & import('vue').VNodeProps & import('vue').AllowedComponentProps & import('vue').ComponentCustomProps, never>, never> & {
5
4
  data: T;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,8 @@
1
- export { default as BarChart } from './components/BarChart/BarChart.vue';
2
- export { LegendPosition } from './types';
1
+ import { default as AreaChart } from './components/AreaChart/AreaChart.vue';
2
+ import { default as AreaStackedChart } from './components/AreaStackedChart/AreaStackedChart.vue';
3
+ import { default as LineChart } from './components/LineChart/LineChart.vue';
4
+ import { default as BarChart } from './components/BarChart/BarChart.vue';
5
+ import { default as DonutChart } from './components/DonutChart/DonutChart.vue';
6
+ import { LegendPosition, CurveType, Orientation, BulletLegendItemInterface, MarkerConfig, CrosshairConfig } from './types';
7
+ export { AreaChart, AreaStackedChart, LineChart, BarChart, DonutChart, Orientation, CurveType, LegendPosition };
8
+ export type { BulletLegendItemInterface, MarkerConfig, CrosshairConfig };
package/dist/index.js CHANGED
@@ -1,6 +1,16 @@
1
- import { default as e } from "./components/BarChart/BarChart.js";
2
- import { LegendPosition as a } from "./types.js";
1
+ import { default as a } from "./components/AreaChart/AreaChart.js";
2
+ import { default as o } from "./components/AreaStackedChart/AreaStackedChart.js";
3
+ import { default as d } from "./components/LineChart/LineChart.js";
4
+ import { default as u } from "./components/BarChart/BarChart.js";
5
+ import { default as n } from "./components/DonutChart/DonutChart.js";
6
+ import { CurveType as x, LegendPosition as C, Orientation as h } from "./types.js";
3
7
  export {
4
- e as BarChart,
5
- a as LegendPosition
8
+ a as AreaChart,
9
+ o as AreaStackedChart,
10
+ u as BarChart,
11
+ x as CurveType,
12
+ n as DonutChart,
13
+ C as LegendPosition,
14
+ d as LineChart,
15
+ h as Orientation
6
16
  };
package/dist/types.d.ts CHANGED
@@ -1,7 +1,45 @@
1
- export declare enum LegendPosition {
1
+ import { AreaChartProps } from './components/AreaChart/types';
2
+ import { BarChartProps } from './components/BarChart/types';
3
+ import { LineChartProps } from './components/LineChart/types';
4
+ import { DonutChartProps } from './components/DonutChart/types';
5
+ declare enum LegendPosition {
2
6
  Top = "top",
3
7
  Bottom = "bottom"
4
8
  }
9
+ declare enum CurveType {
10
+ Basis = "basis",
11
+ BasisClosed = "basisClosed",
12
+ BasisOpen = "basisOpen",
13
+ Bundle = "bundle",
14
+ Cardinal = "cardinal",
15
+ CardinalClosed = "cardinalClosed",
16
+ CardinalOpen = "cardinalOpen",
17
+ CatmullRom = "catmullRom",
18
+ CatmullRomClosed = "catmullRomClosed",
19
+ CatmullRomOpen = "catmullRomOpen",
20
+ Linear = "linear",
21
+ LinearClosed = "linearClosed",
22
+ MonotoneX = "monotoneX",
23
+ MonotoneY = "monotoneY",
24
+ Natural = "natural",
25
+ Step = "step",
26
+ StepAfter = "stepAfter",
27
+ StepBefore = "stepBefore"
28
+ }
29
+ interface BulletLegendItemInterface {
30
+ name: string | number;
31
+ color?: string;
32
+ className?: string;
33
+ shape?: any;
34
+ inactive?: boolean;
35
+ hidden?: boolean;
36
+ pointer?: boolean;
37
+ }
38
+ declare enum Orientation {
39
+ Horizontal = "horizontal",
40
+ Vertical = "vertical"
41
+ }
42
+ export { LegendPosition, CurveType, Orientation, type AreaChartProps, type BarChartProps, type LineChartProps, type DonutChartProps, type BulletLegendItemInterface, };
5
43
  export type axisFormatter = ((tick: number, i?: number, ticks?: number[]) => string) | ((tick: Date, i?: number, ticks?: Date[]) => string);
6
44
  export interface MarkerConfig {
7
45
  type?: "circle" | "square" | "triangle" | "diamond";
@@ -10,3 +48,18 @@ export interface MarkerConfig {
10
48
  color?: string;
11
49
  strokeColor?: string;
12
50
  }
51
+ export interface CrosshairConfig {
52
+ /**
53
+ * The color of the crosshair line. Accepts any valid CSS color string.
54
+ * Example: '#f00', 'rgba(0,0,0,0.5)', 'blue'
55
+ */
56
+ color?: string;
57
+ /**
58
+ * The stroke color of the crosshair line. Accepts any valid CSS color string.
59
+ */
60
+ strokeColor?: string;
61
+ /**
62
+ * The stroke width of the crosshair line in pixels.
63
+ */
64
+ strokeWidth?: number;
65
+ }
package/dist/types.js CHANGED
@@ -1,4 +1,6 @@
1
- var o = /* @__PURE__ */ ((t) => (t.Top = "top", t.Bottom = "bottom", t))(o || {});
1
+ var l = /* @__PURE__ */ ((a) => (a.Top = "top", a.Bottom = "bottom", a))(l || {}), o = /* @__PURE__ */ ((a) => (a.Basis = "basis", a.BasisClosed = "basisClosed", a.BasisOpen = "basisOpen", a.Bundle = "bundle", a.Cardinal = "cardinal", a.CardinalClosed = "cardinalClosed", a.CardinalOpen = "cardinalOpen", a.CatmullRom = "catmullRom", a.CatmullRomClosed = "catmullRomClosed", a.CatmullRomOpen = "catmullRomOpen", a.Linear = "linear", a.LinearClosed = "linearClosed", a.MonotoneX = "monotoneX", a.MonotoneY = "monotoneY", a.Natural = "natural", a.Step = "step", a.StepAfter = "stepAfter", a.StepBefore = "stepBefore", a))(o || {}), t = /* @__PURE__ */ ((a) => (a.Horizontal = "horizontal", a.Vertical = "vertical", a))(t || {});
2
2
  export {
3
- o as LegendPosition
3
+ o as CurveType,
4
+ l as LegendPosition,
5
+ t as Orientation
4
6
  };
package/dist/utils.js CHANGED
@@ -1,24 +1,49 @@
1
- function u(t) {
2
- if (t && Object.keys(t).length > 0) {
3
- const c = Object.keys(t)[0];
4
- return t[c];
1
+ function o(n) {
2
+ if (n && Object.keys(n).length > 0) {
3
+ const e = Object.keys(n)[0];
4
+ return n[e];
5
5
  }
6
6
  }
7
- function o(t) {
8
- return t.charAt(0).toUpperCase() + t.slice(1);
7
+ const u = (n, e, r, t, $) => {
8
+ switch (n) {
9
+ case "circle":
10
+ return `<circle cx="${e / 2}" cy="${e / 2}" r="${(e - r) / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
11
+ case "square":
12
+ return `<rect x="${r / 2}" y="${r / 2}" width="${e - r}" height="${e - r}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
13
+ case "triangle":
14
+ return `<polygon points="${e / 2},${r / 2} ${e - r / 2},${e - r / 2} ${r / 2},${e - r / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
15
+ case "diamond":
16
+ return `<polygon points="${e / 2},${r / 2} ${e - r / 2},${e / 2} ${e / 2},${e - r / 2} ${r / 2},${e / 2}" stroke-width="${r}" stroke="${$}" fill="${t}" />`;
17
+ default:
18
+ return "";
19
+ }
20
+ };
21
+ function m(n) {
22
+ return Object.entries(n).map(([e, r]) => {
23
+ const t = r.type || "circle", $ = r.size || 10, c = r.strokeWidth || 2, a = r.color || "#000", l = r.strokeColor || r.color || "#000";
24
+ return `<marker id="circle-marker-${e}" viewBox="0 0 ${$} ${$}" refX="${$ / 2}" refY="${$ / 2}" markerWidth="${$ / 2}" markerHeight="${$ / 2}">
25
+ ${u(t, $, c, a, l)}
26
+ </marker>`;
27
+ }).join(`
28
+ `);
29
+ }
30
+ function p(n) {
31
+ return n.charAt(0).toUpperCase() + n.slice(1);
9
32
  }
10
- const a = (t, c) => {
11
- const s = Object.keys(t[0]).filter((e) => e !== c), i = Object.keys(t[0][s[0]]);
12
- return t.map((e) => ({
13
- month: e.month,
14
- ...s.flatMap(
15
- (r) => i.map((n) => ({
16
- [`${r}${o(n)}`]: e[r][n]
33
+ const y = (n, e) => {
34
+ const r = Object.keys(n[0]).filter(($) => $ !== e), t = Object.keys(n[0][r[0]]);
35
+ return n.map(($) => ({
36
+ month: $.month,
37
+ ...r.flatMap(
38
+ (c) => t.map((a) => ({
39
+ [`${c}${p(a)}`]: $[c][a]
17
40
  }))
18
- ).reduce((r, n) => ({ ...r, ...n }), {})
41
+ ).reduce((c, a) => ({ ...c, ...a }), {})
19
42
  }));
20
43
  };
21
44
  export {
22
- a as flattenData,
23
- u as getFirstPropertyValue
45
+ m as createMarkers,
46
+ y as flattenData,
47
+ o as getFirstPropertyValue,
48
+ u as markerShape
24
49
  };
package/package.json CHANGED
@@ -1,16 +1,17 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.2.0-test.9",
3
+ "version": "0.2.1",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
- "main": "./dist/index.js",
8
+ "main": "./dist/index.umd.cjs",
9
9
  "module": "./dist/index.js",
10
10
  "types": "./dist/index.d.ts",
11
11
  "exports": {
12
12
  ".": {
13
- "import": "./dist/index.js"
13
+ "import": "./dist/index.js",
14
+ "require": "./dist/index.umd.cjs"
14
15
  }
15
16
  },
16
17
  "scripts": {
@@ -20,26 +21,24 @@
20
21
  "release": "commit-and-tag-version"
21
22
  },
22
23
  "peerDependencies": {
23
- "@unovis/ts": "^1.5.2",
24
- "@unovis/vue": "^1.5.2",
25
24
  "vue": "^3.5.13"
26
25
  },
27
26
  "devDependencies": {
28
- "@tailwindcss/vite": "^4.1.11",
29
- "@tanstack/vue-table": "^8.21.3",
30
- "@types/node": "^22.16.5",
27
+ "@tailwindcss/vite": "^4.0.15",
28
+ "@tanstack/vue-table": "^8.21.2",
29
+ "@types/node": "^22.13.11",
31
30
  "@unovis/ts": "^1.5.2",
32
31
  "@unovis/vue": "^1.5.2",
33
- "@vitejs/plugin-vue": "^5.2.4",
32
+ "@vitejs/plugin-vue": "^5.2.1",
34
33
  "@vue/tsconfig": "^0.7.0",
35
- "@vueuse/core": "^13.5.0",
34
+ "@vueuse/core": "^13.0.0",
36
35
  "commit-and-tag-version": "^12.5.1",
37
- "tailwindcss": "^4.1.11",
38
- "typescript": "~5.7.3",
39
- "vite": "^6.3.5",
40
- "vite-plugin-dts": "^4.5.4",
41
- "vue-router": "^4.5.1",
42
- "vue-tsc": "^2.2.12"
36
+ "tailwindcss": "^4.0.15",
37
+ "typescript": "~5.7.2",
38
+ "vite": "^6.2.0",
39
+ "vite-plugin-dts": "^4.5.3",
40
+ "vue-router": "^4.5.0",
41
+ "vue-tsc": "^2.2.4"
43
42
  },
44
43
  "packageManager": "pnpm@8.15.4+sha256.cea6d0bdf2de3a0549582da3983c70c92ffc577ff4410cbf190817ddc35137c2"
45
44
  }