Verified Commit b81e8327 authored by jxtxzzw's avatar jxtxzzw
Browse files

优化:根据筛选情况调整画布显示范围,优化判断逻辑



Signed-off-by: jxtxzzw's avatarjxtxzzw <jxtxzzw@126.com>
parent 094b94f1
......@@ -2,7 +2,20 @@
import { chartHeight } from './incomeUtil'
export function renderChartForCredit(that, credit) {
export function renderChartForCredit(that, credit, checkboxes) {
const [checkAllGroupSource, checkAllGroupModel] = checkboxes
credit = credit.filter((e) => {
return (
checkAllGroupSource.includes(e.source) &&
checkAllGroupModel.includes(e.model)
)
})
if (credit.length === 0) {
return null
}
const { Chart } = that.$g2
const chart = new Chart({
container: 'credit-score',
......@@ -56,6 +69,31 @@ export function renderChartForCredit(that, credit) {
},
})
let chartMin = 1000
let chartMax = 0
if (
checkAllGroupModel.includes('微信支付分') ||
checkAllGroupModel.includes('芝麻信用')
) {
chartMin = Math.min(chartMin, 350)
chartMax = Math.max(chartMax, 950)
}
if (
checkAllGroupModel.includes('FICO Score 8') ||
checkAllGroupModel.includes('FICO Score 9') ||
checkAllGroupModel.includes('VantageScore 3.0') ||
checkAllGroupModel.includes('VantageScore 4.0')
) {
chartMin = Math.min(chartMin, 300)
chartMax = Math.max(chartMax, 850)
}
chart.scale('score', {
min: chartMin,
max: chartMax,
})
chart.render()
return chart
}
......@@ -61,12 +61,8 @@ export default {
}
this.oldChart.creditScore = creditUtil.renderChartForCredit(
this,
credit.filter((e) => {
return (
this.checkAllGroupSource.includes(e.source) &&
this.checkAllGroupModel.includes(e.model)
)
})
credit,
[this.checkAllGroupSource, this.checkAllGroupModel]
)
// Chart 都是 autoFit 的,所以强制触发一次 resize 就可以了
window.dispatchEvent(new Event('resize'))
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment