hfn-components 0.1.0 → 0.1.2

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.
Files changed (57) hide show
  1. package/dist/index.css +1 -0
  2. package/es/component.mjs +2 -0
  3. package/es/components/chart/index.d.ts +151 -0
  4. package/es/components/chart/index.mjs +7 -0
  5. package/es/components/chart/src/HtChart.d.ts +57 -0
  6. package/es/components/chart/src/HtChart.mjs +77 -0
  7. package/es/components/chart/src/HtChart.vue.d.ts +157 -0
  8. package/es/components/chart/src/HtChart.vue.mjs +91 -0
  9. package/es/components/chart/src/HtChart.vue2.mjs +94 -0
  10. package/es/components/chart/src/chartConfig.d.ts +7 -0
  11. package/es/components/chart/src/chartConfig.mjs +88 -0
  12. package/es/components/chart/style/index.d.ts +1 -0
  13. package/es/components/elTable/index.d.ts +84 -37
  14. package/es/components/elTable/index.mjs +1 -1
  15. package/es/components/elTable/src/columnDeal.vue.d.ts +27 -15
  16. package/es/components/elTable/src/columnDeal.vue.mjs +2 -2
  17. package/es/components/elTable/src/columnDeal.vue2.mjs +2 -4
  18. package/es/components/elTable/src/elTable.d.ts +14 -2
  19. package/es/components/elTable/src/elTable.mjs +11 -1
  20. package/es/components/elTable/src/elTable.vue.d.ts +84 -37
  21. package/es/components/elTable/src/elTable.vue.mjs +9 -3
  22. package/es/components/elTable/src/elTable.vue2.mjs +3 -3
  23. package/es/components/index.d.ts +1 -0
  24. package/es/components/index.mjs +3 -1
  25. package/es/components/table/HtTable.d.ts +1 -1
  26. package/es/components/table/HtTable.vue.d.ts +6 -6
  27. package/es/components/table/HtTable.vue.mjs +8 -2
  28. package/es/components/table/HtTable.vue2.mjs +11 -15
  29. package/es/components/table/index.d.ts +6 -6
  30. package/es/constants/table.d.ts +45 -2
  31. package/es/constants/table.mjs +4 -3
  32. package/es/css/index.css +59 -0
  33. package/es/index.mjs +3 -1
  34. package/es/utils/chart.d.ts +7 -0
  35. package/es/utils/chart.mjs +163 -0
  36. package/es/utils/common.d.ts +1 -1
  37. package/es/utils/index.d.ts +1 -0
  38. package/es/utils/index.mjs +1 -0
  39. package/es/utils/tool.mjs +1 -1
  40. package/global.d.ts +8 -9
  41. package/package.json +4 -2
  42. package/theme-chalk/ht-chart.css +1 -0
  43. package/theme-chalk/index.css +1 -0
  44. package/theme-chalk/src/chart.scss +53 -0
  45. package/theme-chalk/src/index.scss +1 -0
  46. package/es/components/button/HtButton.vue.d.ts +0 -19
  47. package/es/components/button/HtButton.vue.mjs +0 -16
  48. package/es/components/button/HtButton.vue2.mjs +0 -42
  49. package/es/components/button/index.d.ts +0 -20
  50. package/es/components/button/index.mjs +0 -6
  51. package/es/components/button/instance.d.ts +0 -2
  52. package/es/components/button/instance.mjs +0 -1
  53. package/es/components/eleTable/index.d.ts +0 -0
  54. package/es/components/eleTable/src/eleTable.d.ts +0 -0
  55. package/es/components/eleTable/src/eleTable.mjs +0 -1
  56. package/es/components/eleTable/src/eleTable.vue.mjs +0 -10
  57. /package/es/components/{eleTable → chart/style}/index.mjs +0 -0
package/dist/index.css ADDED
@@ -0,0 +1 @@
1
+ .echart-box{display:flex;flex-direction:column;height:100%;position:relative;width:100%}.echart-content{flex:auto}.echart-lenged{box-sizing:border-box;display:flex;flex-wrap:wrap;font-size:12px;height:auto;margin-top:6px;padding-right:22px;position:relative;width:100%;z-index:999}.bg-span{height:2px;width:14px}.bg-span,.bg-span-bar{display:inline-block;margin-right:6px}.bg-span-bar{border-radius:2px;height:10px;width:16px}.span-box{cursor:pointer;margin-left:5px;margin-right:6px}.noData,.span-box{align-items:center;display:flex}.noData{bottom:0;color:#ccc;font-size:16px;height:100%;justify-content:center;position:absolute;width:100%}
package/es/component.mjs CHANGED
@@ -1,7 +1,9 @@
1
1
  import { HtElTable } from './components/elTable/index.mjs';
2
+ import { HtChart } from './components/chart/index.mjs';
2
3
 
3
4
  var Components = [
4
5
  // HtTable,
6
+ HtChart,
5
7
  HtElTable
6
8
  ];
7
9
 
@@ -0,0 +1,151 @@
1
+ export declare const HtChart: import("hfn-components/es/utils").SFCWithInstall<import("vue").DefineComponent<{
2
+ readonly chartData: {
3
+ readonly type: import("vue").PropType<any[]>;
4
+ readonly default: () => never[];
5
+ };
6
+ readonly chartId: {
7
+ readonly type: StringConstructor;
8
+ readonly default: "";
9
+ };
10
+ readonly chartType: {
11
+ readonly type: import("vue").PropType<import("hfn-components/es/utils").chartType>;
12
+ readonly default: "";
13
+ };
14
+ readonly xAxisData: {
15
+ readonly type: import("vue").PropType<string[]>;
16
+ readonly default: readonly [];
17
+ };
18
+ readonly collation: {
19
+ readonly type: StringConstructor;
20
+ readonly default: "des";
21
+ };
22
+ readonly isReturn: {
23
+ readonly type: BooleanConstructor;
24
+ readonly default: false;
25
+ };
26
+ readonly isPercent: {
27
+ readonly type: BooleanConstructor;
28
+ readonly default: false;
29
+ };
30
+ readonly floatNumber: {
31
+ readonly type: NumberConstructor;
32
+ readonly default: 4;
33
+ };
34
+ readonly titleText: {
35
+ readonly type: StringConstructor;
36
+ readonly default: "";
37
+ };
38
+ readonly tooltipUnit: {
39
+ readonly type: StringConstructor;
40
+ readonly default: "";
41
+ };
42
+ readonly watchResize: {
43
+ readonly type: BooleanConstructor;
44
+ readonly default: false;
45
+ };
46
+ readonly showLegend: {
47
+ readonly type: BooleanConstructor;
48
+ readonly default: true;
49
+ };
50
+ readonly downLoadAutn: {
51
+ readonly type: BooleanConstructor;
52
+ readonly default: false;
53
+ };
54
+ }, {
55
+ props: import("@vue/shared").LooseRequired<{
56
+ readonly chartData: any[];
57
+ readonly chartId: string;
58
+ readonly chartType: import("hfn-components/es/utils").chartType;
59
+ readonly xAxisData: string[];
60
+ readonly collation: string;
61
+ readonly isReturn: boolean;
62
+ readonly isPercent: boolean;
63
+ readonly floatNumber: number;
64
+ readonly titleText: string;
65
+ readonly tooltipUnit: string;
66
+ readonly watchResize: boolean;
67
+ readonly showLegend: boolean;
68
+ readonly downLoadAutn: boolean;
69
+ } & {}>;
70
+ myChart: import("vue").ShallowRef<any>;
71
+ isEmpty: import("vue").Ref<boolean>;
72
+ echartOptions: any;
73
+ drawGraph: () => void;
74
+ lengedDeal: () => void;
75
+ echartInit: () => void;
76
+ chartResize: () => void;
77
+ allLegend: import("vue").Ref<import("./src/HtChart.vue").Legend[]>;
78
+ noData: import("vue").Ref<boolean>;
79
+ legendStatus: (item: import("./src/HtChart.vue").Legend, index: number) => void;
80
+ legendEnter: (index: number) => void;
81
+ legendLeave: () => void;
82
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
83
+ readonly chartData: {
84
+ readonly type: import("vue").PropType<any[]>;
85
+ readonly default: () => never[];
86
+ };
87
+ readonly chartId: {
88
+ readonly type: StringConstructor;
89
+ readonly default: "";
90
+ };
91
+ readonly chartType: {
92
+ readonly type: import("vue").PropType<import("hfn-components/es/utils").chartType>;
93
+ readonly default: "";
94
+ };
95
+ readonly xAxisData: {
96
+ readonly type: import("vue").PropType<string[]>;
97
+ readonly default: readonly [];
98
+ };
99
+ readonly collation: {
100
+ readonly type: StringConstructor;
101
+ readonly default: "des";
102
+ };
103
+ readonly isReturn: {
104
+ readonly type: BooleanConstructor;
105
+ readonly default: false;
106
+ };
107
+ readonly isPercent: {
108
+ readonly type: BooleanConstructor;
109
+ readonly default: false;
110
+ };
111
+ readonly floatNumber: {
112
+ readonly type: NumberConstructor;
113
+ readonly default: 4;
114
+ };
115
+ readonly titleText: {
116
+ readonly type: StringConstructor;
117
+ readonly default: "";
118
+ };
119
+ readonly tooltipUnit: {
120
+ readonly type: StringConstructor;
121
+ readonly default: "";
122
+ };
123
+ readonly watchResize: {
124
+ readonly type: BooleanConstructor;
125
+ readonly default: false;
126
+ };
127
+ readonly showLegend: {
128
+ readonly type: BooleanConstructor;
129
+ readonly default: true;
130
+ };
131
+ readonly downLoadAutn: {
132
+ readonly type: BooleanConstructor;
133
+ readonly default: false;
134
+ };
135
+ }>>, {
136
+ readonly chartData: any[];
137
+ readonly chartId: string;
138
+ readonly chartType: import("hfn-components/es/utils").chartType;
139
+ readonly xAxisData: string[];
140
+ readonly collation: string;
141
+ readonly isReturn: boolean;
142
+ readonly isPercent: boolean;
143
+ readonly floatNumber: number;
144
+ readonly titleText: string;
145
+ readonly tooltipUnit: string;
146
+ readonly watchResize: boolean;
147
+ readonly showLegend: boolean;
148
+ readonly downLoadAutn: boolean;
149
+ }, {}>> & Record<string, any>;
150
+ export default HtChart;
151
+ export * from './src/HtChart';
@@ -0,0 +1,7 @@
1
+ import chart from './src/HtChart.vue.mjs';
2
+ import { withInstall } from '../../utils/common.mjs';
3
+ export { chartProps } from './src/HtChart.mjs';
4
+
5
+ const HtChart = withInstall(chart);
6
+
7
+ export { HtChart, HtChart as default };
@@ -0,0 +1,57 @@
1
+ import { PropType, ExtractPropTypes } from 'vue';
2
+ import type { chartType } from 'hfn-components/es/utils';
3
+ export declare const chartProps: {
4
+ readonly chartData: {
5
+ readonly type: PropType<any[]>;
6
+ readonly default: () => never[];
7
+ };
8
+ readonly chartId: {
9
+ readonly type: StringConstructor;
10
+ readonly default: "";
11
+ };
12
+ readonly chartType: {
13
+ readonly type: PropType<chartType>;
14
+ readonly default: "";
15
+ };
16
+ readonly xAxisData: {
17
+ readonly type: PropType<string[]>;
18
+ readonly default: readonly [];
19
+ };
20
+ readonly collation: {
21
+ readonly type: StringConstructor;
22
+ readonly default: "des";
23
+ };
24
+ readonly isReturn: {
25
+ readonly type: BooleanConstructor;
26
+ readonly default: false;
27
+ };
28
+ readonly isPercent: {
29
+ readonly type: BooleanConstructor;
30
+ readonly default: false;
31
+ };
32
+ readonly floatNumber: {
33
+ readonly type: NumberConstructor;
34
+ readonly default: 4;
35
+ };
36
+ readonly titleText: {
37
+ readonly type: StringConstructor;
38
+ readonly default: "";
39
+ };
40
+ readonly tooltipUnit: {
41
+ readonly type: StringConstructor;
42
+ readonly default: "";
43
+ };
44
+ readonly watchResize: {
45
+ readonly type: BooleanConstructor;
46
+ readonly default: false;
47
+ };
48
+ readonly showLegend: {
49
+ readonly type: BooleanConstructor;
50
+ readonly default: true;
51
+ };
52
+ readonly downLoadAutn: {
53
+ readonly type: BooleanConstructor;
54
+ readonly default: false;
55
+ };
56
+ };
57
+ export type chartProp = ExtractPropTypes<typeof chartProps>;
@@ -0,0 +1,77 @@
1
+ const chartProps = {
2
+ //图表数据
3
+ chartData: {
4
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
+ type: Array,
6
+ default: () => []
7
+ },
8
+ //图表id
9
+ chartId: {
10
+ type: String,
11
+ default: ""
12
+ },
13
+ //图表高度
14
+ // chartHeight: {
15
+ // type: String,
16
+ // default: ''
17
+ // },
18
+ chartType: {
19
+ type: String,
20
+ default: ""
21
+ },
22
+ //是否为类目轴
23
+ // isCategory: {
24
+ // type: Boolean,
25
+ // default: false
26
+ // },
27
+ //是类目轴时x轴数据
28
+ xAxisData: {
29
+ type: Array,
30
+ default: []
31
+ },
32
+ collation: {
33
+ type: String,
34
+ default: "des"
35
+ },
36
+ //是否为收益率
37
+ isReturn: {
38
+ type: Boolean,
39
+ default: false
40
+ },
41
+ //是否有百分比
42
+ isPercent: {
43
+ type: Boolean,
44
+ default: false
45
+ },
46
+ //保留几位小数
47
+ floatNumber: {
48
+ type: Number,
49
+ default: 4
50
+ },
51
+ //y轴文本
52
+ titleText: {
53
+ type: String,
54
+ default: ""
55
+ },
56
+ //tooltip单位
57
+ tooltipUnit: {
58
+ type: String,
59
+ default: ""
60
+ },
61
+ //图表重新加载
62
+ watchResize: {
63
+ type: Boolean,
64
+ default: false
65
+ },
66
+ showLegend: {
67
+ type: Boolean,
68
+ default: true
69
+ },
70
+ //数据下载
71
+ downLoadAutn: {
72
+ type: Boolean,
73
+ default: false
74
+ }
75
+ };
76
+
77
+ export { chartProps };
@@ -0,0 +1,157 @@
1
+ import type { Ref } from 'vue';
2
+ export interface Legend {
3
+ name: string;
4
+ lineType: string;
5
+ isShow: boolean;
6
+ color: string;
7
+ }
8
+ declare const _default: import("vue").DefineComponent<{
9
+ readonly chartData: {
10
+ readonly type: import("vue").PropType<any[]>;
11
+ readonly default: () => never[];
12
+ };
13
+ readonly chartId: {
14
+ readonly type: StringConstructor;
15
+ readonly default: "";
16
+ };
17
+ readonly chartType: {
18
+ readonly type: import("vue").PropType<import("hfn-components/es/utils").chartType>;
19
+ readonly default: "";
20
+ };
21
+ readonly xAxisData: {
22
+ readonly type: import("vue").PropType<string[]>;
23
+ readonly default: readonly [];
24
+ };
25
+ readonly collation: {
26
+ readonly type: StringConstructor;
27
+ readonly default: "des";
28
+ };
29
+ readonly isReturn: {
30
+ readonly type: BooleanConstructor;
31
+ readonly default: false;
32
+ };
33
+ readonly isPercent: {
34
+ readonly type: BooleanConstructor;
35
+ readonly default: false;
36
+ };
37
+ readonly floatNumber: {
38
+ readonly type: NumberConstructor;
39
+ readonly default: 4;
40
+ };
41
+ readonly titleText: {
42
+ readonly type: StringConstructor;
43
+ readonly default: "";
44
+ };
45
+ readonly tooltipUnit: {
46
+ readonly type: StringConstructor;
47
+ readonly default: "";
48
+ };
49
+ readonly watchResize: {
50
+ readonly type: BooleanConstructor;
51
+ readonly default: false;
52
+ };
53
+ readonly showLegend: {
54
+ readonly type: BooleanConstructor;
55
+ readonly default: true;
56
+ };
57
+ readonly downLoadAutn: {
58
+ readonly type: BooleanConstructor;
59
+ readonly default: false;
60
+ };
61
+ }, {
62
+ props: import("@vue/shared").LooseRequired<{
63
+ readonly chartData: any[];
64
+ readonly chartId: string;
65
+ readonly chartType: import("hfn-components/es/utils").chartType;
66
+ readonly xAxisData: string[];
67
+ readonly collation: string;
68
+ readonly isReturn: boolean;
69
+ readonly isPercent: boolean;
70
+ readonly floatNumber: number;
71
+ readonly titleText: string;
72
+ readonly tooltipUnit: string;
73
+ readonly watchResize: boolean;
74
+ readonly showLegend: boolean;
75
+ readonly downLoadAutn: boolean;
76
+ } & {}>;
77
+ myChart: import("vue").ShallowRef<any>;
78
+ isEmpty: Ref<boolean>;
79
+ echartOptions: any;
80
+ drawGraph: () => void;
81
+ lengedDeal: () => void;
82
+ echartInit: () => void;
83
+ chartResize: () => void;
84
+ allLegend: Ref<Legend[]>;
85
+ noData: Ref<boolean>;
86
+ legendStatus: (item: Legend, index: number) => void;
87
+ legendEnter: (index: number) => void;
88
+ legendLeave: () => void;
89
+ }, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
90
+ readonly chartData: {
91
+ readonly type: import("vue").PropType<any[]>;
92
+ readonly default: () => never[];
93
+ };
94
+ readonly chartId: {
95
+ readonly type: StringConstructor;
96
+ readonly default: "";
97
+ };
98
+ readonly chartType: {
99
+ readonly type: import("vue").PropType<import("hfn-components/es/utils").chartType>;
100
+ readonly default: "";
101
+ };
102
+ readonly xAxisData: {
103
+ readonly type: import("vue").PropType<string[]>;
104
+ readonly default: readonly [];
105
+ };
106
+ readonly collation: {
107
+ readonly type: StringConstructor;
108
+ readonly default: "des";
109
+ };
110
+ readonly isReturn: {
111
+ readonly type: BooleanConstructor;
112
+ readonly default: false;
113
+ };
114
+ readonly isPercent: {
115
+ readonly type: BooleanConstructor;
116
+ readonly default: false;
117
+ };
118
+ readonly floatNumber: {
119
+ readonly type: NumberConstructor;
120
+ readonly default: 4;
121
+ };
122
+ readonly titleText: {
123
+ readonly type: StringConstructor;
124
+ readonly default: "";
125
+ };
126
+ readonly tooltipUnit: {
127
+ readonly type: StringConstructor;
128
+ readonly default: "";
129
+ };
130
+ readonly watchResize: {
131
+ readonly type: BooleanConstructor;
132
+ readonly default: false;
133
+ };
134
+ readonly showLegend: {
135
+ readonly type: BooleanConstructor;
136
+ readonly default: true;
137
+ };
138
+ readonly downLoadAutn: {
139
+ readonly type: BooleanConstructor;
140
+ readonly default: false;
141
+ };
142
+ }>>, {
143
+ readonly chartData: any[];
144
+ readonly chartId: string;
145
+ readonly chartType: import("hfn-components/es/utils").chartType;
146
+ readonly xAxisData: string[];
147
+ readonly collation: string;
148
+ readonly isReturn: boolean;
149
+ readonly isPercent: boolean;
150
+ readonly floatNumber: number;
151
+ readonly titleText: string;
152
+ readonly tooltipUnit: string;
153
+ readonly watchResize: boolean;
154
+ readonly showLegend: boolean;
155
+ readonly downLoadAutn: boolean;
156
+ }, {}>;
157
+ export default _default;
@@ -0,0 +1,91 @@
1
+ import _sfc_main from './HtChart.vue2.mjs';
2
+ import { openBlock, createElementBlock, Fragment, renderList, normalizeStyle, createCommentVNode, createElementVNode, toDisplayString } from 'vue';
3
+ import _export_sfc from '../../../_virtual/_plugin-vue_export-helper.mjs';
4
+
5
+ const _hoisted_1 = { class: "echart-box" };
6
+ const _hoisted_2 = {
7
+ key: 0,
8
+ class: "echart-lenged"
9
+ };
10
+ const _hoisted_3 = ["onClick", "onMouseover"];
11
+ const _hoisted_4 = ["id"];
12
+ const _hoisted_5 = {
13
+ key: 1,
14
+ class: "noData"
15
+ };
16
+ function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
17
+ return openBlock(), createElementBlock("div", _hoisted_1, [
18
+ _ctx.showLegend && !$setup.isEmpty ? (openBlock(), createElementBlock("div", _hoisted_2, [
19
+ (openBlock(true), createElementBlock(
20
+ Fragment,
21
+ null,
22
+ renderList($setup.allLegend, (item, index) => {
23
+ return openBlock(), createElementBlock("div", {
24
+ class: "span-box mb10",
25
+ key: index,
26
+ onClick: ($event) => $setup.legendStatus(item, index),
27
+ onMouseover: ($event) => $setup.legendEnter(index),
28
+ onMouseleave: _cache[0] || (_cache[0] = ($event) => $setup.legendLeave())
29
+ }, [
30
+ item.lineType === "line" ? (openBlock(), createElementBlock(
31
+ "span",
32
+ {
33
+ key: 0,
34
+ class: "bg-span",
35
+ style: normalizeStyle({ background: item.isShow ? item.color : "#ccc" })
36
+ },
37
+ null,
38
+ 4
39
+ /* STYLE */
40
+ )) : createCommentVNode("v-if", true),
41
+ item.lineType === "bar" ? (openBlock(), createElementBlock(
42
+ "span",
43
+ {
44
+ key: 1,
45
+ class: "bg-span-bar",
46
+ style: normalizeStyle({ background: item.isShow ? item.color : "#ccc" })
47
+ },
48
+ null,
49
+ 4
50
+ /* STYLE */
51
+ )) : createCommentVNode("v-if", true),
52
+ createElementVNode(
53
+ "span",
54
+ {
55
+ style: normalizeStyle({ color: item.isShow ? "#000" : "#ccc" })
56
+ },
57
+ toDisplayString(item.name),
58
+ 5
59
+ /* TEXT, STYLE */
60
+ ),
61
+ createCommentVNode(` <span
62
+ v-if="isLegend"
63
+ class="returnRatio"
64
+ :style="{ color: item.isShow ? (item.returnRatio > 0 ? 'red' : item.returnRatio < 0 ? 'green' : '#000') : '#ccc' }"
65
+ >
66
+ {{
67
+ item.name !== '\u57FA\u91D1\u89C4\u6A21' && item.name !== '\u603B\u5E02\u503C' && item.name !== '\u6D41\u901A\u5E02\u503C'
68
+ ? item.returnRatio === ''
69
+ ? ''
70
+ : item.returnRatio.toFixed(2) + (isPercent || specialPercent ? '%' : '')
71
+ : \`\${item.returnRatio}\${props.tooltipUnit}\`
72
+ }}
73
+ </span> `)
74
+ ], 40, _hoisted_3);
75
+ }),
76
+ 128
77
+ /* KEYED_FRAGMENT */
78
+ ))
79
+ ])) : createCommentVNode("v-if", true),
80
+ createElementVNode("div", {
81
+ class: "echart-content",
82
+ id: _ctx.chartId,
83
+ ref: "chartDom"
84
+ }, null, 8, _hoisted_4),
85
+ createCommentVNode(" \u56FE\u4F8B\u5168\u7F6E\u7070\u76D2\u5B50 "),
86
+ $setup.noData ? (openBlock(), createElementBlock("div", _hoisted_5, "\u6682\u65E0\u6570\u636E")) : createCommentVNode("v-if", true)
87
+ ]);
88
+ }
89
+ var chart = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "/Users/libiluo/Desktop/company/component-library/packages/components/chart/src/HtChart.vue"]]);
90
+
91
+ export { chart as default };
@@ -0,0 +1,94 @@
1
+ import { defineComponent, shallowRef, ref, reactive, watch } from 'vue';
2
+ import { BASIC_CHART_CONFIG } from './chartConfig.mjs';
3
+ import { chartProps } from './HtChart.mjs';
4
+ import cloneDeep from 'lodash.clonedeep';
5
+ import { setEchartXAxis, setEchartYAxis, setEchartTooltip, legendEnterOperate, legendLeaveOperate } from '../../../utils/chart.mjs';
6
+ import * as echarts from 'echarts/core';
7
+
8
+ var _sfc_main = /* @__PURE__ */ defineComponent({
9
+ __name: "HtChart",
10
+ props: chartProps,
11
+ setup(__props, { expose: __expose }) {
12
+ __expose();
13
+ const props = __props;
14
+ const myChart = shallowRef();
15
+ const isEmpty = ref(false);
16
+ const echartOptions = reactive(cloneDeep(BASIC_CHART_CONFIG));
17
+ watch(
18
+ () => props.chartData,
19
+ (val) => {
20
+ echartOptions.series = cloneDeep(val);
21
+ drawGraph();
22
+ },
23
+ {
24
+ deep: true
25
+ }
26
+ );
27
+ watch(
28
+ () => props.watchResize,
29
+ () => {
30
+ chartResize();
31
+ }
32
+ );
33
+ const drawGraph = () => {
34
+ setEchartXAxis(echartOptions, props.chartType, props.xAxisData);
35
+ setEchartYAxis(echartOptions);
36
+ setEchartTooltip(echartOptions, props);
37
+ lengedDeal();
38
+ echartInit();
39
+ };
40
+ const lengedDeal = () => {
41
+ allLegend.value = [];
42
+ props.chartData.forEach((item, index) => {
43
+ const data = {
44
+ name: item.name,
45
+ isShow: true,
46
+ lineType: item.type,
47
+ color: echartOptions.color[index % echartOptions.color.length]
48
+ };
49
+ allLegend.value.push(data);
50
+ });
51
+ };
52
+ const echartInit = () => {
53
+ setTimeout(() => {
54
+ if (!myChart.value) {
55
+ const ele = document.getElementById(props.chartId);
56
+ myChart.value = echarts.init(ele, null, { devicePixelRatio: 2 });
57
+ }
58
+ console.log(myChart.value);
59
+ myChart.value.setOption(echartOptions, true);
60
+ }, 200);
61
+ };
62
+ const chartResize = () => {
63
+ myChart.value.resize();
64
+ };
65
+ const allLegend = ref([]);
66
+ const noData = ref(false);
67
+ const legendStatus = (item, index) => {
68
+ const status = !item.isShow;
69
+ allLegend.value[index].isShow = status;
70
+ if (allLegend.value.every((item2) => item2.isShow === false)) {
71
+ noData.value = true;
72
+ } else {
73
+ noData.value = false;
74
+ }
75
+ myChart.value.dispatchAction({
76
+ type: "legendToggleSelect",
77
+ name: item.name
78
+ });
79
+ };
80
+ const legendEnter = (index) => {
81
+ legendEnterOperate(echartOptions, allLegend.value[index].name);
82
+ myChart.value.setOption(echartOptions);
83
+ };
84
+ const legendLeave = () => {
85
+ legendLeaveOperate(echartOptions);
86
+ myChart.value.setOption(echartOptions);
87
+ };
88
+ const __returned__ = { props, myChart, isEmpty, echartOptions, drawGraph, lengedDeal, echartInit, chartResize, allLegend, noData, legendStatus, legendEnter, legendLeave };
89
+ Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
90
+ return __returned__;
91
+ }
92
+ });
93
+
94
+ export { _sfc_main as default };
@@ -0,0 +1,7 @@
1
+ import * as echarts from 'echarts/core';
2
+ import type { BarSeriesOption, LineSeriesOption } from 'echarts/charts';
3
+ import type { TitleComponentOption, TooltipComponentOption, GridComponentOption, DatasetComponentOption } from 'echarts/components';
4
+ import type { ComposeOption } from 'echarts/core';
5
+ export type ECOption = ComposeOption<BarSeriesOption | LineSeriesOption | TitleComponentOption | TooltipComponentOption | GridComponentOption | DatasetComponentOption>;
6
+ export default echarts;
7
+ export declare const BASIC_CHART_CONFIG: any;