...
|
...
|
@@ -6,6 +6,7 @@ import { |
|
|
StyleSheet,
|
|
|
View,
|
|
|
Text,
|
|
|
Platform,
|
|
|
} from 'react-native';
|
|
|
|
|
|
export default class ChartView extends Component {
|
...
|
...
|
@@ -15,13 +16,16 @@ export default class ChartView extends Component { |
|
|
|
|
|
render() {
|
|
|
|
|
|
let xString = '';
|
|
|
if (this.props.xData.length!==0) {
|
|
|
xString = this.props.xData.reduce((previous, current, index, array) => {
|
|
|
if (index==1) {
|
|
|
previous = `\'` + previous + `\'`;
|
|
|
}
|
|
|
return previous + ','+ `\'` + current+ `\'`;
|
|
|
});
|
|
|
}
|
|
|
|
|
|
let xString = this.props.xData.reduce((previous, current, index, array) => {
|
|
|
if (index==1) {
|
|
|
previous = `\'` + previous + `\'`;
|
|
|
}
|
|
|
return previous + ','+ `\'` + current+ `\'`;
|
|
|
});
|
|
|
// xString = '\'' + xString;
|
|
|
|
|
|
console.log(xString);
|
...
|
...
|
@@ -46,6 +50,8 @@ export default class ChartView extends Component { |
|
|
}
|
|
|
}
|
|
|
|
|
|
const chartHeight = (Platform.OS === 'android') ? 250 : 175;
|
|
|
|
|
|
const styles = StyleSheet.create({
|
|
|
container: {
|
|
|
backgroundColor: 'white',
|
...
|
...
|
@@ -57,22 +63,24 @@ const styles = StyleSheet.create({ |
|
|
marginLeft: 15,
|
|
|
},
|
|
|
chartStyle: {
|
|
|
height: 175,
|
|
|
height: chartHeight,
|
|
|
marginLeft: -45,
|
|
|
marginRight: -45,
|
|
|
marginBottom: 15,
|
|
|
},
|
|
|
});
|
|
|
|
|
|
const fontSize = (Platform.OS === 'android') ? 14 : 24;
|
|
|
|
|
|
function getHTMLString(xData,yData) {
|
|
|
const HTML = `
|
|
|
<!DOCTYPE html>
|
|
|
<html style="height: 100%">
|
|
|
<html style="height: 100%; margin: 0px;">
|
|
|
<head>
|
|
|
<meta charset="utf-8">
|
|
|
</head>
|
|
|
<body style="height: 100%; margin: 0">
|
|
|
<div id="container" style="height: 100%"></div>
|
|
|
<body style="height: 100%; margin: 0px;">
|
|
|
<div id="container" style="height: 100%; margin: 0px; min-height: 250px;"></div>
|
|
|
<script type="text/javascript" src="http://cdn.bootcss.com/echarts/3.0.0/echarts.min.js"></script>
|
|
|
<script type="text/javascript">
|
|
|
var dom = document.getElementById("container");
|
...
|
...
|
@@ -100,7 +108,7 @@ function getHTMLString(xData,yData) { |
|
|
axisLabel: {
|
|
|
textStyle: {
|
|
|
color: '#b1b1b1',
|
|
|
fontSize: 24,
|
|
|
fontSize: ` + fontSize + `,
|
|
|
},
|
|
|
},
|
|
|
splitLine: {
|
...
|
...
|
@@ -132,7 +140,7 @@ function getHTMLString(xData,yData) { |
|
|
backgroundColor: 'orange',
|
|
|
formatter: '{c}',
|
|
|
textStyle: {
|
|
|
fontSize: 24,
|
|
|
fontSize: ` + fontSize + `,
|
|
|
},
|
|
|
axisPointer: {
|
|
|
type: 'line',
|
...
|
...
|
|