@mekari/pixel3-chart 0.0.1-dev.0

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,99 @@
1
+ import {
2
+ useChart
3
+ } from "./chunk-5SYLA56O.mjs";
4
+ import {
5
+ chartProps
6
+ } from "./chunk-4Y625OEJ.mjs";
7
+ import {
8
+ __name
9
+ } from "./chunk-QZ7VFGWC.mjs";
10
+
11
+ // src/chart.tsx
12
+ import { createVNode as _createVNode, isVNode as _isVNode } from "vue";
13
+ import { defineComponent } from "vue";
14
+ import { MpText } from "@mekari/pixel3-text";
15
+ import { merge } from "lodash-es";
16
+ function _isSlot(s) {
17
+ return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !_isVNode(s);
18
+ }
19
+ __name(_isSlot, "_isSlot");
20
+ var MpChart = defineComponent({
21
+ name: "MpChart",
22
+ props: chartProps,
23
+ emits: ["show-tooltip", "hide-tooltip", "click-legend"],
24
+ setup(props, {
25
+ slots,
26
+ emit
27
+ }) {
28
+ const {
29
+ rootAttrs,
30
+ chartHeaderAttrs,
31
+ chartWrapperAttrs,
32
+ chartContainerAttrs,
33
+ canvasContainerAttrs,
34
+ canvasAttrs,
35
+ chartLegendAttrs,
36
+ legendWrapperAttrs,
37
+ legendBoxAttrs,
38
+ chartTooltipAttrs,
39
+ tooltipWrapperAttrs,
40
+ tooltipRowAttrs,
41
+ tooltipItemAttrs,
42
+ tooltipBoxAttrs,
43
+ chart,
44
+ legend,
45
+ tooltip
46
+ } = useChart(props, emit);
47
+ return () => {
48
+ const children = slots.default && slots.default();
49
+ const {
50
+ title,
51
+ isShowLegend,
52
+ isShowTooltip
53
+ } = props;
54
+ return _createVNode("div", rootAttrs.value, [(title || slots.action) && _createVNode("div", chartHeaderAttrs.value, [_createVNode(MpText, {
55
+ "size": "h2",
56
+ "weight": "semiBold"
57
+ }, _isSlot(title) ? title : {
58
+ default: () => [title]
59
+ }), slots.action && slots.action(chart.value)]), _createVNode("div", chartWrapperAttrs.value, [_createVNode("div", chartContainerAttrs.value, [_createVNode("div", canvasContainerAttrs.value, [_createVNode("canvas", canvasAttrs.value, null)]), children]), isShowLegend ? slots.legend ? slots.legend(merge(legend.value)) : _createVNode("div", chartLegendAttrs.value, [
60
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
61
+ legend.value.map((item, index) => {
62
+ return _createVNode("div", legendWrapperAttrs(item, index), [_createVNode("div", legendBoxAttrs(item), null), _createVNode(MpText, {
63
+ "is-strike": item.hidden
64
+ }, {
65
+ default: () => [item.text]
66
+ })]);
67
+ })
68
+ ]) : "", isShowTooltip && _createVNode("div", chartTooltipAttrs.value, [slots.tooltip ? slots.tooltip(tooltip.value.data) : _createVNode("div", tooltipWrapperAttrs.value, [_createVNode(MpText, {
69
+ "size": "label",
70
+ "color": "gray.600"
71
+ }, {
72
+ default: () => {
73
+ var _a, _b;
74
+ return [(_b = (_a = tooltip.value.data) == null ? void 0 : _a.dataPoints[0]) == null ? void 0 : _b.label];
75
+ }
76
+ }), _createVNode("div", tooltipRowAttrs.value, [_createVNode("div", tooltipItemAttrs.value, [_createVNode("div", tooltipBoxAttrs.value, null), _createVNode(MpText, {
77
+ "size": "label-small",
78
+ "weight": "semiBold"
79
+ }, {
80
+ default: () => {
81
+ var _a, _b;
82
+ return [(_b = (_a = tooltip.value.data) == null ? void 0 : _a.dataPoints[0]) == null ? void 0 : _b.dataset.label];
83
+ }
84
+ })]), _createVNode(MpText, {
85
+ "size": "label-small",
86
+ "color": "gray.600"
87
+ }, {
88
+ default: () => {
89
+ var _a, _b;
90
+ return [(_b = (_a = tooltip.value.data) == null ? void 0 : _a.dataPoints[0]) == null ? void 0 : _b.formattedValue];
91
+ }
92
+ })])])])])]);
93
+ };
94
+ }
95
+ });
96
+
97
+ export {
98
+ MpChart
99
+ };
@@ -0,0 +1,5 @@
1
+ export { MpChart } from './chart.mjs';
2
+ import 'vue/jsx-runtime';
3
+ import 'chart.js/dist/types/utils';
4
+ import 'chart.js';
5
+ import 'vue';
@@ -0,0 +1,5 @@
1
+ export { MpChart } from './chart.js';
2
+ import 'vue/jsx-runtime';
3
+ import 'chart.js/dist/types/utils';
4
+ import 'chart.js';
5
+ import 'vue';