fix: 修复折线图百分比数据与坐标对不上问题

This commit is contained in:
@changcode
2022-10-23 10:17:26 +08:00
parent 74cbcf0d46
commit 21c3ead654
4 changed files with 25 additions and 8 deletions

View File

@@ -47,7 +47,7 @@ import { get } from '@/utils/http'
import { api } from '@/utils/api'
import ChartNoData from '@/views/charts/charts/ChartNoData'
import chartMixin from '@/views/charts2/chart-mixin'
import { chartColor3 } from '@/utils/constants'
import unitConvert from '@/utils/unit-convert'
export default {
name: 'NpmLine',
@@ -178,6 +178,14 @@ export default {
data: t.values.map((v) => [Number(v[0]) * 1000, Number(v[1]), type])
}
})
this.chartOption.yAxis[0].axisLabel.formatter = (value) => {
if (type === 'percent') {
console.log(type)
return unitConvert(value, type)[0]
} else {
return unitConvert(value, 'number').join('')
}
}
this.chartOption.tooltip.formatter = (params) => {
params.forEach(t => {
t.seriesName = this.$t(t.seriesName)