-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.js
60 lines (56 loc) · 1.72 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
'use strict';
import React from 'react-native';
import ichart from './lib/ichart-wrapper.js';
const {
View,
WebView,
} = React;
export default React.createClass({
propTypes: {
render: React.PropTypes.func.isRequired
},
render: function() {
let renderString = this.props.render.toString();
return (
<View>
<WebView
html={this.createHTML(renderString)}
style={this.props.style}
automaticallyAdjustContentInsets={false}
contentInset={{top: 0, right: 0, bottom: 0, left: 0}}
/>
</View>
);
},
createHTML: function(render) {
var html = `
<DOCTYPE html>
<html>
<head>
<title>iChart</title>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1, width=device-width, user-scalable=no">
<style>
body{margin:0;padding:0;}
#canvas-container{width:100%;height:100%;};
</style>
<script>
window.onerror=function (){
alert(JSON.stringify(arguments));
};
${ichart}
</script>
</head>
<body>
<div id="canvas-container"></div>
<script>
$(function(){
(${render})();
});
</script>
</body>
</html>
`;
return html;
}
});