From 91fbe6ea41b0451a17aa1f6654faa9806b7f1817 Mon Sep 17 00:00:00 2001
From: wujingjing <gersonwu@qq.com>
Date: 星期二, 12 十一月 2024 16:14:26 +0800
Subject: [PATCH] 猜你想问

---
 src/components/chat/chatComponents/common.ts |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 112 insertions(+), 5 deletions(-)

diff --git a/src/components/chat/chatComponents/common.ts b/src/components/chat/chatComponents/common.ts
index 3e3d48b..95ed285 100644
--- a/src/components/chat/chatComponents/common.ts
+++ b/src/components/chat/chatComponents/common.ts
@@ -1,8 +1,21 @@
-export const timeDataOptionToContent = (opt) => {
+import type * as echarts from 'echarts';
+import { buildProps } from 'element-plus/es/utils/vue/props/runtime';
+import _ from 'lodash';
+import type { ExtractPropTypes, PropType } from 'vue';
+import { axisLabelFormatter } from '/@/utils/chart';
 
-	const headerList = [opt.xAxis[0]].concat(opt.yAxis).map((item) => `<td>${item.name}</td>`).join('');
+export const timeDataOptionToContent = (opt) => {
+	const headerList = [opt.xAxis[0]]
+		.concat(opt.yAxis)
+		.map((item) => `<td>${item.name}</td>`)
+		.join('');
 	const title = opt.title?.[0]?.text ?? '';
-	let table = '<div style="border:1px solid black"><h3>'+title+'</h3><table style="width:100%;text-align:center"><tbody><tr>' + headerList + '</tr>';
+	let table =
+		'<div style="border:1px solid black"><h3>' +
+		title +
+		'</h3><table style="width:100%;text-align:center"><tbody><tr>' +
+		headerList +
+		'</tr>';
 	const timeData = new Set();
 	const dataMap = opt.series.map((item) => {
 		for (const subItem of item.data) {
@@ -15,11 +28,105 @@
 			return (a as any).localeCompare(b);
 		})
 		.map((item) => {
-		
 			return `<tr><td>${item}</td>${dataMap.map((itemMap) => `<td>${itemMap.get(item) ?? ''}</td>`)}</tr>`;
-		}).join('');
+		})
+		.join('');
 	table += bodyList;
 
 	table += '</tbody></table></div>';
 	return table;
 };
