forked from github/dataease
Merge pull request #5208 from dataease/pr@dev@refactor_axis
refactor: 组合图轴值最大值不能小于数值最大值
This commit is contained in:
commit
85722cbbd2
@ -24,6 +24,7 @@ export function baseMixOption(chart_option, chart) {
|
||||
}
|
||||
}
|
||||
// 处理data
|
||||
const yAxisSeriesMaxList = []; const yAxisExtSeriesMaxList = []
|
||||
if (chart.data) {
|
||||
chart_option.title.text = chart.title
|
||||
chart_option.xAxis.data = chart.data.x
|
||||
@ -69,12 +70,42 @@ export function baseMixOption(chart_option, chart) {
|
||||
chart_option.legend.data.push(y.name)
|
||||
i >= yAxis.length ? (y.yAxisIndex = 1) : (y.yAxisIndex = 0)
|
||||
|
||||
// get max
|
||||
if (i >= yAxis.length) {
|
||||
const valueList = []
|
||||
y.data.forEach(ele => {
|
||||
valueList.push(ele.value)
|
||||
})
|
||||
yAxisExtSeriesMaxList.push(Math.max.apply(null, valueList))
|
||||
} else {
|
||||
const valueList = []
|
||||
y.data.forEach(ele => {
|
||||
valueList.push(ele.value)
|
||||
})
|
||||
yAxisSeriesMaxList.push(Math.max.apply(null, valueList))
|
||||
}
|
||||
|
||||
y.selectedMode = true
|
||||
y.select = BASE_ECHARTS_SELECT
|
||||
chart_option.series.push(y)
|
||||
}
|
||||
}
|
||||
componentStyle(chart_option, chart)
|
||||
|
||||
// 若轴值中最大值小于data的最大值,则轴值最大值设置失效
|
||||
if (yAxisSeriesMaxList.length > 0 && !isNaN(chart_option.yAxis[0].max)) {
|
||||
const max = Math.max.apply(null, yAxisSeriesMaxList)
|
||||
if (max > chart_option.yAxis[0].max) {
|
||||
delete chart_option.yAxis[0].max
|
||||
}
|
||||
}
|
||||
if (yAxisExtSeriesMaxList.length > 0 && !isNaN(chart_option.yAxis[1].max)) {
|
||||
const max = Math.max.apply(null, yAxisExtSeriesMaxList)
|
||||
if (max > chart_option.yAxis[1].max) {
|
||||
delete chart_option.yAxis[1].max
|
||||
}
|
||||
}
|
||||
|
||||
seniorCfg(chart_option, chart)
|
||||
return chart_option
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user