vue-chrts 0.0.45 → 0.0.47

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/index.js ADDED
@@ -0,0 +1,318 @@
1
+ import { defineComponent, computed, ref, resolveComponent, mergeProps, unref, withCtx, createBlock, createCommentVNode, renderSlot, openBlock, createVNode, Fragment, renderList, useSSRContext } from "vue";
2
+ import { ssrRenderAttrs, ssrRenderComponent, ssrRenderList, ssrRenderAttr, ssrRenderSlot } from "vue/server-renderer";
3
+ import { CurveType, Area, Line, Axis } from "@unovis/ts";
4
+ import { VisXYContainer, VisArea, VisLine, VisAxis } from "@unovis/vue";
5
+ import { useMounted } from "@vueuse/core";
6
+ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
7
+ __name: "Area",
8
+ __ssrInlineRender: true,
9
+ props: {
10
+ data: {},
11
+ categories: {},
12
+ index: {},
13
+ colors: {},
14
+ margin: { default: () => ({ top: 0, bottom: 0, left: 0, right: 0 }) },
15
+ filterOpacity: { default: 0.2 },
16
+ xFormatter: {},
17
+ yFormatter: {},
18
+ showXAxis: { type: Boolean, default: true },
19
+ showYAxis: { type: Boolean, default: true },
20
+ showTooltip: { type: Boolean, default: true },
21
+ showLegend: { type: Boolean, default: true },
22
+ showGridLine: { type: Boolean, default: true },
23
+ customTooltip: {},
24
+ curveType: { default: CurveType.MonotoneX },
25
+ showGradiant: { type: Boolean, default: true }
26
+ },
27
+ emits: ["legendItemClick"],
28
+ setup(__props, { emit: __emit }) {
29
+ function defaultColors(count = 3) {
30
+ const quotient = Math.floor(count / 2);
31
+ const remainder = count % 2;
32
+ const primaryCount = quotient + remainder;
33
+ const secondaryCount = quotient;
34
+ return [
35
+ ...Array.from(new Array(primaryCount).keys()).map((i) => `hsl(var(--vis-primary-color) / ${1 - 1 / primaryCount * i})`),
36
+ ...Array.from(new Array(secondaryCount).keys()).map((i) => `hsl(var(--vis-secondary-color) / ${1 - 1 / secondaryCount * i})`)
37
+ ];
38
+ }
39
+ const props = __props;
40
+ const emits = __emit;
41
+ const index = computed(() => props.index);
42
+ const colors = computed(() => {
43
+ var _a;
44
+ return ((_a = props.colors) == null ? void 0 : _a.length) ? props.colors : defaultColors(props.categories.length);
45
+ });
46
+ const legendItems = ref(props.categories.map((category, i) => ({
47
+ name: category,
48
+ color: colors.value[i],
49
+ inactive: false
50
+ })));
51
+ const isMounted = useMounted();
52
+ function handleLegendItemClick(d, i) {
53
+ emits("legendItemClick", d, i);
54
+ }
55
+ return (_ctx, _push, _parent, _attrs) => {
56
+ const _component_ChartLegend = resolveComponent("ChartLegend");
57
+ const _component_ChartCrosshair = resolveComponent("ChartCrosshair");
58
+ _push(`<div${ssrRenderAttrs(mergeProps({ class: "w-full h-[400px] flex flex-col items-end" }, _attrs))}>`);
59
+ if (_ctx.showLegend) {
60
+ _push(ssrRenderComponent(_component_ChartLegend, {
61
+ items: legendItems.value,
62
+ "onUpdate:items": ($event) => legendItems.value = $event,
63
+ onLegendItemClick: handleLegendItemClick
64
+ }, null, _parent));
65
+ } else {
66
+ _push(`<!---->`);
67
+ }
68
+ _push(ssrRenderComponent(unref(VisXYContainer), {
69
+ style: { height: unref(isMounted) ? "100%" : "auto" },
70
+ margin: { left: 20, right: 20 },
71
+ data: _ctx.data
72
+ }, {
73
+ default: withCtx((_, _push2, _parent2, _scopeId) => {
74
+ if (_push2) {
75
+ _push2(`<svg width="0" height="0"${_scopeId}><defs${_scopeId}><!--[-->`);
76
+ ssrRenderList(colors.value, (color, i) => {
77
+ _push2(`<linearGradient x1="0" y1="0" x2="0" y2="1"${_scopeId}>`);
78
+ if (_ctx.showGradiant) {
79
+ _push2(`<!--[--><stop offset="5%"${ssrRenderAttr("stop-color", color)} stop-opacity="0.4"${_scopeId}></stop><stop offset="95%"${ssrRenderAttr("stop-color", color)} stop-opacity="0"${_scopeId}></stop><!--]-->`);
80
+ } else {
81
+ _push2(`<stop offset="0%"${ssrRenderAttr("stop-color", color)}${_scopeId}></stop>`);
82
+ }
83
+ _push2(`</linearGradient>`);
84
+ });
85
+ _push2(`<!--]--></defs></svg>`);
86
+ if (_ctx.showTooltip) {
87
+ _push2(ssrRenderComponent(_component_ChartCrosshair, {
88
+ colors: colors.value,
89
+ items: legendItems.value,
90
+ index: index.value,
91
+ "custom-tooltip": _ctx.customTooltip
92
+ }, null, _parent2, _scopeId));
93
+ } else {
94
+ _push2(`<!---->`);
95
+ }
96
+ _push2(`<!--[-->`);
97
+ ssrRenderList(_ctx.categories, (category) => {
98
+ var _a;
99
+ _push2(ssrRenderComponent(unref(VisArea), {
100
+ x: (_2, i) => i,
101
+ y: (d) => d[category],
102
+ color: "auto",
103
+ "curve-type": _ctx.curveType,
104
+ attributes: {
105
+ [unref(Area).selectors.area]: {
106
+ fill: ``
107
+ }
108
+ },
109
+ opacity: ((_a = legendItems.value.find((item) => item.name === category)) == null ? void 0 : _a.inactive) ? _ctx.filterOpacity : 1
110
+ }, null, _parent2, _scopeId));
111
+ });
112
+ _push2(`<!--]--><!--[-->`);
113
+ ssrRenderList(_ctx.categories, (category, i) => {
114
+ var _a;
115
+ _push2(ssrRenderComponent(unref(VisLine), {
116
+ x: (_2, i2) => i2,
117
+ y: (d) => d[category],
118
+ color: colors.value[i],
119
+ "curve-type": _ctx.curveType,
120
+ attributes: {
121
+ [unref(Line).selectors.line]: {
122
+ opacity: ((_a = legendItems.value.find((item) => item.name === category)) == null ? void 0 : _a.inactive) ? _ctx.filterOpacity : 1
123
+ }
124
+ }
125
+ }, null, _parent2, _scopeId));
126
+ });
127
+ _push2(`<!--]-->`);
128
+ if (_ctx.showXAxis) {
129
+ _push2(ssrRenderComponent(unref(VisAxis), {
130
+ type: "x",
131
+ "tick-format": _ctx.xFormatter ?? ((v) => {
132
+ var _a;
133
+ return (_a = _ctx.data[v]) == null ? void 0 : _a[index.value];
134
+ }),
135
+ "grid-line": false,
136
+ "tick-line": false,
137
+ "tick-text-color": "hsl(var(--vis-text-color))"
138
+ }, null, _parent2, _scopeId));
139
+ } else {
140
+ _push2(`<!---->`);
141
+ }
142
+ if (_ctx.showYAxis) {
143
+ _push2(ssrRenderComponent(unref(VisAxis), {
144
+ type: "y",
145
+ "tick-line": false,
146
+ "tick-format": _ctx.yFormatter,
147
+ "domain-line": false,
148
+ "grid-line": _ctx.showGridLine,
149
+ attributes: {
150
+ [unref(Axis).selectors.grid]: {
151
+ class: "text-muted"
152
+ }
153
+ },
154
+ "tick-text-color": "hsl(var(--vis-text-color))"
155
+ }, null, _parent2, _scopeId));
156
+ } else {
157
+ _push2(`<!---->`);
158
+ }
159
+ ssrRenderSlot(_ctx.$slots, "default", {}, null, _push2, _parent2, _scopeId);
160
+ } else {
161
+ return [
162
+ (openBlock(), createBlock("svg", {
163
+ width: "0",
164
+ height: "0"
165
+ }, [
166
+ createVNode("defs", null, [
167
+ (openBlock(true), createBlock(Fragment, null, renderList(colors.value, (color, i) => {
168
+ return openBlock(), createBlock("linearGradient", {
169
+ key: i,
170
+ x1: "0",
171
+ y1: "0",
172
+ x2: "0",
173
+ y2: "1"
174
+ }, [
175
+ _ctx.showGradiant ? (openBlock(), createBlock(Fragment, { key: 0 }, [
176
+ createVNode("stop", {
177
+ offset: "5%",
178
+ "stop-color": color,
179
+ "stop-opacity": "0.4"
180
+ }, null, 8, ["stop-color"]),
181
+ createVNode("stop", {
182
+ offset: "95%",
183
+ "stop-color": color,
184
+ "stop-opacity": "0"
185
+ }, null, 8, ["stop-color"])
186
+ ], 64)) : (openBlock(), createBlock("stop", {
187
+ key: 1,
188
+ offset: "0%",
189
+ "stop-color": color
190
+ }, null, 8, ["stop-color"]))
191
+ ]);
192
+ }), 128))
193
+ ])
194
+ ])),
195
+ _ctx.showTooltip ? (openBlock(), createBlock(_component_ChartCrosshair, {
196
+ key: 0,
197
+ colors: colors.value,
198
+ items: legendItems.value,
199
+ index: index.value,
200
+ "custom-tooltip": _ctx.customTooltip
201
+ }, null, 8, ["colors", "items", "index", "custom-tooltip"])) : createCommentVNode("", true),
202
+ (openBlock(true), createBlock(Fragment, null, renderList(_ctx.categories, (category) => {
203
+ var _a;
204
+ return openBlock(), createBlock(unref(VisArea), {
205
+ key: category,
206
+ x: (_2, i) => i,
207
+ y: (d) => d[category],
208
+ color: "auto",
209
+ "curve-type": _ctx.curveType,
210
+ attributes: {
211
+ [unref(Area).selectors.area]: {
212
+ fill: ``
213
+ }
214
+ },
215
+ opacity: ((_a = legendItems.value.find((item) => item.name === category)) == null ? void 0 : _a.inactive) ? _ctx.filterOpacity : 1
216
+ }, null, 8, ["x", "y", "curve-type", "attributes", "opacity"]);
217
+ }), 128)),
218
+ (openBlock(true), createBlock(Fragment, null, renderList(_ctx.categories, (category, i) => {
219
+ var _a;
220
+ return openBlock(), createBlock(unref(VisLine), {
221
+ key: category,
222
+ x: (_2, i2) => i2,
223
+ y: (d) => d[category],
224
+ color: colors.value[i],
225
+ "curve-type": _ctx.curveType,
226
+ attributes: {
227
+ [unref(Line).selectors.line]: {
228
+ opacity: ((_a = legendItems.value.find((item) => item.name === category)) == null ? void 0 : _a.inactive) ? _ctx.filterOpacity : 1
229
+ }
230
+ }
231
+ }, null, 8, ["x", "y", "color", "curve-type", "attributes"]);
232
+ }), 128)),
233
+ _ctx.showXAxis ? (openBlock(), createBlock(unref(VisAxis), {
234
+ key: 1,
235
+ type: "x",
236
+ "tick-format": _ctx.xFormatter ?? ((v) => {
237
+ var _a;
238
+ return (_a = _ctx.data[v]) == null ? void 0 : _a[index.value];
239
+ }),
240
+ "grid-line": false,
241
+ "tick-line": false,
242
+ "tick-text-color": "hsl(var(--vis-text-color))"
243
+ }, null, 8, ["tick-format"])) : createCommentVNode("", true),
244
+ _ctx.showYAxis ? (openBlock(), createBlock(unref(VisAxis), {
245
+ key: 2,
246
+ type: "y",
247
+ "tick-line": false,
248
+ "tick-format": _ctx.yFormatter,
249
+ "domain-line": false,
250
+ "grid-line": _ctx.showGridLine,
251
+ attributes: {
252
+ [unref(Axis).selectors.grid]: {
253
+ class: "text-muted"
254
+ }
255
+ },
256
+ "tick-text-color": "hsl(var(--vis-text-color))"
257
+ }, null, 8, ["tick-format", "grid-line", "attributes"])) : createCommentVNode("", true),
258
+ renderSlot(_ctx.$slots, "default")
259
+ ];
260
+ }
261
+ }),
262
+ _: 3
263
+ }, _parent));
264
+ _push(`</div>`);
265
+ };
266
+ }
267
+ });
268
+ const _sfc_setup$1 = _sfc_main$1.setup;
269
+ _sfc_main$1.setup = (props, ctx) => {
270
+ const ssrContext = useSSRContext();
271
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/Area/Area.vue");
272
+ return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
273
+ };
274
+ var PaginationPosition = /* @__PURE__ */ ((PaginationPosition2) => {
275
+ PaginationPosition2["Top"] = "top";
276
+ PaginationPosition2["Bottom"] = "bottom";
277
+ return PaginationPosition2;
278
+ })(PaginationPosition || {});
279
+ const _sfc_main = /* @__PURE__ */ defineComponent({
280
+ __name: "Button",
281
+ __ssrInlineRender: true,
282
+ props: {
283
+ variant: {},
284
+ size: {}
285
+ },
286
+ setup(__props) {
287
+ return (_ctx, _push, _parent, _attrs) => {
288
+ _push(`<button${ssrRenderAttrs(mergeProps({
289
+ class: [
290
+ "button",
291
+ `button--${_ctx.variant || "primary"}`,
292
+ `button--${_ctx.size || "medium"}`
293
+ ]
294
+ }, _attrs))} data-v-52b6ec0c>`);
295
+ ssrRenderSlot(_ctx.$slots, "default", {}, null, _push, _parent);
296
+ _push(`</button>`);
297
+ };
298
+ }
299
+ });
300
+ const _export_sfc = (sfc, props) => {
301
+ const target = sfc.__vccOpts || sfc;
302
+ for (const [key, val] of props) {
303
+ target[key] = val;
304
+ }
305
+ return target;
306
+ };
307
+ const _sfc_setup = _sfc_main.setup;
308
+ _sfc_main.setup = (props, ctx) => {
309
+ const ssrContext = useSSRContext();
310
+ (ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/Button/Button.vue");
311
+ return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
312
+ };
313
+ const Button = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-52b6ec0c"]]);
314
+ export {
315
+ _sfc_main$1 as Area,
316
+ Button,
317
+ PaginationPosition
318
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vue-chrts",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "dist"