1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
| <template>
| <el-tabs v-model="activeName" class="demo-tabs min-w-[38rem] flex-column">
| <el-tab-pane class="h-full" label="Chart" name="first">
| <div class="flex-auto" v-resize="chartContainerResize">
| <div ref="chartRef" class="h-full"></div>
| </div>
| </el-tab-pane>
| <el-tab-pane class="h-full" label="Data" name="second">
| <el-table :data="data.values" style="width: 100%" cellClassName="text-sm" headerCellClassName="text-sm">
| <el-table-column v-for="(item, index) in data?.names" :label="item" :key="index">
| <template #default="scope">
| {{ scope.row[index] }}
| </template>
| </el-table-column>
| </el-table>
| </el-tab-pane>
| </el-tabs>
| </template>
| <script lang="ts" setup>
| import type * as echarts from 'echarts';
| import _ from 'lodash';
| import { ref } from 'vue';
| import { SCATTER_SYMBOL_SIZE, chatComProps, getChatChartOption } from '../common';
| import { useDrawChatChart } from '../hooks/useDrawChatChart';
| const activeName = ref('first');
| const chartRef = ref<HTMLDivElement>(null);
|
| const defaultChartType = 'line';
| const props = defineProps(chatComProps);
|
| const drawChart = () => {
| chartInstance.value.setOption(
| _.defaultsDeep(getChatChartOption(), {
| grid: {
| bottom: '5%',
| },
|
| toolbox: {
| feature: {
| myBar: {
| onclick: () => {
| chartInstance.value.setOption({
| series: {
| data: props.data.values,
| type: 'bar',
| symbol: 'none',
| },
| });
| },
| },
|
| myScatter: {
| onclick: () => {
| chartInstance.value.setOption({
| data: props.data.values,
| type: 'scatter',
| symbol: 'circle',
| symbolSize: SCATTER_SYMBOL_SIZE,
| });
| },
| },
| myLine: {
| onclick: () => {
| chartInstance.value.setOption({
| data: props.data.values,
| type: 'line',
| symbol: 'none',
| smooth: true,
| });
| },
| },
| },
| },
|
| title: {
| text: props.data.title,
| },
| xAxis: {
| name: props.data?.names[0],
| },
| yAxis: {
| name: props.data?.names[1],
| },
| series: [
| {
| data: props.data.values,
| symbol: 'none',
| smooth: true,
| type: defaultChartType,
| },
| ],
| } as echarts.EChartsOption)
| );
| };
| const { chartContainerResize, chartInstance } = useDrawChatChart({ chartRef, drawChart });
| </script>
|
| <style scoped lang="scss">
| .el-tabs {
| :deep(.el-tabs__header) {
| flex: 0 0 auto;
| }
| :deep(.el-tabs__content) {
| flex: 1;
| .el-tab-pane {
| display: flex;
| flex-direction: column;
| min-height: 24rem;
| }
| }
| }
| </style>
|
|