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 9
9
"dependencies" : {
10
10
"react" : " 15.3.2" ,
11
11
"react-native" : " 0.35.0" ,
12
- "native-echarts" : " 0.1 .0"
12
+ "native-echarts" : " 0.2 .0"
13
13
},
14
14
"jest" : {
15
15
"preset" : " jest-react-native"
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " native-echarts" ,
3
- "version" : " 0.1.2 " ,
3
+ "version" : " 0.2.0 " ,
4
4
"description" : " echarts for react-native" ,
5
5
"main" : " src/index.js" ,
6
6
"directories" : {
Original file line number Diff line number Diff line change @@ -8,10 +8,11 @@ export default class App extends Component {
8
8
return (
9
9
< WebView
10
10
scrollEnabled = { false }
11
+ injectedJavaScript = { renderChart ( this . props ) }
11
12
style = { {
12
13
height : this . props . height || 400 ,
13
14
} }
14
- source = { { html : renderChart ( this . props . option ) } }
15
+ source = { require ( './tpl.html' ) }
15
16
/>
16
17
) ;
17
18
}
Original file line number Diff line number Diff line change 1
1
import echarts from './echarts.min' ;
2
2
import toString from '../../util/toString' ;
3
3
4
- export default function renderChart ( option ) {
4
+ export default function renderChart ( props ) {
5
+ const height = props . height || 400 ;
5
6
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
+ `
39
11
}
Load Diff Large diffs are not rendered by default.
You can’t perform that action at this time.
0 commit comments