+
+export const PATH_ICON = {
+	scatter:
+		'path://M445.7 609.8c0 19.4 10.3 37.3 27.1 46.9 16.8 9.7 37.4 9.7 54.2 0 16.8-9.7 27.1-27.6 27.1-46.9 0-29.9-24.3-54.2-54.2-54.2s-54.2 24.3-54.2 54.2z m0 0M179.2 613.8c-42.2 0-76.5 34.3-76.5 76.5s34.3 76.5 76.5 76.5 76.5-34.3 76.5-76.5-34.3-76.5-76.5-76.5z m0 0M144.9 401.1c0 29 23.5 52.5 52.5 52.5s52.5-23.5 52.5-52.5-23.5-52.5-52.5-52.5-52.5 23.5-52.5 52.5z m0 0M598.7 404c0 42.2 34.3 76.5 76.5 76.5 42.3 0 76.5-34.3 76.5-76.5 0-42.3-34.3-76.5-76.5-76.5-42.3 0-76.5 34.3-76.5 76.5z m0 0M849.3 169.2c-42.2 0-76.5 34.3-76.5 76.5s34.3 76.5 76.5 76.5 76.5-34.3 76.5-76.5-34.3-76.5-76.5-76.5z m0 0M261.6 583.1c0 13.2 7.1 25.5 18.5 32.1 11.5 6.6 25.6 6.6 37.1 0s18.5-18.9 18.5-32.1c0-20.5-16.6-37.1-37.1-37.1-20.4 0.1-37 16.7-37 37.1z m0 0M276.8 425.1c0 42.3 34.3 76.5 76.5 76.5 42.3 0 76.5-34.3 76.5-76.5s-34.3-76.5-76.5-76.5-76.5 34.3-76.5 76.5z m0 0M445.7 421.4c0 18.5 9.9 35.5 25.8 44.8 16 9.2 35.7 9.2 51.7 0s25.8-26.3 25.8-44.8c0-28.5-23.1-51.7-51.7-51.7-28.5 0-51.6 23.2-51.6 51.7z m0 0M398.2 208.8c0 42.3 34.3 76.5 76.5 76.5s76.5-34.3 76.5-76.5c0-42.3-34.3-76.5-76.5-76.5s-76.5 34.3-76.5 76.5z m0 0M693.7 599.2c0 42.3 34.3 76.5 76.5 76.5s76.5-34.3 76.5-76.5-34.3-76.5-76.5-76.5c-42.3 0-76.5 34.3-76.5 76.5z m0 0M62.1 828.9H959v60.7H62.1z',
+	bar: 'path://M580.8 228.8h-136v500.8h136V228.8z m-40 460.8h-56V268.8h56v420.8zM788.8 420.8h-136v308.8h136V420.8z m-40 268.8h-56V460.8h56v228.8zM372.8 326.4h-136v401.6h136V326.4z m-40 363.2h-56V366.4h56v323.2zM208 788.8h608v40H208z',
+	pie: 'path://M512 938.666667C276.352 938.666667 85.333333 747.648 85.333333 512a426.666667 426.666667 0 0 1 245.418667-386.346667l11.264-5.12a42.368 42.368 0 0 1 36.053333 76.672l-34.261333 17.749334A341.504 341.504 0 0 0 512 853.333333a341.504 341.504 0 0 0 295.552-170.453333l5.888-10.581333a42.666667 42.666667 0 0 1 75.648 39.381333l-3.754667 7.04A426.538667 426.538667 0 0 1 512 938.666667z m384-384h-341.333333a85.333333 85.333333 0 0 1-85.333334-85.333334V128a42.666667 42.666667 0 0 1 42.666667-42.666667c235.648 0 426.666667 191.018667 426.666667 426.666667a42.666667 42.666667 0 0 1-42.666667 42.666667z m-341.333333-358.272V426.666667a42.666667 42.666667 0 0 0 42.666666 42.666666h235.605334a15.232 15.232 0 0 0 15.018666-17.92 341.546667 341.546667 0 0 0-269.824-274.346666 19.626667 19.626667 0 0 0-23.466666 19.328z',
+
+	line: 'path://M664.1 783c-3.8 0-7.6-0.2-11.3-0.5-36.3-3.1-68.9-20.6-96.9-52.1-28.4-32-52.5-79.4-71.4-140.8-32.4-105-66.1-182.6-100.3-230.6-25.5-35.8-50.2-54-73.4-54h-0.4c-38.8 0.4-84.8 51-129.3 142.7-37 76.2-59.4 153-59.7 153.8L64 582.6c1-3.4 24.3-83.1 63.7-164.3 56.8-117 118.1-176.6 182.1-177.3h1c43 0 83.8 26.7 121.2 79.3 38.2 53.7 75.1 137.5 109.5 249.3 29.3 94.9 68.3 145.1 116 149.1 21.3 1.8 45.6-5.2 72.2-20.9 24.5-14.4 50.3-35.8 76.8-63.5 49.6-51.9 87.7-111.9 100.1-137.6L960 526c-14.6 30.4-56.4 96.4-111.4 154-30.4 31.8-60.6 56.6-89.9 73.9-32.8 19.3-64.6 29.1-94.6 29.1z',
+};
+
+export const SCATTER_SYMBOL_SIZE = 4;
+
+export const chatComProps = buildProps({
+	data: {
+		type: Object as PropType<any>,
+	},
+	originData: {
+		type: Object as PropType<any>,
+	},
+	conclusion:{
+		type:Array as PropType<Array<any>>
+	},
+	isTalking:{
+		type:Boolean
+	}
+} as const);
+export type ChatComPropsType = ExtractPropTypes<typeof chatComProps>;
+
+export const getChatChartOption = () => {
+	const option = {
+		grid: {
+			// bottom: 120,
+			// right: '15%',
+			top: 65,
+			left: 65,
+			right: 45,
+		},
+		tooltip: {
+			show: true,
+			trigger: 'axis',
+		},
+		toolbox: {
+			show: true,
+			feature: {
+				dataZoom: {
+					yAxisIndex: 'none',
+				},
+
+				myBar: {
+					title: '杞寲涓烘煴鐘跺浘',
+					show: true,
+					icon: PATH_ICON.bar,
+				},
+
+				myScatter: {
+					title: '杞寲涓烘暎鐐瑰浘',
+					show: true,
+					icon: PATH_ICON.scatter,
+				},
+				myLine: {
+					title: '杞寲涓烘洸绾垮浘',
+					show: true,
+					icon: PATH_ICON.line,
+				},
+				// dataView: {
+				// 	readOnly: true,
+				// 	optionToContent: timeDataOptionToContent,
+				// },
+				saveAsImage: {},
+			},
+		},
+
+		title: {
+			left: 'center',
+			textStyle: {
+				fontSize: 14,
+			},
+		},
+		xAxis: {
+			type: 'time',
+		},
+		yAxis: {
+			type: 'value',
+			axisLabel: {
+				formatter: axisLabelFormatter,
+			},
+		},
+		dataZoom: {
+			type: 'inside',
+		},
+	} as echarts.EChartsOption;
+
+	return _.cloneDeep(option);
+};

--
Gitblit v1.9.3