Ver Fonte

铺满整个图表

kagg886 há 1 mês atrás
pai
commit
779cfe418c

+ 0 - 2
src/components/assistant/ViewerCard.vue

@@ -31,8 +31,6 @@ watch(()=> props.card.w, () => {
 watch(()=> props.card.h, () => {
 	charts.value?.resize()
 })
-
-debugger
 </script>
 
 <template>

+ 17 - 1
src/components/markdown/plugins/impl/VueCharts.vue

@@ -23,13 +23,29 @@ const setOption = () => {
 		if (typeof prop.data === 'object') {
 			data = prop.data
 		} else {
-			data = JSON.parse(decodeURIComponent(prop.data))
+			try {
+				data = JSON.parse(decodeURIComponent(prop.data))
+			} catch {
+				data = JSON.parse(prop.data)
+			}
 		}
 
 	} catch (e) {
 		console.error(e)
 		return
 	}
+
+	data = {
+		...data,
+		"grid": {
+			"left": "3%",
+			"right": "4%",
+			"bottom": "3%",
+			"top": "3%",
+			"containLabel": true
+		},
+	}
+
 	instance = echarts.init(dom.value)
 	try {
 		instance.setOption(data)

+ 0 - 40
src/views/assistant/dashboard/edit.vue

@@ -103,44 +103,6 @@ const removeCard = (id: string) => {
 	}
 }
 
-// 上移卡片层级
-const moveCardUp = (id: string) => {
-	const card = cards.value.find((item) => item.id === id)
-	if (card) {
-		// 找到当前卡片上方最近的卡片
-		const upperCards = cards.value.filter((item) => item.z > card.z)
-		if (upperCards.length > 0) {
-			// 找到z值最小的上层卡片
-			const nearestUpperCard = upperCards.reduce((min, current) =>
-				current.z < min.z ? current : min
-			)
-			// 交换z值
-			const tempZ = card.z
-			card.z = nearestUpperCard.z
-			nearestUpperCard.z = tempZ
-		}
-	}
-}
-
-// 下移卡片层级
-const moveCardDown = (id: string) => {
-	const card = cards.value.find((item) => item.id === id)
-	if (card) {
-		// 找到当前卡片下方最近的卡片
-		const lowerCards = cards.value.filter((item) => item.z < card.z)
-		if (lowerCards.length > 0) {
-			// 找到z值最大的下层卡片
-			const nearestLowerCard = lowerCards.reduce((max, current) =>
-				current.z > max.z ? current : max
-			)
-			// 交换z值
-			const tempZ = card.z
-			card.z = nearestLowerCard.z
-			nearestLowerCard.z = tempZ
-		}
-	}
-}
-
 const chat = ref<LmSession[]>([])
 const currentSelectedChat = ref<number>()
 
@@ -494,8 +456,6 @@ onMounted( () => {
 					@update-content="updateCardContent"
 					@remove-card="removeCard"
 					@add-card="addCard"
-					@move-card-up="moveCardUp"
-					@move-card-down="moveCardDown"
 				/>
 			</div>