|
@@ -31,6 +31,9 @@ const basicYAxis = {
|
|
|
export default {
|
|
|
data() {
|
|
|
return {
|
|
|
+ leftLimitData:[0,0],//左轴上下限
|
|
|
+ rightLimitData:[0,0],//右轴上下限
|
|
|
+ rightTwoLimitData:[0,0],//右二轴上下限
|
|
|
bgList:[
|
|
|
{image_url:require('@/assets/img/ppt_m/bg3.jpg')},
|
|
|
{image_url:require('@/assets/img/ppt_m/bg4.jpg')},
|
|
@@ -115,6 +118,15 @@ export default {
|
|
|
chartData.forEach((item, index) => {
|
|
|
//轴位置值相同的下标
|
|
|
let sameSideIndex = chartData.findIndex(i => i.IsAxis === item.IsAxis);
|
|
|
+ //获取对应轴的上下限
|
|
|
+ let minLimit = 0,maxLimit = 0
|
|
|
+ const limitMap = {
|
|
|
+ 0:this.rightLimitData||[],
|
|
|
+ 1:this.leftLimitData||[],
|
|
|
+ 2:this.rightTwoLimitData||[]
|
|
|
+ }
|
|
|
+ minLimit = limitMap[item.IsAxis][1]||0
|
|
|
+ maxLimit = limitMap[item.IsAxis][0]||0
|
|
|
//y轴
|
|
|
const textZh = item.ConvertUnit||item.Unit
|
|
|
const textEn = item.ConvertEnUnit||item.UnitEn||item.ConvertUnit||item.Unit
|
|
@@ -147,8 +159,8 @@ export default {
|
|
|
},
|
|
|
opposite: [0,2].includes(item.IsAxis),
|
|
|
reversed: item.IsOrder,
|
|
|
- min: Number(item.MinData),
|
|
|
- max: Number(item.MaxData),
|
|
|
+ min: Number(minLimit),
|
|
|
+ max: Number(maxLimit),
|
|
|
tickWidth: 1,
|
|
|
visible: sameSideIndex === index,
|
|
|
plotBands: this.setAxisPlotAreas(item.IsAxis),
|
|
@@ -278,6 +290,16 @@ export default {
|
|
|
? -1
|
|
|
: this.dataList.findIndex((item) => item.IsAxis===2);
|
|
|
|
|
|
+ //获取对应轴的上下限
|
|
|
+ let minLimit = 0,maxLimit = 0
|
|
|
+ const limitMap = {
|
|
|
+ 0:this.rightLimitData||[],
|
|
|
+ 1:this.leftLimitData||[],
|
|
|
+ 2:this.rightTwoLimitData||[]
|
|
|
+ }
|
|
|
+ minLimit = limitMap[item.IsAxis][1]||0
|
|
|
+ maxLimit = limitMap[item.IsAxis][0]||0
|
|
|
+
|
|
|
//y轴
|
|
|
let yItem = {
|
|
|
...basicYAxis,
|
|
@@ -308,8 +330,8 @@ export default {
|
|
|
},
|
|
|
opposite: [0,2].includes(item.IsAxis),
|
|
|
reversed: item.IsOrder,
|
|
|
- min: Number(chartData[sameSideIndex].MinData),
|
|
|
- max: Number(chartData[sameSideIndex].MaxData),
|
|
|
+ min: Number(minLimit),
|
|
|
+ max: Number(maxLimit),
|
|
|
tickWidth: sameSideIndex !== index ? 0 : 1,
|
|
|
visible: serie_yIndex === index && sameSideIndex ===index,
|
|
|
plotBands: this.setAxisPlotAreas(item.IsAxis),
|
|
@@ -402,6 +424,10 @@ export default {
|
|
|
let seasonYdata = [],
|
|
|
seasonData = []
|
|
|
|
|
|
+ //获取对应轴的上下限
|
|
|
+ let minLimit = 0,maxLimit = 0
|
|
|
+ minLimit = this.leftLimitData[1]||0
|
|
|
+ maxLimit = this.leftLimitData[0]||0
|
|
|
//数据列
|
|
|
for (let j of chartDataHandle) {
|
|
|
//预测指标配置
|
|
@@ -455,8 +481,8 @@ export default {
|
|
|
textAlign: 'left',
|
|
|
reserveSpace: false
|
|
|
},
|
|
|
- max: Number(chartData.MaxData),
|
|
|
- min: Number(chartData.MinData),
|
|
|
+ max: Number(maxLimit),
|
|
|
+ min: Number(minLimit),
|
|
|
plotBands: this.setAxisPlotAreas(1),
|
|
|
plotLines: this.setAxisPlotLines(1)
|
|
|
}];
|
|
@@ -560,6 +586,10 @@ export default {
|
|
|
}
|
|
|
|
|
|
const { IsOrder,ChartColor,MaxData,MinData } = chartData[0];
|
|
|
+ //获取对应轴的上下限
|
|
|
+ let minLimit = 0,maxLimit = 0
|
|
|
+ minLimit = this.leftLimitData[1]||0
|
|
|
+ maxLimit = this.leftLimitData[0]||0
|
|
|
//y轴
|
|
|
const textYZh = chartData[1].ConvertUnit||chartData[1].Unit
|
|
|
const textYEn = chartData[1].ConvertEnUnit||chartData[1].UnitEn||chartData[1].ConvertUnit||chartData[1].Unit
|
|
@@ -587,8 +617,8 @@ export default {
|
|
|
},
|
|
|
opposite: false,
|
|
|
reversed: IsOrder,
|
|
|
- min: Number(chartData[1].MinData),
|
|
|
- max: Number(chartData[1].MaxData),
|
|
|
+ min: Number(minLimit),
|
|
|
+ max: Number(maxLimit),
|
|
|
tickWidth: 1,
|
|
|
tickLength: 5,
|
|
|
lineWidth: 1,
|
|
@@ -1812,6 +1842,132 @@ export default {
|
|
|
})
|
|
|
|
|
|
return plotBands
|
|
|
- }
|
|
|
+ },
|
|
|
+ /* ----自定义上下限相关--- */
|
|
|
+ setLimitData(tableData=[]){
|
|
|
+ const {
|
|
|
+ //左右轴极值字段
|
|
|
+ LeftMin=0,LeftMax=0,
|
|
|
+ RightMin=0,RightMax=0,
|
|
|
+ Right2Min=0,Right2Max=0,
|
|
|
+ MinMaxSave
|
|
|
+ } = this.chartInfo
|
|
|
+ if(MinMaxSave){
|
|
|
+ this.leftLimitData = [Number(LeftMax),Number(LeftMin)]
|
|
|
+ this.rightLimitData = [Number(RightMax),Number(RightMin)]
|
|
|
+ this.rightTwoLimitData = [Number(Right2Max),Number(Right2Min)]
|
|
|
+ //若用户修改过,则检测轴的上下限是否为空,若为空,则需要计算对应轴的上下限
|
|
|
+ this.checkLimit(tableData)
|
|
|
+ }else{
|
|
|
+ this.calcYAxislimit(tableData)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkLimit(tableData=[]){
|
|
|
+ //散点图单独处理
|
|
|
+ if(this.chartInfo.ChartType===5){
|
|
|
+ if(tableData[1]){
|
|
|
+ if(Number(this.leftLimitData[0])===0&&Number(this.leftLimitData[1])===0){
|
|
|
+ this.leftLimitData = [tableData[1].MaxData,tableData[1].MinData]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //若轴的上下限均为0,则不管用户有没有修改过,都重新赋值
|
|
|
+ if(Number(this.leftLimitData[0])===0&&Number(this.leftLimitData[1])===0){
|
|
|
+ const leftData = tableData.filter(i=>i.IsAxis===1).map(i=>[Number(i.MinData),Number(i.MaxData)])
|
|
|
+ if(leftData.length){
|
|
|
+ const {Max,Min} = this.calcLimit(leftData.flat())
|
|
|
+ this.leftLimitData = [Max,Min]
|
|
|
+ }else{
|
|
|
+ this.leftLimitData = [0,0]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Number(this.rightLimitData[0])===0&&Number(this.rightLimitData[1])===0){
|
|
|
+ const rightData = tableData.filter(i => !i.IsAxis).map(i=>[Number(i.MinData),Number(i.MaxData)])
|
|
|
+ if(rightData.length){
|
|
|
+ const {Max,Min} = this.calcLimit(rightData.flat())
|
|
|
+ this.rightLimitData = [Max,Min]
|
|
|
+ }else{
|
|
|
+ this.rightLimitData = [0,0]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Number(this.rightTwoLimitData[0])===0&&Number(this.rightTwoLimitData[1])===0){
|
|
|
+ const rightTwoData = tableData.filter(i=>i.IsAxis===2).map(i=>[Number(i.MinData),Number(i.MaxData)])
|
|
|
+ if(rightTwoData.length){
|
|
|
+ const {Max,Min} = this.calcLimit(rightTwoData.flat())
|
|
|
+ this.rightTwoLimitData = [Max,Min]
|
|
|
+ }else{
|
|
|
+ this.rightTwoLimitData = [0,0]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /* 计算y轴上下限 */
|
|
|
+ calcYAxislimit(tableData=[]) {
|
|
|
+ //散点图单独处理
|
|
|
+ if(this.chartInfo.ChartType===5){
|
|
|
+ if(tableData[1]){
|
|
|
+ this.leftLimitData = [tableData[1].MaxData,tableData[1].MinData]
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ //分组
|
|
|
+ const leftData = tableData.filter(i => i.IsAxis === 1).map(i => [Number(i.MinData), Number(i.MaxData)])
|
|
|
+ const rightData = tableData.filter(i => !i.IsAxis).map(i => [Number(i.MinData), Number(i.MaxData)])
|
|
|
+ const rightTwoData = tableData.filter(i => i.IsAxis === 2).map(i => [Number(i.MinData), Number(i.MaxData)])
|
|
|
+ //计算最大最小值
|
|
|
+ if (leftData.length) {
|
|
|
+ const {
|
|
|
+ Max,
|
|
|
+ Min
|
|
|
+ } = this.calcLimit(leftData.flat())
|
|
|
+ this.leftLimitData = [Max, Min]
|
|
|
+ } else {
|
|
|
+ this.leftIndex = -1
|
|
|
+ this.leftLimitData = [0, 0]
|
|
|
+ }
|
|
|
+ if (rightData.length) {
|
|
|
+ const {
|
|
|
+ Max,
|
|
|
+ Min
|
|
|
+ } = this.calcLimit(rightData.flat())
|
|
|
+ this.rightLimitData = [Max, Min]
|
|
|
+ } else {
|
|
|
+ this.rightIndex = -1
|
|
|
+ this.rightLimitData = [0, 0]
|
|
|
+ }
|
|
|
+ if (rightTwoData.length) {
|
|
|
+ const {
|
|
|
+ Max,
|
|
|
+ Min
|
|
|
+ } = this.calcLimit(rightTwoData.flat())
|
|
|
+ this.rightTwoLimitData = [Max, Min]
|
|
|
+ } else {
|
|
|
+ this.rightTwoIndex = -1
|
|
|
+ this.rightTwoLimitData = [0, 0]
|
|
|
+ }
|
|
|
+ console.table([{
|
|
|
+ 'y轴': '左轴',
|
|
|
+ '最大值': this.leftLimitData[0],
|
|
|
+ '最小值': this.leftLimitData[1]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'y轴': '右轴',
|
|
|
+ '最大值': this.rightLimitData[0],
|
|
|
+ '最小值': this.rightLimitData[1]
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'y轴': '右二轴',
|
|
|
+ '最大值': this.rightTwoLimitData[0],
|
|
|
+ '最小值': this.rightTwoLimitData[1]
|
|
|
+ }
|
|
|
+ ])
|
|
|
+ },
|
|
|
+ calcLimit(arr) {
|
|
|
+ return {
|
|
|
+ Max: Math.max(...arr),
|
|
|
+ Min: Math.min(...arr)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /*-------------------- */
|
|
|
},
|
|
|
};
|