Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.8.9版本,配置项属性为函数时,本地与线上有差异 #99

Closed
Dream-nb opened this issue Mar 13, 2023 · 2 comments
Closed

Comments

@Dream-nb
Copy link

例如formatter属性为函数时,本地看为正常,发布后存在卡死现象,并且影响了图表显示
formatter(value: any) { // 浮窗内容及数字处理 const data = value[0]; return ${new Date().getFullYear()}.${data.name}
${data.marker} ${
data.seriesName
}: ${formatterVariable.date(data.value)}; }

@supervons
Copy link
Owner

supervons commented Mar 14, 2023

参考 #6 提供一下设备信息和可供运行的最小复现代码。

另外,可以尝试更新到 1.9.0 版本,看看是否还有这个问题。

@Dream-nb
Copy link
Author

更新版本为1.9.0版本。原因找到。是因为formatter为函数时,对数字的处理函数写在组件内。代码如下:
// 处理Y轴数字显示规则 const handleY = (value: any) => { // alert((value); if (value >= 1e8) { return parseInt(${value / 1e8}) + '亿'; } if (value >= 1e4) { return parseInt(${value / 1e4}) + '万'; } return value; }; ..... yAxis: { type: 'value', offset: 5, axisLabel: { formatter(value: any) { return formatterVariable.data(value) // 此处是传入 formatterVariable属性的对象函数 {data: handleY}; }, }, },
用上面这种写法图表就会无法显示,并且出一条虚线。只能把对数字的处理放到函数当中才行。如下:
formatter(value: any) { // 浮窗内容及数字处理 const data = value[0]; let num = data.value; if (num >= 1e8) { num = parseFloat(${num / 1e8}).toFixed(1) + '亿'; } if (num >= 1e4) { num = parseFloat(${num / 1e4}).toFixed(1) + '万'; } return ${new Date().getFullYear()}.${data.name}
${data.marker} ${data.seriesName}: ${num}; }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants