From 2dfbc988ad38d42a03516d2ac6d067b95e35464d Mon Sep 17 00:00:00 2001 From: BianLzhaoMin <11485688+bianliangzhaomin123@user.noreply.gitee.com> Date: Wed, 23 Jul 2025 22:16:11 +0800 Subject: [PATCH] =?UTF-8?q?echarts=20=E6=8E=A5=E5=8F=A3=E8=B0=83=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- js/pages/newDataAnalysis/projectProgress.js | 74 ++++++++++++++++++--- pages/newDataAnalysis/projectProgress.html | 4 +- 2 files changed, 67 insertions(+), 11 deletions(-) diff --git a/js/pages/newDataAnalysis/projectProgress.js b/js/pages/newDataAnalysis/projectProgress.js index ebeb691..95facdc 100644 --- a/js/pages/newDataAnalysis/projectProgress.js +++ b/js/pages/newDataAnalysis/projectProgress.js @@ -1,6 +1,11 @@ let table, layer, form; let currentType = 1; let currentBidCode = ""; +let xData = []; +let yData_1 = []; +let yData_2 = []; +let pieData = []; +let pieData_1 = []; // 将setCols函数提取到外部,使其可以被全局访问 function setCols(type) { @@ -181,7 +186,7 @@ function initLineChart() { xAxis: { type: "category", boundaryGap: false, - data: ["一月", "二月", "三月", "四月", "五月", "六月"], + data: xData, }, yAxis: { type: "value", @@ -190,7 +195,7 @@ function initLineChart() { { name: "计划进度", type: "line", - data: [120, 132, 101, 134, 90, 230], + data: yData_1, smooth: false, lineStyle: { color: "#5470C6", @@ -203,7 +208,7 @@ function initLineChart() { { name: "实际进度", type: "line", - data: [100, 120, 90, 110, 80, 150], + data: yData_2, smooth: false, lineStyle: { color: "#FF0000", // 红色 @@ -239,7 +244,7 @@ function initPieChart() { }, tooltip: { trigger: "item", - formatter: "{a} {b}: {c} ({d}%)", + formatter: "{a} {b}: {c} ", }, legend: { orient: "vertical", // 垂直排列 @@ -270,27 +275,27 @@ function initPieChart() { }, data: [ { - value: 335, + value: pieData_1[0], name: "大气影响", itemStyle: { color: "#67C23A" }, }, { - value: 210, + value: pieData_1[1], name: "设备判断延迟", itemStyle: { color: "#409EFF" }, }, { - value: 154, + value: pieData_1[2], name: "人员不足", itemStyle: { color: "#E6A23C" }, }, { - value: 154, + value: pieData_1[3], name: "设计变更", itemStyle: { color: "#909399" }, }, { - value: 154, + value: pieData_1[4], name: "其他", itemStyle: { color: "#F56C6C" }, }, @@ -313,3 +318,54 @@ function initPieChart() { rightChart.resize(); }); } + +// 获取图表数据 +function getChartData() { + const url = + commonUrl + "screen/largeScreen/tb_project_progress_new/list4chart"; + $.ajax({ + url: url, + type: "get", + headers: { + authorization: sessionStorage.getItem("zhgd_token"), + }, + success: function (data) { + console.log(data, "图表数据1===折线图"); + + if (data.rows && data.rows.length > 0) { + // initPieChart(data.rows); + + const result = data.rows; + + result.forEach((item) => { + xData.push(item.month); + yData_1.push(item.monthValue || 0); + yData_2.push(item.monthValue2 || 0); + }); + } + }, + }); + const url2 = + commonUrl + "screen/largeScreen//tb_project_progress_new/list4bing"; + $.ajax({ + url: url2, + type: "get", + headers: { + authorization: sessionStorage.getItem("zhgd_token"), + }, + success: function (data) { + console.log(data, "图表数据2===饼图"); + + if (data.rows && data.rows.length > 0) { + const result = data.rows; + + result.forEach((item) => { + pieData.push(item.category); + pieData_1.push(item.monthValue || 0); + }); + } + }, + }); +} + +getChartData(); diff --git a/pages/newDataAnalysis/projectProgress.html b/pages/newDataAnalysis/projectProgress.html index 414a63a..f08b78d 100644 --- a/pages/newDataAnalysis/projectProgress.html +++ b/pages/newDataAnalysis/projectProgress.html @@ -41,10 +41,10 @@
- 左侧折线图 +
- 右侧饼图 +