File tree Expand file tree Collapse file tree 5 files changed +75
-37
lines changed
Expand file tree Collapse file tree 5 files changed +75
-37
lines changed Original file line number Diff line number Diff line change 99 "dependencies" : {
1010 "react" : " 15.3.2" ,
1111 "react-native" : " 0.35.0" ,
12- "native-echarts" : " 0.1 .0"
12+ "native-echarts" : " 0.2 .0"
1313 },
1414 "jest" : {
1515 "preset" : " jest-react-native"
Original file line number Diff line number Diff line change 11{
22 "name" : " native-echarts" ,
3- "version" : " 0.1.2 " ,
3+ "version" : " 0.2.0 " ,
44 "description" : " echarts for react-native" ,
55 "main" : " src/index.js" ,
66 "directories" : {
Original file line number Diff line number Diff line change @@ -8,10 +8,11 @@ export default class App extends Component {
88 return (
99 < WebView
1010 scrollEnabled = { false }
11+ injectedJavaScript = { renderChart ( this . props ) }
1112 style = { {
1213 height : this . props . height || 400 ,
1314 } }
14- source = { { html : renderChart ( this . props . option ) } }
15+ source = { require ( './tpl.html' ) }
1516 />
1617 ) ;
1718 }
Original file line number Diff line number Diff line change 11import echarts from './echarts.min' ;
22import toString from '../../util/toString' ;
33
4- export default function renderChart ( option ) {
4+ export default function renderChart ( props ) {
5+ const height = props . height || 400 ;
56 return `
6- <!DOCTYPE html>\n
7- <html>
8- <head>
9- <title>echarts</title>
10- <meta http-equiv="content-type" content="text/html; charset=utf-8">
11- <style type="text/css">
12- html,body {
13- height: 100%;
14- width: 100%;
15- margin: 0;
16- padding: 0;
17- overflow: hidden;
18- }
19- #main {
20- height: 100%;
21- }
22- </style>
23- <script>
24- ${ echarts }
25- </script>
26- </head>
27-
28- <body>
29- <div id="main" ></div>
30- <script>
31- // 基于准备好的dom,初始化echarts实例
32- var myChart = echarts.init(document.getElementById('main'));
33- // 使用刚指定的配置项和数据显示图表。
34- myChart.setOption(${ toString ( option ) } );
35- </script>
36- <body>
37- <html>
38- `
7+ document.getElementById('main').style.height = "${ height } px";
8+ var myChart = echarts.init(document.getElementById('main'));
9+ myChart.setOption(${ toString ( props . option ) } );
10+ `
3911}
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments