supervons / react-native-echarts-pro

A React-Native charts based on Apache ECharts, support various charts and map.
https://supervons.github.io/react-native-echarts-pro-docs/
MIT License
216 stars 32 forks source link

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

Closed Dream-nb closed 1 year ago

Dream-nb commented 1 year ago

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

supervons commented 1 year ago

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

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

Dream-nb commented 1 year ago

更新版本为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}; }