|
@@ -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 滚动相关性
|
|
@@ -158,7 +158,15 @@ export const chartSetMixin = {
|
|
|
barXData: [],//柱形图的x轴
|
|
|
barXIdList: [],//x轴id数组 用于切换英文遍历用
|
|
|
barEdbData: [],//柱形图的表格数据 只用于取值
|
|
|
- chartLimit: {},
|
|
|
+ chartLimit: {
|
|
|
+ min:'', //左轴上下限
|
|
|
+ max:'',
|
|
|
+ rightMin:'',//右轴上下限
|
|
|
+ rightMax:'',
|
|
|
+ rightTwoMin:'',//右二轴上下限
|
|
|
+ rightTwoMax:'',
|
|
|
+
|
|
|
+ },
|
|
|
|
|
|
/* 商品价格曲线 本来逻辑分开写 但需求又得加入myeta和eta图库共存 还是写一块算了 */
|
|
|
commodityChartData: [],
|
|
@@ -567,7 +575,14 @@ export const chartSetMixin = {
|
|
|
this.leftIndex = -1;
|
|
|
this.rightIndex = -1;
|
|
|
this.rightTwoIndex = -1;
|
|
|
- this.chartLimit = {};
|
|
|
+ this.chartLimit = {
|
|
|
+ min:'', //左轴上下限
|
|
|
+ max:'',
|
|
|
+ rightMin:'',//右轴上下限
|
|
|
+ rightMax:'',
|
|
|
+ rightTwoMin:'',//右二轴上下限
|
|
|
+ rightTwoMax:'',
|
|
|
+ };
|
|
|
}else {
|
|
|
this.leftIndex = newval.findIndex((item) => item.IsAxis===1);
|
|
|
this.rightIndex = newval.findIndex((item) => !item.IsAxis);
|
|
@@ -588,7 +603,31 @@ export const chartSetMixin = {
|
|
|
let sameSideIndex = chartData.findIndex(
|
|
|
(i) => i.IsAxis === item.IsAxis
|
|
|
);
|
|
|
-
|
|
|
+
|
|
|
+ //获取对应轴的上下限
|
|
|
+ //预测指标-走势图;图表配置-主题设置;不使用自定义上下限,剔除
|
|
|
+ const useTableLimit = ['/predictEdb','/chartThemeSet'].includes(this.$route.path)
|
|
|
+ //非ETA图库图表也不设置自定义上下限,相关性和统计特征也会用到曲线图
|
|
|
+ //若chartInfo.Source为1,需在之前调用setLimitData
|
|
|
+ const isETASource = this.chartInfo.Source===1
|
|
|
+ let minLimit = 0,maxLimit = 0
|
|
|
+ if(useTableLimit||!isETASource){
|
|
|
+ minLimit = newval[sameSideIndex].MinData
|
|
|
+ maxLimit = newval[sameSideIndex].MaxData
|
|
|
+ }
|
|
|
+ if(!useTableLimit&&isETASource){
|
|
|
+ const limitMap = {
|
|
|
+ 0:['rightMin','rightMax'],
|
|
|
+ 1:['min','max'],
|
|
|
+ 2:['rightTwoMin','rightTwoMax']
|
|
|
+ }
|
|
|
+ if(limitMap[item.IsAxis]){
|
|
|
+ minLimit = this.chartLimit[`${limitMap[item.IsAxis][0]}`]||0
|
|
|
+ maxLimit = this.chartLimit[`${limitMap[item.IsAxis][1]}`]||0
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//y轴
|
|
|
const textZh = item.ConvertUnit||item.Unit
|
|
|
const textEn = item.ConvertEnUnit||item.UnitEn||item.ConvertUnit||item.Unit
|
|
@@ -621,8 +660,8 @@ export const chartSetMixin = {
|
|
|
},
|
|
|
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),
|
|
@@ -768,6 +807,26 @@ export const chartSetMixin = {
|
|
|
? -1
|
|
|
: newval.findIndex((item) => item.IsAxis===2);
|
|
|
|
|
|
+
|
|
|
+ //获取对应轴的上下限
|
|
|
+ //预测指标-走势图;图表配置-主题设置;不使用自定义上下限,剔除
|
|
|
+ const useTableLimit = ['/predictEdb','/chartThemeSet'].includes(this.$route.path)
|
|
|
+ let minLimit = 0,maxLimit = 0
|
|
|
+ if(useTableLimit){
|
|
|
+ minLimit = chartData[sameSideIndex].MinData
|
|
|
+ maxLimit = chartData[sameSideIndex].MaxData
|
|
|
+ }else{
|
|
|
+ const limitMap = {
|
|
|
+ 0:['rightMin','rightMax'],
|
|
|
+ 1:['min','max'],
|
|
|
+ 2:['rightTwoMin','rightTwoMax']
|
|
|
+ }
|
|
|
+ if(limitMap[item.IsAxis]){
|
|
|
+ minLimit = this.chartLimit[`${limitMap[item.IsAxis][0]}`]||0
|
|
|
+ maxLimit = this.chartLimit[`${limitMap[item.IsAxis][1]}`]||0
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
//y轴
|
|
|
const textZh = item.ConvertUnit||item.Unit
|
|
|
const textEn = item.ConvertEnUnit||item.UnitEn||item.ConvertUnit||item.Unit
|
|
@@ -800,8 +859,8 @@ export const chartSetMixin = {
|
|
|
},
|
|
|
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: 1,
|
|
|
visible: serie_yIndex === index && sameSideIndex ===index,
|
|
|
plotBands: this.setAxisPlotAreas(item.IsAxis),
|
|
@@ -898,6 +957,18 @@ export const chartSetMixin = {
|
|
|
let seasonYdata = [],
|
|
|
seasonData = [];
|
|
|
|
|
|
+ //获取对应轴的上下限
|
|
|
+ //预测指标-走势图;图表配置-主题设置;不使用自定义上下限,剔除
|
|
|
+ const useTableLimit = ['/predictEdb','/chartThemeSet'].includes(this.$route.path)
|
|
|
+ let minLimit = 0,maxLimit = 0
|
|
|
+ if(useTableLimit){
|
|
|
+ minLimit = chartData.MinData
|
|
|
+ maxLimit = chartData.MaxData
|
|
|
+ }else{
|
|
|
+ minLimit = this.chartLimit.min||0
|
|
|
+ maxLimit = this.chartLimit.max||0
|
|
|
+ }
|
|
|
+
|
|
|
//数据列
|
|
|
for (let j of chartDataHandle) {
|
|
|
//预测指标配置
|
|
@@ -950,8 +1021,8 @@ export const chartSetMixin = {
|
|
|
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)
|
|
|
}];
|
|
@@ -1115,6 +1186,18 @@ export const chartSetMixin = {
|
|
|
} */
|
|
|
|
|
|
|
|
|
+ //获取对应轴的上下限
|
|
|
+ //预测指标-走势图;图表配置-主题设置;不使用自定义上下限,剔除
|
|
|
+ const useTableLimit = ['/predictEdb','/chartThemeSet'].includes(this.$route.path)
|
|
|
+ let minLimit = 0,maxLimit = 0
|
|
|
+ if(useTableLimit){
|
|
|
+ minLimit = Math.min(...real_data.map(_ => _.y));
|
|
|
+ maxLimit = Math.max(...real_data.map(_ => _.y));
|
|
|
+ }else{
|
|
|
+ minLimit = this.chartLimit.min||0
|
|
|
+ maxLimit = this.chartLimit.max||0
|
|
|
+ }
|
|
|
+
|
|
|
const { IsOrder,ChartColor } = newval[0];
|
|
|
//y轴
|
|
|
const textYZh = newval[1].ConvertUnit||newval[1].Unit
|
|
@@ -1148,8 +1231,8 @@ export const chartSetMixin = {
|
|
|
},
|
|
|
opposite: false,
|
|
|
reversed: IsOrder,
|
|
|
- min: Number(newval[1].MinData),
|
|
|
- max: Number(newval[1].MaxData),
|
|
|
+ min: Number(minLimit),
|
|
|
+ max: Number(maxLimit),
|
|
|
tickWidth: 1,
|
|
|
plotBands: this.setAxisPlotAreas(1),
|
|
|
plotLines: this.setAxisPlotLines(1)
|
|
@@ -1215,6 +1298,9 @@ export const chartSetMixin = {
|
|
|
x轴为指标名称的柱形图 以日期作为series
|
|
|
*/
|
|
|
setBarChart() {
|
|
|
+ this.leftIndex = -1;
|
|
|
+ this.rightIndex = -1;
|
|
|
+ this.rightTwoIndex = -1;
|
|
|
let seriesData = [];
|
|
|
const data = _.cloneDeep(this.barDateList);
|
|
|
|
|
@@ -2489,6 +2575,12 @@ export const chartSetMixin = {
|
|
|
changeLimit() {
|
|
|
//source1 eta图库的类型对应
|
|
|
const typeMap = {
|
|
|
+ 1: this.setDefaultChart,
|
|
|
+ 2: this.setSeasonChart,
|
|
|
+ 3: this.setStackOrCombinChart,
|
|
|
+ 4: this.setStackOrCombinChart,
|
|
|
+ 5: this.setScatterChart,
|
|
|
+ 6: this.setStackOrCombinChart,
|
|
|
7: this.setBarChart,
|
|
|
10: this.setSectionScatterChart,
|
|
|
11: this.setRadarChart
|
|
@@ -2500,7 +2592,13 @@ export const chartSetMixin = {
|
|
|
// 3:
|
|
|
}
|
|
|
if(this.chartInfo.Source === 1) {
|
|
|
- typeMap[this.chartInfo.ChartType]()
|
|
|
+ if([7,10,11].includes(this.chartInfo.ChartType)){
|
|
|
+ typeMap[this.chartInfo.ChartType]()
|
|
|
+ }else{
|
|
|
+ this.setAddChartDefault&&this.setAddChartDefault();
|
|
|
+ typeMap[this.chartInfo.ChartType](this.tableData)
|
|
|
+ }
|
|
|
+
|
|
|
}else {
|
|
|
sourceMap[this.chartInfo.Source]();
|
|
|
}
|
|
@@ -2632,5 +2730,144 @@ export const chartSetMixin = {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ /* ----自定义上下限相关--- */
|
|
|
+ /* 计算y轴上下限 */
|
|
|
+ calcYAxislimit(tableData=[]) {
|
|
|
+ //散点图单独处理
|
|
|
+ if(this.chartInfo.ChartType===5){
|
|
|
+ if(tableData[1]){
|
|
|
+ this.chartLimit.min = tableData[1].MinData
|
|
|
+ this.chartLimit.max = tableData[1].MaxData
|
|
|
+ }
|
|
|
+ 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.chartLimit.min=Min
|
|
|
+ this.chartLimit.max=Max
|
|
|
+ } else {
|
|
|
+ this.leftIndex = -1
|
|
|
+ this.chartLimit.min=0
|
|
|
+ this.chartLimit.max=0
|
|
|
+ }
|
|
|
+ if (rightData.length) {
|
|
|
+ const {
|
|
|
+ Max,
|
|
|
+ Min
|
|
|
+ } = this.calcLimit(rightData.flat())
|
|
|
+ this.chartLimit.rightMin = Min
|
|
|
+ this.chartLimit.rightMax = Max
|
|
|
+ } else {
|
|
|
+ this.rightIndex = -1
|
|
|
+ this.chartLimit.rightMin = 0
|
|
|
+ this.chartLimit.rightMax = 0
|
|
|
+ }
|
|
|
+ if (rightTwoData.length) {
|
|
|
+ const {
|
|
|
+ Max,
|
|
|
+ Min
|
|
|
+ } = this.calcLimit(rightTwoData.flat())
|
|
|
+ this.chartLimit.rightTwoMin = Min
|
|
|
+ this.chartLimit.rightTwoMax = Max
|
|
|
+ } else {
|
|
|
+ this.rightTwoIndex = -1
|
|
|
+ this.chartLimit.rightTwoMin = 0
|
|
|
+ this.chartLimit.rightTwoMax = 0
|
|
|
+ }
|
|
|
+ console.table([{
|
|
|
+ 'y轴': '左轴',
|
|
|
+ '最大值': this.chartLimit.max,
|
|
|
+ '最小值': this.chartLimit.min
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'y轴': '右轴',
|
|
|
+ '最大值': this.chartLimit.rightMax,
|
|
|
+ '最小值': this.chartLimit.rightMin
|
|
|
+ },
|
|
|
+ {
|
|
|
+ 'y轴': '右二轴',
|
|
|
+ '最大值': this.chartLimit.rightTwoMax,
|
|
|
+ '最小值': this.chartLimit.rightTwoMin
|
|
|
+ }
|
|
|
+ ])
|
|
|
+ },
|
|
|
+ calcLimit(arr) {
|
|
|
+ return {
|
|
|
+ Max: Math.max(...arr),
|
|
|
+ Min: Math.min(...arr)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //图表详情-设置图表上下限
|
|
|
+ setLimitData(tableData=[]){
|
|
|
+ const {
|
|
|
+ //左右轴极值字段
|
|
|
+ LeftMin=0,LeftMax=0,
|
|
|
+ RightMin=0,RightMax=0,
|
|
|
+ Right2Min=0,Right2Max=0,
|
|
|
+ MinMaxSave
|
|
|
+ } = this.chartInfo
|
|
|
+ if(MinMaxSave){
|
|
|
+ this.chartLimit.min = Number(LeftMin)
|
|
|
+ this.chartLimit.max = Number(LeftMax)
|
|
|
+ this.chartLimit.rightMin = Number(RightMin)
|
|
|
+ this.chartLimit.rightMax = Number(RightMax)
|
|
|
+ this.chartLimit.rightTwoMin = Number(Right2Min)
|
|
|
+ this.chartLimit.rightTwoMax = Number(Right2Max)
|
|
|
+ //若用户修改过,则检测轴的上下限是否为空,若为空,则需要计算对应轴的上下限
|
|
|
+ this.checkChartLimit(tableData)
|
|
|
+ }else{
|
|
|
+ this.calcYAxislimit(tableData)
|
|
|
+ }
|
|
|
+ },
|
|
|
+ checkChartLimit(tableData=[]){
|
|
|
+ //散点图单独处理
|
|
|
+ if(this.chartInfo.ChartType===5){
|
|
|
+ if(tableData[1]){
|
|
|
+ const {min,max} = this.chartLimit
|
|
|
+ if(Number(min)===0&&Number(max)===0){
|
|
|
+ this.chartLimit.min = tableData[1].MinData
|
|
|
+ this.chartLimit.max = tableData[1].MaxData
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return
|
|
|
+ }
|
|
|
+ const {
|
|
|
+ min,max,rightMin,rightMax,rightTwoMin,rightTwoMax
|
|
|
+ } = this.chartLimit
|
|
|
+ //若轴的上下限均为0,则不管用户有没有修改过,都重新赋值
|
|
|
+ if(Number(min)===0&&Number(max)===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.chartLimit.min=Min
|
|
|
+ this.chartLimit.max=Max
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Number(rightMin)===0&&Number(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())
|
|
|
+ this.chartLimit.rightMin = Min
|
|
|
+ this.chartLimit.rightMax = Max
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(Number(rightTwoMin)===0&&Number(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())
|
|
|
+ this.chartLimit.rightTwoMin = Min
|
|
|
+ this.chartLimit.rightTwoMax = Max
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ /*-------------------- */
|
|
|
}
|
|
|
}
|