Closed TomWq closed 7 months ago
有相应demo吗
我也是,重进几次就出现了,安卓的,配置
const COLORS = [Theme.baseColor, '#5470c6'];
const options: EChartsOption = {
backgroundColor: 'white',
title: {
text: '速度:km/h',
textStyle: {
fontSize: 12,
},
left: 10,
top: 5,
},
grid: {
show: true,
left: '30',
top: '40',
right: '30',
bottom: '40',
borderColor: '#eee',
},
color: COLORS,
legend: {
show: false,
},
xAxis: {
type: 'category',
boundaryGap: true,
triggerEvent: false,
splitLine: {
show: false,
lineStyle: {
color: '#eee',
width: 1,
},
},
axisLine: {
onZero: false,
lineStyle: {
color: '#ccc',
width: 1,
},
},
axisTick: {
show: false, //去小头头
length: 5, //坐标轴刻度的长度
alignWithLabel: true,
inside: true,
},
data: data.xData,
axisLabel: {
color: '#999',
fontSize: 10,
fontFamily: 'PingFangSC,Noto Sans CJK SC ,Source Han Sans CN',
// showMinLabel: true,
// showMaxLabel: true,
formatter(value) {
return `${value}`;
},
},
},
dataZoom: [
{
type: 'slider', //隐藏或显示(true)组件
show: true,
backgroundColor: '#c9c9c9', // 组件的背景颜色。
fillerColor: Theme.baseColor, // 选中范围的填充颜色。
borderColor: '#f8f8f8', // 边框颜色
showDetail: false, //是否显示detail,即拖拽时候显示详细数值信息
start: 0,
end: 100,
maxSpan: 20,
borderRadius: 5,
filterMode: 'empty',
width: '50%', //滚动条高度
height: 8, //滚动条显示位置
left: 'center',
handleSize: 0, //控制手柄的尺寸
bottom: 10, // dataZoom-slider组件离容器下侧的距离
},
{
//没有下面这块的话,只能拖动滚动条,鼠标滚轮在区域内不能控制外部滚动条
type: 'inside',
zoomOnMouseWheel: true, //滚轮是否触发缩放
moveOnMouseMove: true, //鼠标滚轮触发滚动
moveOnMouseWheel: true,
},
],
yAxis: {
max: 150,
min: 0,
type: 'value',
splitNumber: 4,
axisLabel: {
color: '#666',
fontSize: 10,
fontFamily: 'PingFangSC,Noto Sans CJK SC ,Source Han Sans CN',
formatter: function (val: any) {
return `${numeral(val).format('0')}`;
},
},
splitLine: {
lineStyle: {
type: 'dashed',
},
},
},
series: {
symbol: 'circle',
data: data.data,
label: {
show: true,
color: '#666',
fontSize: 10,
},
type: 'line',
lineStyle: {
width: 1,
},
},
animationEasing: 'quadraticIn',
};
let chart: any;
if (chartRef.current) {
// @ts-ignore
chart = echarts.init(chartRef.current, 'light', {
renderer: 'svg',
width,
height,
});
chart.setOption(options);
}
return () => chart?.dispose();
}, [data, width, height]);
好像是因为增加了dataZoom的缘故,其它没加的倒是没触发过这个错误
重进几次就出现了,指的是使用 react navigation 跳转页面吗
I have the same problem that work on ios and raise this error on android. That was working on react native 0.71.2 but I when I move on react native 0.72.3 I got error
try 1.2.3-alpha.0
@zhiqingchen The issue is still there on android but not on ios
Any other demos? I don't get errors in the above case
I reproduced on iOS
How
Same issue on iOS
Hi, someone has found a solution?
Can anyone provide a reproducible demo of this
Any solution? I have started to receive this error message as well. I might add that I didn't experience these issues before - it's new and nothing seems to fix it.
Dependencies:
Do you have a suggestion of what might cause this? The bug is app breaking and I'm suspecting it has to do with version incompatibility since I never experienced it in the past using very similar code. It also happens seemingly randomly @zhiqingchen
I haven't been able to reproduce this
try 1.1.2
try 1.1.2
Tried - issue remains unfortunately
Edit: Below is my Echarts component for reference.
import SkiaChart, { SVGRenderer } from "@wuba/react-native-echarts/skiaChart"
import React, { memo, useEffect, useRef } from "react"
import { BarChart, LineChart, PieChart } from "echarts/charts"
import { GridComponent, LegendComponent, TooltipComponent } from "echarts/components"
import * as echarts from "echarts/core"
import { EChartsOption } from "echarts/types/dist/shared"
echarts.use([TooltipComponent, LegendComponent, GridComponent, SVGRenderer, BarChart, LineChart, PieChart])
export const Echarts = memo(({ option, width, height }: { option: EChartsOption; width: number; height: number }) => {
const skiaRef = useRef<any>(null)
useEffect(() => {
let chart: echarts.ECharts
if (skiaRef.current) {
chart = echarts.init(skiaRef.current, "light", {
renderer: "svg",
width,
height,
})
chart.setOption(option)
}
return () => chart?.dispose()
}, [option, width, height])
return <SkiaChart ref={skiaRef} />
})
If someone can reproduce the issue, can provide a expo snack so that we can easily locate and fix it.
I fixed this issue with a temporary config in node_modules, after many tests I saw this error just appeared when the user clicks on any time of my picker calendar, to filter dates, when action is too quick this error appears, but when is slower error did not appear.
So, I did use not the recommendation method to fix the issue but checked if the element existed before the call method.
Step 1, go on zrender on your node_modules and go on zrender.js on lib
all call method should predifined by method && method(), exemple this.animation.start() become this.animation && this.animation.start()
This correction is based on @yechunxi
My files new zrender js file
/*!
Having this error on Android 12.
It's happening in this line when the chart updates 3,4 times in a small space of time.
I reproduce the issue, The reason for this problem is that after the chart executes dispose, some instances are set to null, but some internal asynchronous operations will be called again, resulting in an error.
The current temporary solution is to apply a patch to zrender.js , Modify the method in zrender and add judgment before calling the method. same as @wogno
I gave zrender a PR, but it has not been officially verified and merged. If anyone has a better solution, welcome to submit a PR.
same issue after slowly click legend on android, but ios is ok
ERROR TypeError: Cannot read property 'trigger' of null, js engine: hermes
@yechunxi is right, comment // return () => chart?.dispose(); will work success but got warning ' WARN [ECharts] There is a chart instance already initialized on the dom. '
example code at https://wuba.github.io/react-native-echarts/docs/getting-started/write-a-simple-line-chart shows
return () => chart?.dispose();
remove this line and add check if exists looks good even if multi charts shows on same page
const innerChartRef = useRef<any>(null);
const chartInstance = useRef<any>(null);
useEffect(() => {
if (innerChartRef.current) {
// https://github.com/wuba/react-native-echarts/issues/92
// WARN [ECharts] There is a chart instance already initialized on the dom. []
if (!chartInstance.current) {
chartInstance.current = echarts.init(innerChartRef.current, 'light', {
renderer: 'svg',
width,
height,
});
onChartHandler?.(chartInstance.current);
}
chartInstance.current.setOption(option);
}
// return () => chartInstance.current?.dispose();
}, [onChartHandler, option, width, height]);
useImperativeHandle(ref, () => ({ ...innerChartRef.current }));
return <SvgChart ref={innerChartRef} />;
It looks like removing return () => chart?.dispose()
fixed this issue for me. Removing this also gave my charts a bit better performance it seems.
@krmao You could probably fix that warning by trying to get the chart instance by ref, this is what I have:
chart = echarts.getInstanceByDom(chartRef.current) || echarts.init(chartRef.current,'light', {
height: height,
width: width,
renderer: 'svg',
});
It looks like removing
return () => chart?.dispose()
fixed this issue for me. Removing this also gave my charts a bit better performance it seems.@krmao You could probably fix that warning by trying to get the chart instance by ref, this is what I have:
chart = echarts.getInstanceByDom(chartRef.current) || echarts.init(chartRef.current,'light', { height: height, width: width, renderer: 'svg', });
yes, my final code is here, for some echarts dispose manually @alecsloan
if (!chartInstance.current || chartInstance.current.isDisposed()) {
chartInstance.current = echarts.init(innerChartRef.current, 'light', {
renderer: 'svg',
width,
height,
});
}
Zrender is too slow, to fix bugs, can we change the render library?
Not yet, zrender is a rendering library for echarts, so if you need a quick fix, patch it in your own project.
How to change the zrender with any other alternative ? anyone have any idea than let me know. I also have to change as I'm experiencing slow rendering of chart in my react native application.
zrender 5.5.0 echarts 5.5.0-rc.1
The new version fixes this problem, you can try it.
我在使用过程中多点几次就会出现这个错误: Cannot read property 'trigger' of null "react-native":" 0.72.3" "echarts": "^5.4.3", "@wuba/react-native-echarts": "^1.2.2"