|
@@ -38,7 +38,7 @@ const basicYAxis = {
|
|
|
}
|
|
|
/**备注一下 越多越乱
|
|
|
* @params
|
|
|
- * Source 1 ; chartType 1曲线 2季节 3面积 4堆积柱 5散点 6组合 7柱形 8截面散点
|
|
|
+ * Source 1 ; chartType 1曲线 2季节 3面积 4堆积柱 5散点 6组合 7柱形 10截面散点 11雷达图
|
|
|
* 2 商品价格
|
|
|
* 3 相关性
|
|
|
* 4 滚动相关性
|
|
@@ -134,6 +134,9 @@ export const chartSetMixin = {
|
|
|
leftIndex: -1, //左侧上下限对应下标
|
|
|
rightIndex: -1, //右侧上下限对应下标
|
|
|
rightTwoIndex: -1,//右2上下限对应下标
|
|
|
+ leftLimitData:[0,0],//左轴上下限
|
|
|
+ rightLimitData:[0,0],//右轴上下限
|
|
|
+ rightTwoLimitData:[0,0],//右二轴上下限
|
|
|
left_extreme: [],
|
|
|
right_extreme: [],
|
|
|
|
|
@@ -590,15 +593,23 @@ export const chartSetMixin = {
|
|
|
);
|
|
|
|
|
|
//获取对应轴的上下限
|
|
|
+ //预测指标-走势图;图表配置-主题设置;不使用自定义上下限,剔除
|
|
|
+ const useTableLimit = ['/predictEdb','/chartThemeSet'].includes(this.$route.path)
|
|
|
let minLimit = 0,maxLimit = 0
|
|
|
- const limitMap = {
|
|
|
- 0:this.rightLimitData||[],
|
|
|
- 1:this.leftLimitData||[],
|
|
|
- 2:this.rightTwoLimitData||[]
|
|
|
+ if(useTableLimit){
|
|
|
+ minLimit = this.tableData[sameSideIndex].MinData
|
|
|
+ maxLimit = this.tableData[sameSideIndex].MaxData
|
|
|
+ }else{
|
|
|
+ const limitMap = {
|
|
|
+ 0:this.rightLimitData||[],
|
|
|
+ 1:this.leftLimitData||[],
|
|
|
+ 2:this.rightTwoLimitData||[]
|
|
|
+ }
|
|
|
+ minLimit = limitMap[item.IsAxis][1]||0
|
|
|
+ maxLimit = limitMap[item.IsAxis][0]||0
|
|
|
}
|
|
|
- minLimit = limitMap[item.IsAxis][1]||0
|
|
|
- maxLimit = limitMap[item.IsAxis][0]||0
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
//y轴
|
|
|
let yItem = {
|
|
|
...basicYAxis,
|
|
@@ -2609,5 +2620,116 @@ export const chartSetMixin = {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+
|
|
|
+ /* 计算y轴上下限 */
|
|
|
+ calcYAxislimit(tableData=[]) {
|
|
|
+ //分组
|
|
|
+ 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)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //输入框改变上下限时触发
|
|
|
+ changeAxisLimit() {
|
|
|
+ this.setAddChartDefault&&this.setAddChartDefault();
|
|
|
+ this.setChartOptionHandle(this.tableData);
|
|
|
+ },
|
|
|
+ //图表详情-设置图表上下限
|
|
|
+ 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)]
|
|
|
+ //若轴的上下限均为0,则不管用户有没有修改过,都重新赋值
|
|
|
+ if(this.leftLimitData[0]===0&&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(this.rightLimitData[0]===0&&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(this.rightTwoLimitData[0]===0&&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]
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ this.calcYAxislimit(tableData)
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|