From 6f604e6e228dc33ff88b55190c0e3793177d21ce Mon Sep 17 00:00:00 2001 From: ali <ali9696@163.com> Date: 星期五, 28 二月 2025 11:41:14 +0800 Subject: [PATCH] basecard&linechart --- zhitan-vue/src/components/Echarts/LineChart.vue | 15 +++++++++++---- 1 files changed, 11 insertions(+), 4 deletions(-) diff --git a/zhitan-vue/src/components/Echarts/LineChart.vue b/zhitan-vue/src/components/Echarts/LineChart.vue index 3294c0c..ef9af8b 100644 --- a/zhitan-vue/src/components/Echarts/LineChart.vue +++ b/zhitan-vue/src/components/Echarts/LineChart.vue @@ -1,6 +1,6 @@ <template> <div class="chart-item"> - <div id="ChartDom" style="width: 100%; height: 100%"></div> + <div :id="domId" style="width: 100%; height: 100%"></div> </div> </template> @@ -18,6 +18,10 @@ chartType: { type: String, default: "line", // bar + }, + domId: { + type: String, + default: "ChartDom", }, }) @@ -44,22 +48,24 @@ if (!props.chartData.xAxis) { return } - const chartDom = document.getElementById("ChartDom") + const chartDom = document.getElementById(props.domId) if (echarts.getInstanceByDom(chartDom)) { echarts.dispose(chartDom) } const myChart = echarts.init(chartDom) // 澶勭悊澶氱郴鍒楁暟鎹� const series = props.chartData.series.map((item) => ({ + ...item, name: item.name, type: props.chartType, // 鏍规嵁浼犲叆绫诲瀷娓叉煋 data: item.data, - barWidth: "16", + barWidth: props.chartData.barWidth || "16", itemStyle: { borderRadius: [15, 15, 0, 0], }, smooth: true, // 鍚敤骞虫粦鏇茬嚎 })) + console.log("initChart", series) let option = { title: { // text: props.chartData.title, @@ -68,7 +74,8 @@ color: "#2979ff", }, }, - color: ["#2979ff", "#19be6b", "#ff9900", "#fa3534"], + color: ["#4dadf8", "#19be6b", "#ff9900", "#3d8a32", "#e8463a", "#ff4e3f"], + // color: ["#2979ff", "#19be6b", "#ff9900", "#fa3534"], tooltip: { trigger: "axis", axisPointer: { -- Gitblit v1.9.3