diff --git a/package.json b/package.json index 2fb8ee5e..588581b0 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "native-echarts", - "version": "0.5.0", + "version": "0.7.0", "description": "echarts for react-native", "main": "src/index.js", "directories": { diff --git a/src/components/Echarts/index.js b/src/components/Echarts/index.js index fe86c8ce..50ad89a8 100644 --- a/src/components/Echarts/index.js +++ b/src/components/Echarts/index.js @@ -1,7 +1,9 @@ import React, { Component } from 'react'; -import { WebView, View, StyleSheet, Platform } from 'react-native'; +import { View, StyleSheet, Platform } from 'react-native'; import renderChart from './renderChart'; import echarts from './echarts.min'; +import WebView from "react-native-webview"; +import getTpl from "./tpl" ; export default class App extends Component { @@ -9,13 +11,21 @@ export default class App extends Component { super(props); this.setNewOption = this.setNewOption.bind(this); } - + componentWillReceiveProps(nextProps) { if(nextProps.option !== this.props.option) { - this.refs.chart.reload(); + // this.refs.chart.reload(); + if(Platform.OS === 'android'){ + this.refs.chart.reload(); + }else { + this.setNewOption(nextProps.option) ; + } } } + shouldComponentUpdate() { + return false ; + } setNewOption(option) { this.refs.chart.postMessage(JSON.stringify(option)); @@ -23,21 +33,20 @@ export default class App extends Component { render() { return ( - - this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null} - /> - + + this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null} + /> + ); } } diff --git a/src/components/Echarts/tpl.html b/src/components/Echarts/tpl.html deleted file mode 100644 index ca20a315..00000000 --- a/src/components/Echarts/tpl.html +++ /dev/null @@ -1,63 +0,0 @@ - - - - - echarts - - - - - - - -
- - diff --git a/src/components/Echarts/tpl.js b/src/components/Echarts/tpl.js new file mode 100644 index 00000000..485bf1c8 --- /dev/null +++ b/src/components/Echarts/tpl.js @@ -0,0 +1,28 @@ +export default ()=>` + + + + echarts + + + + + + + +
+ + +` ; \ No newline at end of file