stellar-ui-plus 1.25.2 → 1.25.4

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.
@@ -99,6 +99,23 @@
99
99
  </script>
100
100
  ```
101
101
 
102
+ ## 事件
103
+
104
+ - 属性`getImage`: 通过ref来获取实例的base64格式的图片地址,异步方法,需在实例生成后调用。
105
+
106
+ ```html
107
+ <template>
108
+ <ste-area-chart :series="series1" :categories1="categories1" ref="areaChart"></ste-area-chart>
109
+ </template>
110
+ <script setup lang="ts">
111
+ import { ref,onMounted } from 'vue';
112
+ let areaChart: any = ref(null);
113
+ onMounted(async () => {
114
+ const base64 = await areaChart.value.getImage()
115
+ }),
116
+ </script>
117
+ ```
118
+
102
119
  ---$
103
120
 
104
121
  <!-- props -->
@@ -6,7 +6,7 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import uCharts from '../../Charts/Charts';
9
- import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance } from 'vue';
9
+ import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance, type ComponentPublicInstance } from 'vue';
10
10
  import utils from '../../utils/utils';
11
11
  import { propsData, propsComponent } from './props';
12
12
  import type { ChartsOptions } from '../../Charts/types/index';
@@ -99,6 +99,38 @@ function tap(e: any) {
99
99
  charts.value?.touchLegend(e);
100
100
  charts.value?.showToolTip(e);
101
101
  }
102
+ const thas = ref<ComponentPublicInstance | null>();
103
+ async function getImage() {
104
+ if (props.canvas2d == false) {
105
+ return new Promise(resolve => {
106
+ uni.canvasToTempFilePath(
107
+ {
108
+ canvasId: canvasId.value,
109
+ success: res => {
110
+ resolve(res.tempFilePath);
111
+ },
112
+ },
113
+ thas.value
114
+ );
115
+ });
116
+ } else {
117
+ return new Promise(resolve => {
118
+ const query = uni.createSelectorQuery().in(thas.value);
119
+ query
120
+ .select('#' + canvasId.value)
121
+ .fields({ node: true, size: true })
122
+ .exec(res => {
123
+ if (res[0]) {
124
+ const canvas = res[0].node;
125
+ resolve(canvas.toDataURL('image/png'));
126
+ }
127
+ });
128
+ });
129
+ }
130
+ }
131
+ defineExpose({
132
+ getImage,
133
+ });
102
134
  </script>
103
135
 
104
136
  <style scoped></style>
@@ -69,6 +69,23 @@
69
69
  </script>
70
70
  ```
71
71
 
72
+ ## 事件
73
+
74
+ - 属性`getImage`: 通过ref来获取实例的base64格式的图片地址,异步方法,需在实例生成后调用。
75
+
76
+ ```html
77
+ <template>
78
+ <ste-bar-chart :series="series1" :categories="['2018', '2019', '2020']" width="660" height="400" ref="barChart"></ste-bar-chart>
79
+ </template>
80
+ <script setup lang="ts">
81
+ import { ref,onMounted } from 'vue';
82
+ let barChart: any = ref(null);
83
+ onMounted(async () => {
84
+ const base64 = await barChart.value.getImage()
85
+ }),
86
+ </script>
87
+ ```
88
+
72
89
  ---$
73
90
 
74
91
  <!-- props -->
@@ -6,7 +6,7 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import uCharts from '../../Charts/Charts';
9
- import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance } from 'vue';
9
+ import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance, type ComponentPublicInstance } from 'vue';
10
10
  import utils from '../../utils/utils';
11
11
  import { propsData, propsComponent } from './props';
12
12
  import type { ChartsOptions, ChartsSerie } from '../../Charts/types/index';
@@ -95,4 +95,37 @@ function tap(e: any) {
95
95
  charts.value?.touchLegend(e);
96
96
  charts.value?.showToolTip(e);
97
97
  }
98
+
99
+ const thas = ref<ComponentPublicInstance | null>();
100
+ async function getImage() {
101
+ if (props.canvas2d == false) {
102
+ return new Promise(resolve => {
103
+ uni.canvasToTempFilePath(
104
+ {
105
+ canvasId: canvasId.value,
106
+ success: res => {
107
+ resolve(res.tempFilePath);
108
+ },
109
+ },
110
+ thas.value
111
+ );
112
+ });
113
+ } else {
114
+ return new Promise(resolve => {
115
+ const query = uni.createSelectorQuery().in(thas.value);
116
+ query
117
+ .select('#' + canvasId.value)
118
+ .fields({ node: true, size: true })
119
+ .exec(res => {
120
+ if (res[0]) {
121
+ const canvas = res[0].node;
122
+ resolve(canvas.toDataURL('image/png'));
123
+ }
124
+ });
125
+ });
126
+ }
127
+ }
128
+ defineExpose({
129
+ getImage,
130
+ });
98
131
  </script>
@@ -107,6 +107,23 @@
107
107
  </script>
108
108
  ```
109
109
 
110
+ ## 事件
111
+
112
+ - 属性`getImage`: 通过ref来获取实例的base64格式的图片地址,异步方法,需在实例生成后调用。
113
+
114
+ ```html
115
+ <template>
116
+ <ste-column-chart :series="series" :categories="categories" ref="columnChart"></ste-column-chart>
117
+ </template>
118
+ <script setup lang="ts">
119
+ import { ref,onMounted } from 'vue';
120
+ let columnChart: any = ref(null);
121
+ onMounted(async () => {
122
+ const base64 = await columnChart.value.getImage()
123
+ }),
124
+ </script>
125
+ ```
126
+
110
127
  ---$
111
128
 
112
129
  <!-- props -->
@@ -6,7 +6,7 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import uCharts from '../../Charts/Charts';
9
- import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance } from 'vue';
9
+ import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance, type ComponentPublicInstance } from 'vue';
10
10
  import utils from '../../utils/utils';
11
11
  import { propsData, propsComponent } from './props';
12
12
  import type { ChartsOptions } from '../../Charts/types/index';
@@ -96,6 +96,39 @@ function tap(e: any) {
96
96
  charts.value?.touchLegend(e);
97
97
  charts.value?.showToolTip(e);
98
98
  }
99
+
100
+ const thas = ref<ComponentPublicInstance | null>();
101
+ async function getImage() {
102
+ if (props.canvas2d == false) {
103
+ return new Promise(resolve => {
104
+ uni.canvasToTempFilePath(
105
+ {
106
+ canvasId: canvasId.value,
107
+ success: res => {
108
+ resolve(res.tempFilePath);
109
+ },
110
+ },
111
+ thas.value
112
+ );
113
+ });
114
+ } else {
115
+ return new Promise(resolve => {
116
+ const query = uni.createSelectorQuery().in(thas.value);
117
+ query
118
+ .select('#' + canvasId.value)
119
+ .fields({ node: true, size: true })
120
+ .exec(res => {
121
+ if (res[0]) {
122
+ const canvas = res[0].node;
123
+ resolve(canvas.toDataURL('image/png'));
124
+ }
125
+ });
126
+ });
127
+ }
128
+ }
129
+ defineExpose({
130
+ getImage,
131
+ });
99
132
  </script>
100
133
 
101
134
  <style scoped></style>
@@ -109,6 +109,23 @@
109
109
  </script>
110
110
  ```
111
111
 
112
+ ## 事件
113
+
114
+ - 属性`getImage`: 通过ref来获取实例的base64格式的图片地址,异步方法,需在实例生成后调用。
115
+
116
+ ```html
117
+ <template>
118
+ <ste-funnel-chart :series="series" ref="funnelChart"></ste-funnel-chart>
119
+ </template>
120
+ <script setup lang="ts">
121
+ import { ref,onMounted } from 'vue';
122
+ let funnelChart: any = ref(null);
123
+ onMounted(async () => {
124
+ const base64 = await funnelChart.value.getImage()
125
+ }),
126
+ </script>
127
+ ```
128
+
112
129
  ---$
113
130
 
114
131
  <!-- props -->
@@ -6,7 +6,7 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import uCharts from '../../Charts/Charts';
9
- import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance } from 'vue';
9
+ import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance, type ComponentPublicInstance } from 'vue';
10
10
  import utils from '../../utils/utils';
11
11
  import { propsData, propsComponent } from './props';
