|
@@ -47,21 +47,17 @@ const axisLimitState = reactive({//极值数据
|
|
|
xMin:0,
|
|
|
xMax:0,
|
|
|
})
|
|
|
-let leftLimitData = ref([0,0]) //左轴上下限
|
|
|
-let rightLimitData = ref([0,0]) //右轴上下限
|
|
|
-let rightTwoLimitData = ref([0,0]) //右二轴上下限
|
|
|
//仅ETA图库内图表需要使用自定义上下限
|
|
|
let useSalfLimit = false
|
|
|
+let isUseSelfLimit = ref(false)
|
|
|
|
|
|
export function useChartRender(){
|
|
|
return {
|
|
|
options,
|
|
|
axisLimitState,
|
|
|
chartRender,
|
|
|
- leftLimitData,
|
|
|
- rightLimitData,
|
|
|
- rightTwoLimitData,
|
|
|
- setLimitData
|
|
|
+ setLimitData,
|
|
|
+ isUseSelfLimit
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -89,14 +85,18 @@ export function chartRender({data,renderId,lang='zh',changeLangIsCheck,showChart
|
|
|
axisLimitState.hasRightTwoAxis=false
|
|
|
axisLimitState.hasXAxis=false
|
|
|
|
|
|
- axisLimitState.leftMin=0
|
|
|
- axisLimitState.leftMax=0
|
|
|
- axisLimitState.rightMin=0
|
|
|
- axisLimitState.rightMax=0
|
|
|
- axisLimitState.rightTwoMin=0
|
|
|
- axisLimitState.rightTwoMax=0
|
|
|
- axisLimitState.xMin=0
|
|
|
- axisLimitState.xMax=0
|
|
|
+ //使用自定义上下限时,不需要初始化极值
|
|
|
+ if(!isUseSelfLimit.value){
|
|
|
+ axisLimitState.leftMin=0
|
|
|
+ axisLimitState.leftMax=0
|
|
|
+ axisLimitState.rightMin=0
|
|
|
+ axisLimitState.rightMax=0
|
|
|
+ axisLimitState.rightTwoMin=0
|
|
|
+ axisLimitState.rightTwoMax=0
|
|
|
+ axisLimitState.xMin=0
|
|
|
+ axisLimitState.xMax=0
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
let chartOpt={}
|
|
@@ -675,12 +675,14 @@ function setSplineOpt(e){
|
|
|
}
|
|
|
if(useSalfLimit&&isETASource){
|
|
|
const limitMap = {
|
|
|
- 0:rightLimitData.value||[],
|
|
|
- 1:leftLimitData.value||[],
|
|
|
- 2:rightTwoLimitData.value||[]
|
|
|
+ 0:['rightMin','rightMax'],
|
|
|
+ 1:['leftMin','leftMax'],
|
|
|
+ 2:['rightTwoMin','rightTwoMax']
|
|
|
+ }
|
|
|
+ if(limitMap[item.IsAxis]){
|
|
|
+ minLimit = axisLimitState[`${limitMap[item.IsAxis][0]}`]||0
|
|
|
+ maxLimit = axisLimitState[`${limitMap[item.IsAxis][1]}`]||0
|
|
|
}
|
|
|
- minLimit = limitMap[item.IsAxis][1]||0
|
|
|
- maxLimit = limitMap[item.IsAxis][0]||0
|
|
|
}
|
|
|
const textZh = item.ConvertUnit||item.Unit
|
|
|
const textEn = item.ConvertEnUnit||item.UnitEn||item.ConvertUnit||item.Unit
|
|
@@ -850,8 +852,8 @@ function setSeasonOpt(e){
|
|
|
minLimit = data.MinData
|
|
|
maxLimit = data.MaxData
|
|
|
}else{
|
|
|
- minLimit = leftLimitData.value[1]||0
|
|
|
- maxLimit = leftLimitData.value[0]||0
|
|
|
+ minLimit = axisLimitState.leftMin||0
|
|
|
+ maxLimit = axisLimitState.leftMax||0
|
|
|
}
|
|
|
const textZh = data.ConvertUnit||data.Unit
|
|
|
const textEn = data.ConvertEnUnit||data.UnitEn||data.ConvertUnit||data.Unit
|
|
@@ -906,8 +908,11 @@ function setSeasonOpt(e){
|
|
|
// chartData.rangeSelector=rangeSelector
|
|
|
// 设置坐标轴极值
|
|
|
axisLimitState.hasLeftAxis=true
|
|
|
- axisLimitState.leftMin=Number(data.MinData)
|
|
|
- axisLimitState.leftMax=Number(data.MaxData)
|
|
|
+ if(!useSalfLimit){
|
|
|
+ axisLimitState.leftMin=Number(data.MinData)
|
|
|
+ axisLimitState.leftMax=Number(data.MaxData)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 季节图x轴显示月/日
|
|
|
let xAxis={
|
|
@@ -1074,12 +1079,16 @@ function setStackOrCombinChart(e){
|
|
|
maxLimit = chartData[sameSideIndex].MaxData
|
|
|
}else{
|
|
|
const limitMap = {
|
|
|
- 0:rightLimitData.value||[],
|
|
|
- 1:leftLimitData.value||[],
|
|
|
- 2:rightTwoLimitData.value||[]
|
|
|
+ 0:['rightMin','rightMax'],
|
|
|
+ 1:['leftMin','leftMax'],
|
|
|
+ 2:['rightTwoMin','rightTwoMax']
|
|
|
+ }
|
|
|
+ if(limitMap[item.IsAxis]){
|
|
|
+ minLimit = axisLimitState[`${limitMap[item.IsAxis][0]}`]||0
|
|
|
+ maxLimit = axisLimitState[`${limitMap[item.IsAxis][1]}`]||0
|
|
|
+ console.log('check,check,check',axisLimitState.leftMin,axisLimitState.leftMax)
|
|
|
+ console.log('test堆叠',minLimit,maxLimit)
|
|
|
}
|
|
|
- minLimit = limitMap[item.IsAxis][1]||0
|
|
|
- maxLimit = limitMap[item.IsAxis][0]||0
|
|
|
}
|
|
|
|
|
|
// 设置y轴
|
|
@@ -1221,11 +1230,11 @@ function setScatterOptions(data){
|
|
|
|
|
|
//上下限设置的是y轴,也就是第二个指标的值,改回来
|
|
|
axisLimitState.hasLeftAxis=true
|
|
|
- axisLimitState.leftMin=Number(dataList[1].MinData)
|
|
|
+ /* axisLimitState.leftMin=Number(dataList[1].MinData)
|
|
|
axisLimitState.leftMax=Number(dataList[1].MaxData)
|
|
|
|
|
|
axisLimitData.leftMin=Number(dataList[1].MinData)
|
|
|
- axisLimitData.leftMax=Number(dataList[1].MaxData)
|
|
|
+ axisLimitData.leftMax=Number(dataList[1].MaxData) */
|
|
|
|
|
|
// 取2个指标中日期相同的数据
|
|
|
const real_data = [];
|
|
@@ -1287,8 +1296,8 @@ function setScatterOptions(data){
|
|
|
minLimit = Math.min(...real_data.map(_ => _.y));
|
|
|
maxLimit = Math.max(...real_data.map(_ => _.y));
|
|
|
}else{
|
|
|
- minLimit = leftLimitData.value[1]||0
|
|
|
- maxLimit = leftLimitData.value[0]||0
|
|
|
+ minLimit = axisLimitState.leftMin||0
|
|
|
+ maxLimit = axisLimitState.leftMax||0
|
|
|
}
|
|
|
const textYZh = dataList[1].ConvertUnit||dataList[1].Unit
|
|
|
const textYEn = dataList[1].ConvertEnUnit||dataList[1].UnitEn||dataList[1].ConvertUnit||dataList[1].Unit
|
|
@@ -2277,7 +2286,8 @@ function calcYAxislimit(tableData=[],ChartInfo){
|
|
|
//散点图单独处理
|
|
|
if(ChartInfo.ChartType===5){
|
|
|
if(tableData[1]){
|
|
|
- leftLimitData.value = [tableData[1].MaxData,tableData[1].MinData]
|
|
|
+ axisLimitState.leftMin = tableData[1].MinData
|
|
|
+ axisLimitState.leftMax = tableData[1].MaxData
|
|
|
}
|
|
|
return
|
|
|
}
|
|
@@ -2291,21 +2301,24 @@ function calcYAxislimit(tableData=[],ChartInfo){
|
|
|
Max,
|
|
|
Min
|
|
|
} = calcLimit(leftData.flat())
|
|
|
- leftLimitData.value = [Max, Min]
|
|
|
+ axisLimitState.leftMin = Min
|
|
|
+ axisLimitState.leftMax = Max
|
|
|
}
|
|
|
if (rightData.length) {
|
|
|
const {
|
|
|
Max,
|
|
|
Min
|
|
|
} = calcLimit(rightData.flat())
|
|
|
- rightLimitData.value = [Max, Min]
|
|
|
+ axisLimitState.rightMin = Min
|
|
|
+ axisLimitState.rightMax = Max
|
|
|
}
|
|
|
if (rightTwoData.length) {
|
|
|
const {
|
|
|
Max,
|
|
|
Min
|
|
|
} = calcLimit(rightTwoData.flat())
|
|
|
- rightTwoLimitData.value = [Max, Min]
|
|
|
+ axisLimitState.rightTwoMin = Min
|
|
|
+ axisLimitState.rightTwoMax = Max
|
|
|
}
|
|
|
}
|
|
|
function calcLimit(arr) {
|
|
@@ -2324,11 +2337,15 @@ function setLimitData({EdbInfoList,ChartInfo}){
|
|
|
MinMaxSave
|
|
|
} = ChartInfo
|
|
|
if(MinMaxSave){
|
|
|
- leftLimitData.value = [Number(LeftMax),Number(LeftMin)]
|
|
|
- rightLimitData.value = [Number(RightMax),Number(RightMin)]
|
|
|
- rightTwoLimitData.value = [Number(Right2Max),Number(Right2Min)]
|
|
|
+ axisLimitState.leftMin = Number(LeftMin)
|
|
|
+ axisLimitState.leftMax = Number(LeftMax)
|
|
|
+ axisLimitState.rightMin = Number(RightMin)
|
|
|
+ axisLimitState.rightMax = Number(RightMax)
|
|
|
+ axisLimitState.rightTwoMin = Number(Right2Min)
|
|
|
+ axisLimitState.rightTwoMax = Number(Right2Max)
|
|
|
//若用户修改过,则检测轴的上下限是否为空,若为空,则需要计算对应轴的上下限
|
|
|
checkLimit(EdbInfoList,ChartInfo)
|
|
|
+ console.log('check',axisLimitState.leftMin,axisLimitState.leftMax)
|
|
|
}else{
|
|
|
calcYAxislimit(EdbInfoList,ChartInfo)
|
|
|
}
|
|
@@ -2337,38 +2354,36 @@ function checkLimit(tableData=[],ChartInfo){
|
|
|
//散点图单独处理
|
|
|
if(ChartInfo.ChartType===5){
|
|
|
if(tableData[1]){
|
|
|
- if(Number(leftLimitData.value[0])===0&&Number(leftLimitData.value[1])===0){
|
|
|
- leftLimitData.value = [tableData[1].MaxData,tableData[1].MinData]
|
|
|
+ if(Number(axisLimitState.leftMin)===0&&Number(axisLimitState.leftMax)===0){
|
|
|
+ axisLimitState.leftMin = tableData[1].MinData
|
|
|
+ axisLimitState.leftMax = tableData[1].MaxData
|
|
|
}
|
|
|
}
|
|
|
return
|
|
|
}
|
|
|
//若轴的上下限均为0,则不管用户有没有修改过,都重新赋值
|
|
|
- if(Number(leftLimitData.value[0])===0&&Number(leftLimitData.value[1])===0){
|
|
|
+ if(Number(axisLimitState.leftMin)===0&&Number(axisLimitState.leftMax)===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())
|
|
|
- leftLimitData.value = [Max,Min]
|
|
|
- }else{
|
|
|
- leftLimitData.value = [0,0]
|
|
|
+ axisLimitState.leftMin = Min
|
|
|
+ axisLimitState.leftMax = Max
|
|
|
}
|
|
|
}
|
|
|
- if(Number(rightLimitData.value[0])===0&&Number(rightLimitData.value[1])===0){
|
|
|
+ if(Number(axisLimitState.rightMin)===0&&Number(axisLimitState.rightMax)===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())
|
|
|
- rightLimitData.value = [Max,Min]
|
|
|
- }else{
|
|
|
- rightLimitData.value = [0,0]
|
|
|
+ axisLimitState.rightMin = Min
|
|
|
+ axisLimitState.rightMax = Max
|
|
|
}
|
|
|
}
|
|
|
- if(Number(rightTwoLimitData.value[0])===0&&Number(rightTwoLimitData.value[1])===0){
|
|
|
+ if(Number(axisLimitState.rightTwoMin)===0&&Number(axisLimitState.rightTwoMax)===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())
|
|
|
- rightTwoLimitData.value = [Max,Min]
|
|
|
- }else{
|
|
|
- rightTwoLimitData.value = [0,0]
|
|
|
+ axisLimitState.rightTwoMin = Min
|
|
|
+ axisLimitState.rightTwoMax = Max
|
|
|
}
|
|
|
}
|
|
|
}
|