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

react-native 0.74.6环境 安装最新的库 无法运行 不报错 界面没有显示图表 #219

Open
Kstonelc opened this issue Dec 23, 2024 · 3 comments

Comments

@Kstonelc
Copy link

Kstonelc commented Dec 23, 2024

{ "name": "reactNativeEchartsTest", "version": "0.0.1", "private": true, "scripts": { "android": "react-native run-android", "ios": "react-native run-ios", "lint": "eslint .", "start": "react-native start", "test": "jest" }, "dependencies": { "@shopify/react-native-skia": "1.3.11", "@wuba/react-native-echarts": "2.0.0", "echarts": "^5.5.1", "react": "18.2.0", "react-native": "0.74.6", "react-native-gesture-handler": "^2.21.2", "react-native-svg": "^15.2.0" }, "devDependencies": { "@babel/core": "^7.20.0", "@babel/preset-env": "^7.20.0", "@babel/runtime": "^7.20.0", "@react-native-community/cli": "latest", "@react-native/babel-preset": "0.74.88", "@react-native/eslint-config": "0.74.88", "@react-native/metro-config": "0.74.88", "@react-native/typescript-config": "0.74.88", "@types/react": "^18.2.6", "@types/react-test-renderer": "^18.0.0", "babel-jest": "^29.6.3", "eslint": "^8.19.0", "jest": "^29.6.3", "prettier": "2.8.8", "react-test-renderer": "18.2.0", "typescript": "5.0.4" }, "engines": { "node": ">=18" } }

界面代码:
`import React, {useRef, useEffect} from 'react';
import * as echarts from 'echarts/core';
import {LineChart} from 'echarts/charts';
import {GridComponent} from 'echarts/components';
import {SVGRenderer, SvgChart} from '@wuba/react-native-echarts';
import {View, Text} from 'react-native';

echarts.use([SVGRenderer, LineChart, GridComponent]);

export default function App() {
const skiaRef = useRef(null);
useEffect(() => {
const option = {
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
},
yAxis: {
type: 'value',
},
series: [
{
data: [150, 230, 224, 218, 135, 147, 260],
type: 'line',
},
],
};
let chart;
if (skiaRef.current) {
chart = echarts.init(skiaRef.current, 'light', {
renderer: 'svg',
width: 400,
height: 400,
});
chart.setOption(option);
}

return () => chart?.dispose();

}, []);

return ;
}
`
无法显示图表 生产环境显示不了

@Kstonelc
Copy link
Author

使用npm下载 不生效 修改为yarn下载即可

@zhiqingchen
Copy link
Member

使用 npm 的话,依赖加上 zrender 看看

@zhiqingchen
Copy link
Member

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