12
12
  import type { ChartsOptions } from '../../Charts/types/index';
@@ -95,6 +95,39 @@ function tap(e: any) {
95
95
  charts.value?.touchLegend(e);
96
96
  charts.value?.showToolTip(e);
97
97
  }
98
+
99
+ const thas = ref<ComponentPublicInstance | null>();
100
+ async function getImage() {
101
+ if (props.canvas2d == false) {
102
+ return new Promise(resolve => {
103
+ uni.canvasToTempFilePath(
104
+ {
105
+ canvasId: canvasId.value,
106
+ success: res => {
107
+ resolve(res.tempFilePath);
108
+ },
109
+ },
110
+ thas.value
111
+ );
112
+ });
113
+ } else {
114
+ return new Promise(resolve => {
115
+ const query = uni.createSelectorQuery().in(thas.value);
116
+ query
117
+ .select('#' + canvasId.value)
118
+ .fields({ node: true, size: true })
119
+ .exec(res => {
120
+ if (res[0]) {
121
+ const canvas = res[0].node;
122
+ resolve(canvas.toDataURL('image/png'));
123
+ }
124
+ });
125
+ });
126
+ }
127
+ }
128
+ defineExpose({
129
+ getImage,
130
+ });
98
131
  </script>
99
132
 
100
133
  <style scoped></style>
@@ -113,6 +113,23 @@
113
113
  </script>
114
114
  ```
115
115
 
116
+ ## 事件
117
+
118
+ - 属性`getImage`: 通过ref来获取实例的base64格式的图片地址,异步方法,需在实例生成后调用。
119
+
120
+ ```html
121
+ <template>
122
+ <ste-line-chart :series="series" :categories="categories" ref="lineChart"></ste-line-chart>
123
+ </template>
124
+ <script setup lang="ts">
125
+ import { ref,onMounted } from 'vue';
126
+ let lineChart: any = ref(null);
127
+ onMounted(async () => {
128
+ const base64 = await lineChart.value.getImage()
129
+ }),
130
+ </script>
131
+ ```
132
+
116
133
  ---$
117
134
 
118
135
  <!-- props -->
@@ -7,7 +7,7 @@
7
7
  <script setup lang="ts">
8
8
  import uCharts from '../../Charts/Charts';
9
9
  let uChartsInstance: { [key: string]: any } = {};
10
- import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance } from 'vue';
10
+ import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance, type ComponentPublicInstance } from 'vue';
11
11
  import utils from '../../utils/utils';
12
12
  import { propsData, propsComponent } from './props';
13
13
  import type { ChartsOptions } from '../../Charts/types/index';
@@ -98,6 +98,39 @@ function tap(e: any) {
98
98
  charts.value?.touchLegend(e);
99
99
  charts.value?.showToolTip(e);
100
100
  }
101
+
102
+ const thas = ref<ComponentPublicInstance | null>();
103
+ async function getImage() {
104
+ if (props.canvas2d == false) {
105
+ return new Promise(resolve => {
106
+ uni.canvasToTempFilePath(
107
+ {
108
+ canvasId: canvasId.value,
109
+ success: res => {
110
+ resolve(res.tempFilePath);
111
+ },
112
+ },
113
+ thas.value
114
+ );
115
+ });
116
+ } else {
117
+ return new Promise(resolve => {
118
+ const query = uni.createSelectorQuery().in(thas.value);
119
+ query
120
+ .select('#' + canvasId.value)
121
+ .fields({ node: true, size: true })
122
+ .exec(res => {
123
+ if (res[0]) {
124
+ const canvas = res[0].node;
125
+ resolve(canvas.toDataURL('image/png'));
126
+ }
127
+ });
128
+ });
129
+ }
130
+ }
131
+ defineExpose({
132
+ getImage,
133
+ });
101
134
  </script>
102
135
 
103
136
  <style scoped></style>
@@ -81,6 +81,23 @@
81
81
  </script>
82
82
  ```
83
83
 
84
+ ## 事件
85
+
86
+ - 属性`getImage`: 通过ref来获取实例的base64格式的图片地址,异步方法,需在实例生成后调用。
87
+
88
+ ```html
89
+ <template>
90
+ <ste-pie-chart :series="series1" width="420" height="420" :enableScroll="false" ref="pieChart"></ste-pie-chart>
91
+ </template>
92
+ <script setup lang="ts">
93
+ import { ref,onMounted } from 'vue';
94
+ let pieChart: any = ref(null);
95
+ onMounted(async () => {
96
+ const base64 = await pieChart.value.getImage()
97
+ }),
98
+ </script>
99
+ ```
100
+
84
101
  ---$
85
102
 
86
103
  <!-- props -->
@@ -6,7 +6,7 @@
6
6
 
7
7
  <script setup lang="ts">
8
8
  import uCharts from '../../Charts/Charts';
9
- import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance } from 'vue';
9
+ import { ref, onMounted, computed, type CSSProperties, watch, getCurrentInstance, type ComponentPublicInstance } from 'vue';
10
10
  import utils from '../../utils/utils';
11
11
  import { propsData, propsComponent } from './props';
12
12
  import type { ChartsOptions, ChartsSerie } from '../../Charts/types/index';
@@ -97,6 +97,39 @@ function tap(e: any) {
97
97
  charts.value?.touchLegend(e);
98
98
  charts.value?.showToolTip(e);
99
99
  }
100
+
101
+ const thas = ref<ComponentPublicInstance | null>();
102
+ async function getImage() {
103
+ if (props.canvas2d == false) {
104
+ return new Promise(resolve => {
105
+ uni.canvasToTempFilePath(
106
+ {
107
+ canvasId: canvasId.value,
108
+ success: res => {
109
+ resolve(res.tempFilePath);
110
+ },
111
+ },
112
+ thas.value
113
+ );
114
+ });
115
+ } else {
116
+ return new Promise(resolve => {
117
+ const query = uni.createSelectorQuery().in(thas.value);
118
+ query
119
+ .select('#' + canvasId.value)
120
+ .fields({ node: true, size: true })
121
+ .exec(res => {
122
+ if (res[0]) {
123
+ const canvas = res[0].node;
124
+ resolve(canvas.toDataURL('image/png'));
125
+ }
126
+ });
127
+ });
128
+ }
129
+ }
130
+ defineExpose({
131
+ getImage,
132
+ });
100
133
  </script>
101
134
 
102
135
  <style scoped></style>
@@ -44,8 +44,11 @@ const chartStyle = computed(() => {
44
44
  return style;
45
45
  });
46
46
 
47
+ const thas = ref<ComponentPublicInstance | null>();
48
+
47
49
  onMounted(() => {
48
50
  ctx.value = uni.createCanvasContext(canvasId.value, getCurrentInstance());
51
+ thas.value = getCurrentInstance()?.proxy;
49
52
  drawCharts(props.series);
50
53
  });
51
54
 
@@ -95,20 +98,15 @@ function tap(e: any) {
95
98
  charts?.value.touchLegend(e);
96
99
  charts?.value.showToolTip(e);
97
100
  }
98
- const thas = ref<ComponentPublicInstance | null>();
99
- const emits = defineEmits<{
100
- (e: 'getImage'): String;
101
- }>();
102
101
 
103
102
  async function getImage() {
104
- console.log('getImage', props.canvas2d);
105
103
  if (props.canvas2d == false) {
106
104
  return new Promise(resolve => {
107
105
  uni.canvasToTempFilePath(
108
106
  {
109
107
  canvasId: canvasId.value,
110
108
  success: res => {
111
- resolve(emits('getImage', res.tempFilePath));
109
+ resolve(res.tempFilePath);
112
110
  },
113
111
  },
114
112
  thas.value
@@ -121,10 +119,8 @@ async function getImage() {
121
119
  .select('#' + canvasId.value)
122
120
  .fields({ node: true, size: true })
123
121
  .exec(res => {
124
- console.log('res[0]', res[0].node.toDataURL('image/png'));
125
122
  if (res[0]) {
126
123
  const canvas = res[0].node;
127
- emits('getImage', canvas.toDataURL('image/png'));
128
124
  resolve(canvas.toDataURL('image/png'));
129
125
  }
130
126
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stellar-ui-plus",
3
- "version": "1.25.2",
3
+ "version": "1.25.4",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",