entronad / react-native-echarts-demo Goto Github PK
View Code? Open in Web Editor NEWUsing echarts in react-native
License: MIT License
Using echarts in react-native
License: MIT License
formatter会在json序列化时过滤掉,但Y轴如果数据值很大的话会显示不全,gird.containLabel效果也不是很好
安装debug版本正常,打包hoc后页面就变成空白了
模拟器很快,真机显示要三四秒才显示,iphone6 plus ios12系统
不想要这种效果。怎么去了
按照文档,把web文件夹放过去,而且0.56rn版本你的webview 需要添加 originWhitelist={['*']} 参数的设置。不然ios也无法显示图标。
现在ios没问题,但是android不行,而且android 连dev模式都无法显示
Invariant Violation: Web View has been removed from React Native. It can now be installed and imported from react-native-webview instead of react-native.
项目中引入 react-native-webview
native-echarts
中的 WebView 改为从 react-native-webview
引入
import { WebView } from 'react-native-webview';
点击事件不被触发,并且点击会伴有灰色的遮罩若隐若现
相关代码如下:
export default class WebChart extends React.Component {
static defaultProps = {
option: {},
exScript: `
chart.on('click', (params) => {
console.log('click')
^^^^^^^^^^^^^^^^^^^ ------ this doesn't invoke !!
window.postMessage(JSON.stringify({
type: 'select',
payload: params,
}))
})
`,
onMessage: () => {},
}
componentDidUpdate(prevProps, prevState) {
const optionJson = JSON.stringify(this.props.option)
this.update(optionJson)
}
update = (optionJson) => {
this.webView.postMessage(optionJson)
}
render() {
return (
<View style={this.props.style}>
<WebView
ref={(elem) => { this.webView = elem }}
style={{ backgroundColor: 'rgba(0, 0, 0, 0)' }}
scrollEnabled={false}
scalesPageToFit={os !== 'ios'}
source={os === 'ios' ? html : { uri: 'file:///android_asset/web/WebChart/index.html' }}
injectedJavaScript={`
const chart = echarts.init(document.getElementById('main'), null, { renderer: 'svg' })
chart.setOption(${JSON.stringify(this.props.option)})
document.addEventListener('message', (e) => {
chart.setOption(JSON.parse(e.data), true)
})
${this.props.exScript}
`}
onMessage={(e) => { this.props.onMessage(JSON.parse(e.nativeEvent.data)) }}
/>
</View>
)
}
}
areaStyle: {
normal: {
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
offset: 0,
color: '#8ec6ad'
}, {
offset: 1,
color: '#ffe'
}])
}
}
类似这样的设置渐变色的怎么处理,在option中会报错,没有echarts对象,在exScript中定义,这里option也用不了
?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.