commit
eeeaead411
|
|
@ -21,6 +21,7 @@ export default class App extends Component {
|
|||
height: this.props.height || 400,
|
||||
}}
|
||||
source={require('./tpl.html')}
|
||||
onMessage={event => this.props.onPress ? this.props.onPress(JSON.parse(event.nativeEvent.data)) : null}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -9,5 +9,18 @@ export default function renderChart(props) {
|
|||
document.getElementById('main').style.width = "${width}";
|
||||
var myChart = echarts.init(document.getElementById('main'));
|
||||
myChart.setOption(${toString(props.option)});
|
||||
myChart.on('click', function(params) {
|
||||
var seen = [];
|
||||
var paramsString = JSON.stringify(params, function(key, val) {
|
||||
if (val != null && typeof val == "object") {
|
||||
if (seen.indexOf(val) >= 0) {
|
||||
return;
|
||||
}
|
||||
seen.push(val);
|
||||
}
|
||||
return val;
|
||||
});
|
||||
window.postMessage(paramsString);
|
||||
});
|
||||
`
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue