浏览代码

fix: ETA2.4.2面积图展示

ldong 2 月之前
父节点
当前提交
1d861c82ea
共有 1 个文件被更改,包括 36 次插入10 次删除
  1. 36 10
      src/views/hzyb/hooks/chartRender.js

+ 36 - 10
src/views/hzyb/hooks/chartRender.js

@@ -691,6 +691,7 @@ function setStackOrCombinChart(e) {
   let series=[]
   let yAxis=[]
   let xAxis = {}
+  let ExtraConfig={}
 
   let temYLeftArr=[]
   let temYRightArr=[]
@@ -700,6 +701,9 @@ function setStackOrCombinChart(e) {
 
   //有右二轴时排个序 按照左 右 右2的顺序
   let newData = data.some(_ =>_.IsAxis===2) ? changeEdbOrder(data) : data;
+  if(e.ChartInfo.ChartType===3 && e.ChartInfo.ExtraConfig){
+    ExtraConfig=JSON.parse(e.ChartInfo.ExtraConfig)
+  }
 
   newData.forEach((item,index)=>{
 
@@ -708,7 +712,7 @@ function setStackOrCombinChart(e) {
 
       //堆叠图的yAxis必须一致 数据列所对应的y轴
       let serie_yIndex = index;
-      if([3,4].includes(e.ChartInfo.ChartType)) {
+      if([4].includes(e.ChartInfo.ChartType) || (e.ChartInfo.ChartType ===3 && ExtraConfig.IsHeap==1)) {
           // 类型为堆叠图时公用第一个指标y轴 
           serie_yIndex =  0;
       } else if(e.ChartInfo.ChartType ===6 && ['areaspline','column'].includes(item.ChartStyle)) {
@@ -719,13 +723,13 @@ function setStackOrCombinChart(e) {
       item.IsAxis = serie_yIndex === index ? item.IsAxis : newData[serie_yIndex].IsAxis;
       item.IsOrder = serie_yIndex === index ? item.IsOrder : newData[serie_yIndex].IsOrder;
 
-      temYLeftIndex = [3,4].includes(e.ChartInfo.ChartType) 
+      temYLeftIndex = [4].includes(e.ChartInfo.ChartType) 
           ? (newData[serie_yIndex].IsAxis ? serie_yIndex : -1)
           : data.findIndex((item) => item.IsAxis===1);
-      temYRightIndex = [3,4].includes(e.ChartInfo.ChartType) 
+      temYRightIndex = [4].includes(e.ChartInfo.ChartType) 
           ? (newData[serie_yIndex].IsAxis ? -1 : serie_yIndex)
           : data.findIndex((item) => !item.IsAxis);
-      temYRightTwoIndex = [3,4].includes(e.ChartInfo.ChartType) 
+      temYRightTwoIndex = [4].includes(e.ChartInfo.ChartType) 
           ? -1
           : data.findIndex((item) => item.IsAxis===2);
 
@@ -756,7 +760,8 @@ function setStackOrCombinChart(e) {
           LatestDate:item.LatestDate,
           LatestValue:item.LatestValue,
           ...predict_params,
-          stacking:e.ChartInfo.ChartType==6&&!e.DataResp.IsHeap?undefined:'normal',
+          stacking:e.ChartInfo.ChartType==6?!e.DataResp.IsHeap?undefined:'normal':e.ChartInfo.ChartType==3&&ExtraConfig.IsHeap==1?ExtraConfig.HeapWay==1?'normal':'percent':undefined,
+          threshold: e.ChartInfo.ChartType==3?item.ChartScale?Number(item.ChartScale):0:null
       }
       item.DataList = item.DataList || [];
       for (let i of item.DataList) {
@@ -787,8 +792,8 @@ function setStackOrCombinChart(e) {
           ...basicYAxis,
           IsAxis:item.IsAxis,
           labels: {
-              formatter: function (ctx) {
-                  return sameSideIndex !== index ? '' : ctx.value;
+              formatter:  (ctx) =>{
+                  return sameSideIndex !== index ? '' : e.ChartInfo.ChartType===3&&ExtraConfig.HeapWay==2?ctx.value+'%':ctx.value;
               },
               align: 'center',
               x: [0,2].includes(item.IsAxis) ? 5 : -5,
@@ -810,8 +815,8 @@ function setStackOrCombinChart(e) {
           },
           opposite: [0,2].includes(item.IsAxis),
           reversed: item.IsOrder,
-          min: Number(minLimit),
-          max: Number(maxLimit),
+          min: e.ChartInfo.ChartType===3&&ExtraConfig.HeapWay==2?null:Number(minLimit),
+          max: e.ChartInfo.ChartType===3&&ExtraConfig.HeapWay==2?null:Number(maxLimit),
           tickWidth: sameSideIndex !== index ? 0 : 1,
           visible: serie_yIndex === index && sameSideIndex ===index,
           chartEdbInfo:item,//指标数据用于在保存时读取指标数据
@@ -863,12 +868,33 @@ function setStackOrCombinChart(e) {
       }
   })
 
-  return {
+  let options={
     xAxis: [xAxis],
     yAxis,
     series,
     rangeSelector:{ enabled: false}
   }
+
+  //面积图百分比tooltip
+  if(e.ChartInfo.ChartType===3&&ExtraConfig.HeapWay == 2) {
+    //悬浮提示框
+	options.tooltip={
+		split: false,
+		shared: true,
+		dateTimeLabelFormats: {
+			// 时间格式化字符
+			day: '%Y/%m/%d',
+			week: "%Y/%m",
+			month: '%Y/%m',
+			year: '%Y/%m',
+		},
+		xDateFormat:'%Y/%m/%d',
+		className:'chart-tooltips-box',
+		pointFormat: '<span style=\"color:{point.color}\">●</span><span>{series.name}</span>' +':<b>{point.percentage:.1f}%</b> ({point.y:,.1f})<br/>'
+	}
+  }
+
+  return options
 }