Ver Fonte

2022-12-16 update

1. 调整rateAnalysis scatterSingleChart组件 调用接口数据
2. 修复htmlToPdf 的scroll函数中 对添加image定位不正确的问题
moccus há 3 anos atrás
pai
commit
d73cba0ada

+ 13 - 14
src/pages/dataAnalysis/rateAnalysis/components/scatterSingleChart.vue

@@ -49,15 +49,15 @@ const option = computed({
 		return {
 			tooltip: {
 				position: 'top',
-				formatter: function (params) {
-					return (
-						params.value[2] +
-						' commits in ' +
-						params.value[0] +
-						' of ' +
-						params.value[1]
-					);
-				}
+				// formatter: function (params) {
+				// 	return (
+				// 		params.value[2] +
+				// 		' commits in ' +
+				// 		params.value[0] +
+				// 		' of ' +
+				// 		params.value[1]
+				// 	);
+				// }
 			},
 			title: {
 				text: props.title || '',
@@ -66,11 +66,10 @@ const option = computed({
 				left: '5%',
 			},
 			grid: {
-				top: 40,
-				left: 2,
-				bottom: 10,
-				right: 20,
-				containLabel: true
+				top: 80,
+				left: 40,
+				right: 40,
+				bottom: 40,
 			},
 			xAxis: props.xAxis || [],
 			//  {

+ 51 - 49
src/pages/dataAnalysis/rateAnalysis/index.vue

@@ -226,6 +226,9 @@ const funSubmit = async () => {
 							}]: []
 				})
 				chartId++
+				scatterSeries.value[0].data = chart.frequency?.length? chart.frequency.map((item) => {
+						return [item[1]+'', item[0]+'', (item[2]*10).toFixed(1)];
+				}) : []
 			}
 		}
 	}
