Comments (4)
Ok, after some searching on other github repos solution seems to be:
const [chartInstance, setChartInstance] = useState<EChartsType | null>(null);
const skiaRef = useRef(null);
useEffect(() => {
let chart: EChartsType | null = null;
if (skiaRef.current && !chartInstance) {
chart = echarts.init(skiaRef.current, 'light', {
renderer: 'svg',
width: E_WIDTH,
height: E_HEIGHT,
});
chart.setOption(options);
setChartInstance(chart);
return () => chart?.dispose();
}
}, []);
useEffect(() => {
chartInstance?.setOption(options);
}, [data]);
Hope that is correct implementation. Original link: https://github.com/windalfin/fasttt/blob/ff30b40a040700e5fc99f807fa96cda3951ca01d/src/components/HomePage/FastingProgressGauge.tsx#L86-L105
from react-native-echarts.
Ok, after some searching on other github repos solution seems to be:
const [chartInstance, setChartInstance] = useState<EChartsType | null>(null); const skiaRef = useRef(null); useEffect(() => { let chart: EChartsType | null = null; if (skiaRef.current && !chartInstance) { chart = echarts.init(skiaRef.current, 'light', { renderer: 'svg', width: E_WIDTH, height: E_HEIGHT, }); chart.setOption(options); setChartInstance(chart); return () => chart?.dispose(); } }, []); useEffect(() => { chartInstance?.setOption(options); }, [data]);Hope that is correct implementation. Original link: https://github.com/windalfin/fasttt/blob/ff30b40a040700e5fc99f807fa96cda3951ca01d/src/components/HomePage/FastingProgressGauge.tsx#L86-L105
@alexey-yarmosh Did this approach solve your problem? This is the correct implementation. When options change, instead of re-creating the echart instance, directly call setOption to re-render the chart.
However, some users still find that page switching is too fast and errors occasionally occur. After the echart instance is destroyed, some internal operations may continue to cause errors. like this discussion. We also submitted a PR to zrender to solve the change problem, but the PR is still waiting for official verification and merging.
from react-native-echarts.
Yes, seems to be working for now. If some issues arise I'll get back here.
Also probably that usage worth documenting on the website, I can assist with that if needed.
from react-native-echarts.
Yes, seems to be working for now. If some issues arise I'll get back here. Also probably that usage worth documenting on the website, I can assist with that if needed.
Thank you for your suggestion. Welcome to submit a PR to write the document. This way you can provide more examples.
This issue will be closed. If you have other questions, welcome to open a new issue.
from react-native-echarts.
Related Issues (20)
- I can't capture the click event HOT 2
- Load time is why more than expected. HOT 1
- skiaChart legend custom fontFamily not work but other rn normal component works HOT 2
- New architecture support HOT 1
- App is crashing while using Skia chart or Svg Chart on click on chart and the chart is not loading. HOT 13
- Please merge feat/react-native-73 to be able to use Expo 50 which is not working HOT 4
- Add Support for Comparison Series in Line/Area Charts HOT 7
- Line Chart Incorrectly Renders for Series with Different Date Ranges
- Problem (most likely with opacity) rendering legend, line chart, axes scales and tooltip coordinates. HOT 22
- Warning HOT 3
- 升级新版本 react-native-reanimated,RNGestureHandler.js 报错了
- Chart becomes very slow when rendering large volume of data HOT 4
- Text is not visible on tooltip HOT 4
- markarea cannot use
- series中clip无效,数据过大依然会绘制到超出区域
- SkiaChart: Texts including axis labels, tooltips, toolbox and legend are not rendered. HOT 7
- [Question] Is this RN 74 / Expo 51 ready? HOT 1
- ReferenceError: Property 'document' doesn't exist HOT 4
- I am unable to use only react-native-svg only It is giving error to install @shopify/react-native-skia also but I want to use react-native-svg only HOT 1
- I am using the react-native-echarts component in the flatlist and it is not scolling when I am putting two fingers then it is scrolling in android HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-native-echarts.