v-nuxt-ui 0.2.13 → 0.2.15

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/module.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "dependencies": [
8
8
  "@nuxt/ui"
9
9
  ],
10
- "version": "0.2.13",
10
+ "version": "0.2.15",
11
11
  "builder": {
12
12
  "@nuxt/module-builder": "1.0.2",
13
13
  "unbuild": "3.6.1"
@@ -5,11 +5,15 @@ interface Props {
5
5
  useLine?: boolean;
6
6
  useGrid?: boolean;
7
7
  useRadar?: boolean;
8
+ enableXAxis?: boolean;
9
+ enableYAxis?: boolean;
8
10
  colors?: string[];
9
11
  }
10
12
  declare const __VLS_export: import("vue").DefineComponent<Props, {
11
13
  downloadImage: (filenamePrefix?: string) => void;
12
14
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
15
+ enableXAxis: boolean;
16
+ enableYAxis: boolean;
13
17
  useBar: boolean;
14
18
  usePie: boolean;
15
19
  useLine: boolean;
@@ -13,7 +13,7 @@ import {
13
13
  import VChart from "vue-echarts";
14
14
  import { useTheme, useApp, useEChart } from "#v/composables";
15
15
  import { useColorMode, useLocalStorage } from "@vueuse/core";
16
- import { ref, useTemplateRef, watch } from "vue";
16
+ import { nextTick, ref, useTemplateRef, watch } from "vue";
17
17
  import { StorageKey } from "#v/types";
18
18
  const props = defineProps({
19
19
  option: { type: null, required: true },
@@ -22,6 +22,8 @@ const props = defineProps({
22
22
  useLine: { type: Boolean, required: false, default: false },
23
23
  useGrid: { type: Boolean, required: false, default: false },
24
24
  useRadar: { type: Boolean, required: false },
25
+ enableXAxis: { type: Boolean, required: false, default: true },
26
+ enableYAxis: { type: Boolean, required: false, default: true },
25
27
  colors: { type: Array, required: false, default: () => [] }
26
28
  });
27
29
  const chartsToUse = [CanvasRenderer];
@@ -57,23 +59,29 @@ const echart = useEChart();
57
59
  const rotateXAxisLabel = useLocalStorage(StorageKey.ECHART_ROTATE_X_AXIS_LABEL, false);
58
60
  const finalOption = ref({});
59
61
  const updateOption = () => {
60
- finalOption.value = echart.mergeOption(props.option);
62
+ finalOption.value = echart.mergeOption(props.option, {
63
+ enableXAxis: props.enableXAxis,
64
+ enableYAxis: props.enableYAxis
65
+ });
61
66
  };
62
67
  const devicePixelRatio = window.devicePixelRatio || 1;
63
68
  const chartRef = useTemplateRef("v-chart");
64
69
  watch(
65
70
  [
66
71
  () => props.option,
67
- colorMode,
72
+ () => colorMode.value,
73
+ () => props.enableXAxis,
74
+ () => props.enableYAxis,
68
75
  () => theme.primary.value,
69
76
  () => theme.neutral.value,
70
77
  () => app.appConfig.value.radius,
71
78
  () => rotateXAxisLabel.value
72
79
  ],
73
- () => setTimeout(() => {
80
+ async () => {
81
+ await nextTick();
74
82
  updateOption();
75
- }, 1),
76
- { immediate: true, deep: true }
83
+ },
84
+ { immediate: true, deep: true, flush: "post" }
77
85
  );
78
86
  defineExpose({
79
87
  downloadImage: (filenamePrefix) => {
@@ -5,11 +5,15 @@ interface Props {
5
5
  useLine?: boolean;
6
6
  useGrid?: boolean;
7
7
  useRadar?: boolean;
8
+ enableXAxis?: boolean;
9
+ enableYAxis?: boolean;
8
10
  colors?: string[];
9
11
  }
10
12
  declare const __VLS_export: import("vue").DefineComponent<Props, {
11
13
  downloadImage: (filenamePrefix?: string) => void;
12
14
  }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<Props> & Readonly<{}>, {
15
+ enableXAxis: boolean;
16
+ enableYAxis: boolean;
13
17
  useBar: boolean;
14
18
  usePie: boolean;
15
19
  useLine: boolean;
@@ -1,6 +1,6 @@
1
1
  <script setup>
2
2
  import { useColorMode } from "@vueuse/core";
3
- import { ref, onMounted, watch } from "vue";
3
+ import { ref, onMounted, watch, nextTick } from "vue";
4
4
  const props = defineProps({
5
5
  text: { type: [String, Array], required: false, default: "Watermark" },
6
6
  fontSize: { type: Number, required: false, default: 13 },
@@ -137,9 +137,8 @@ watch(
137
137
  { immediate: true, deep: true }
138
138
  );
139
139
  const colorMode = useColorMode();
140
- watch(() => colorMode.value, generateWatermark);
141
- onMounted(() => {
142
- generateWatermark();
140
+ watch(() => colorMode.value, () => {
141
+ nextTick(generateWatermark);
143
142
  });
144
143
  </script>
145
144
 
@@ -1,3 +1,7 @@
1
+ interface MergeOptionConfig {
2
+ enableXAxis?: boolean;
3
+ enableYAxis?: boolean;
4
+ }
1
5
  export declare const useEChart: () => {
2
6
  getCommonGridOption: () => {
3
7
  grid: {
@@ -21,7 +25,7 @@ export declare const useEChart: () => {
21
25
  icon: string;
22
26
  };
23
27
  };
24
- getCommonXAxisOption: () => {
28
+ getCommonXAxisOption: (enableXAxis?: boolean) => {
25
29
  xAxis: {
26
30
  nameTextStyle: {
27
31
  color: string;
@@ -47,7 +51,7 @@ export declare const useEChart: () => {
47
51
  };
48
52
  };
49
53
  };
50
- getCommonYAxisOption: () => {
54
+ getCommonYAxisOption: (enableYAxis?: boolean) => {
51
55
  yAxis: {
52
56
  nameTextStyle: {
53
57
  color: string;
@@ -90,7 +94,7 @@ export declare const useEChart: () => {
90
94
  };
91
95
  };
92
96
  mergeSeries: (series: any[]) => any[];
93
- mergeOption: (option: any) => any;
97
+ mergeOption: (option: any, config?: MergeOptionConfig) => any;
94
98
  parseCSSVariableColor: (colorStr: string) => string;
95
99
  exportChartAsImage: (chart: any, options?: {
96
100
  type?: string;
@@ -99,3 +103,4 @@ export declare const useEChart: () => {
99
103
  filename?: string;
100
104
  }) => void;
101
105
  };
106
+ export {};
@@ -40,13 +40,13 @@ const _useEChart = () => {
40
40
  icon: "circle"
41
41
  }
42
42
  });
43
- const getCommonXAxisOption = () => ({
43
+ const getCommonXAxisOption = (enableXAxis = true) => ({
44
44
  xAxis: {
45
45
  nameTextStyle: {
46
46
  color: getNormedUiTextColor()
47
47
  },
48
48
  axisLine: {
49
- show: true,
49
+ show: enableXAxis,
50
50
  lineStyle: {
51
51
  color: getNormedUiBorderColor()
52
52
  }
@@ -59,7 +59,7 @@ const _useEChart = () => {
59
59
  rotate: rotateXAxisLabel.value ? 90 : 0
60
60
  },
61
61
  axisTick: {
62
- show: true,
62
+ show: enableXAxis,
63
63
  interval: () => true,
64
64
  // 始终显示所有刻度线
65
65
  lineStyle: {
@@ -68,13 +68,13 @@ const _useEChart = () => {
68
68
  }
69
69
  }
70
70
  });
71
- const getCommonYAxisOption = () => ({
71
+ const getCommonYAxisOption = (enableYAxis = true) => ({
72
72
  yAxis: {
73
73
  nameTextStyle: {
74
74
  color: getNormedUiTextColor()
75
75
  },
76
76
  axisLine: {
77
- show: true,
77
+ show: enableYAxis,
78
78
  lineStyle: {
79
79
  color: getNormedUiBorderColor()
80
80
  }
@@ -214,11 +214,24 @@ const _useEChart = () => {
214
214
  return merged;
215
215
  });
216
216
  };
217
- const mergeOption = (option) => {
218
- const commonOption = defu(getCommonGridOption(), getCommonLegendOption(), getCommonXAxisOption(), getCommonYAxisOption());
217
+ const mergeOption = (option, config = {}) => {
218
+ const {
219
+ enableXAxis = true,
220
+ enableYAxis = true
221
+ } = config;
222
+ const commonOption = defu(
223
+ getCommonGridOption(),
224
+ getCommonLegendOption(),
225
+ getCommonXAxisOption(enableXAxis),
226
+ getCommonYAxisOption(enableYAxis)
227
+ );
219
228
  const merged = defu(option, commonOption);
229
+ if (merged.xAxis && Array.isArray(merged.xAxis) && merged.xAxis.length > 1) {
230
+ const xAxisDefaults = getCommonXAxisOption(enableXAxis).xAxis;
231
+ merged.xAxis = merged.xAxis.map((axis) => defu(axis, xAxisDefaults));
232
+ }
220
233
  if (merged.yAxis && Array.isArray(merged.yAxis) && merged.yAxis.length > 1) {
221
- const yAxisDefaults = getCommonYAxisOption().yAxis;
234
+ const yAxisDefaults = getCommonYAxisOption(enableYAxis).yAxis;
222
235
  merged.yAxis = merged.yAxis.map((axis) => defu(axis, yAxisDefaults));
223
236
  }
224
237
  if (merged.series && Array.isArray(merged.series)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "v-nuxt-ui",
3
- "version": "0.2.13",
3
+ "version": "0.2.15",
4
4
  "description": "Veken UI Component Library - Reusable Nuxt UI components, composables, and utilities for enterprise applications",
5
5
  "type": "module",
6
6
  "style": "./dist/runtime/index.css",