@@ -378,15 +381,12 @@ const scatteryData = ref([
 const scatterSeries = ref(
 	[
 				{
-					name: 'Punch Card',
+					name: '对风偏航',
 					type: 'scatter',
 					symbolSize: function (val) {
-						return val[2] * 2;
+						return val[2];
 					},
-					data: [[0, 0, 5], [0, 1, 1], [0, 2, 0], [0, 3, 0], [0, 4, 0], [0, 5, 0], [0, 6, 0], [0, 7, 0], [0, 8, 0], [0, 9, 0], [0, 10, 0], [0, 11, 2], [0, 12, 4], [0, 13, 1], [0, 14, 1], [0, 15, 3], [1, 0, 7], [1, 1, 0], [1, 2, 0], [1, 3, 0], [1, 4, 0], [1, 5, 0], [1, 6, 0], [1, 7, 0], [1, 8, 0], [1, 9, 0], [1, 10, 5], [1, 11, 2], [1, 12, 2], [1, 13, 6], [1, 14, 9], [1, 15, 11], [2, 0, 1], [2, 1, 1], [2, 2, 0], [2, 3, 0], [2, 4, 0], [2, 5, 0], [2, 6, 0], [2, 7, 0], [2, 8, 0], [2, 9, 0], [2, 10, 3], [2, 11, 2], [2, 12, 1], [2, 13, 9], [2, 14, 8], [2, 15, 10], [3, 0, 7], [3, 1, 3], [3, 2, 0], [3, 3, 0], [3, 4, 0], [3, 5, 0], [3, 6, 0], [3, 7, 0], [3, 8, 1], [3, 9, 0], [3, 10, 5], [3, 11, 4], [3, 12, 7], [3, 13, 14], [3, 14, 13], [3, 15, 12], [4, 0, 1], [4, 1, 3], [4, 2, 0], [4, 3, 0], [4, 4, 0], [4, 5, 1], [4, 6, 0], [4, 7, 0], [4, 8, 0], [4, 9, 2], [4, 10, 4], [4, 11, 4], [4, 12, 2], [4, 13, 4], [4, 14, 4], [4, 15, 14]]
-    .map(function (item) {
-    return [item[1]+'', item[0], item[2]];
-}),
+					data: [],
 					animationDelay: function (idx) {
 						return idx * 5;
 					}
@@ -474,7 +474,7 @@ const funDiaSubmit = async () => {
 			url = '/wind/deviation/ratio'
 			break
 		case 'scatterSingleChartCop':
-			url = '' //暂无接口
+			url = '/wind/roses'
 			break
 	}
 	if(url){
@@ -484,7 +484,6 @@ const funDiaSubmit = async () => {
 				mode: 0
 			}
 		})
-		console.log(res)
 		if(res.code===200){
 			actCopList.value = []
 			actCopListBak.value = [] //清空备份
@@ -530,23 +529,27 @@ const funDiaSubmit = async () => {
 							xAxis: {
 								type: 'category',
 								boundaryGap: false,
-								data: ['N','', 'N-E','', 'E','', 'S-E','', 'S','', 'S-W','', 'W','', 'W-N',''],
+								data: ['N','','','', 'N-E','','','', 'E','','','', 'S-E','','','', 'S','','','', 'S-W','','','', 'W','','','', 'W-N','','',''],
 								splitLine: {
 									show: true
 								}
 							},
 							series: chart.count?.length? [...chart.count.map((o,index) => {
-										return {
-											type: 'bar',
-											data: o,
-											coordinateSystem: 'polar',
-											name: funText(index),
-											stack: 'a',
-											emphasis: {
-												focus: 'series'
-											}
+									const dataArr = new Array(32).fill(0)
+									for(let i=0;i<o.length;i++){
+										dataArr[i*2] = o[i]
+									}
+									return {
+										type: 'bar',
+										data: dataArr,
+										coordinateSystem: 'polar',
+										name: funText(index),
+										stack: 'a',
+										emphasis: {
+											focus: 'series'
 										}
-									}), {
+									}
+								}), {
 								type: 'line',
 								coordinateSystem: 'polar',
 								tooltip: {
@@ -566,36 +569,8 @@ const funDiaSubmit = async () => {
 							actCop: shallowRef(lineChartCop),
 							title: chart.wtId,
 							subtext: '对风偏差分析图',
-							xAxis: {
-								type: 'category',
-								data: new Array(101).fill(-50).map((o,index) => Number((o + index).toFixed(1))),
-								splitLine: {
-									show: false
-								},
-								axisTick: {
-									show: true
-								}
-							},
-							yAxis: [
-								{
-									type: 'value',
-									name: 'm/s',
-									splitLine: {
-									show: false
-								},
-								axisTick: {
-									show: true
-								}
-								},{
-									type: 'value',
-									splitLine: {
-									show: false
-								},
-								axisTick: {
-									show: true
-								}
-								}
-							],
+							xAxis: linexAxis.value,
+							yAxis: lineyAxis.value,
 							dataset: [{
 								source: chart.scatter.map(o => {
 									return [o.x+'', o.y]
@@ -631,6 +606,33 @@ const funDiaSubmit = async () => {
 						})
 						chartId++
 					}
+					if(actChartName.value === 'scatterSingleChartCop'){
+						actCopList.value.push({
+							id: chartId,
+							isBrush: false,
+							actCop: shallowRef(scatterSingleChartCop),
+							title: chart.wt,
+							subtext: '静态偏航对风分析图',
+							xAxis: scatterxData.value,
+							yAxis: scatteryData.value,
+							series: [
+								{
+									name: '对风偏航',
+									type: 'scatter',
+									symbolSize: function (val) {
+										return val[2];
+									},
+									data: chart.frequency?.length? chart.frequency.map((item) => {
+											return [item[1]+'', item[0]+'', (item[2]*10).toFixed(1)];
+									}) : [],
+									animationDelay: function (idx) {
+										return idx * 5;
+									}
+								}
+							]
+						})
+						chartId++
+					}
 				}
 				actCopListBak.value = actCopList.value
 			}

+ 5 - 1
src/tools/htmlToPdf.js

@@ -119,7 +119,11 @@ const scrollToPDF = (ele, pdfName, call = () => {}) => {
                     pdf.addPage()
                     addPos = 0  // 填充下一页后, 设置当前元素填充位置为 新页的top为0
                 }else{
-                    addPos = pageHeight // 如果不大于页面高度  则当前元素填充位置为一个元素高度
+                    if(position<pageHeight){  //如果剩余position小于一个pageHeight 则addPos等于pageHeight
+                        addPos = pageHeight
+                    }else{
+                        addPos = position
+                    }
                 }
             }
             pdf.addImage(pageData, 'JPEG', 0, addPos, 592.28, pageHeight)