-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I'm trying use ECharts in zul, but it doesn't work.
Base on MVVM, I implement the code referred to the official site of ECharts. I put html in zul, there is javascript which initialize echarts object and call the java function to retrieve the data to set in the echart object. But it doesn't work at all.
My code is referred to the following:
<html>
<body>
<div id="main" style="height:400px"></div>
<script src="http://echarts.baidu.com/build/dist/echarts.js" type="text/javascript"></script>
<script type="text/javascript">
function getECharts()
{
//initialize object of echarts base on prepared dom
var dom = document.getElementById('main');
var myChart = echarts.init(dom);
//get the data by calling function in Java
var option = zkbind.$('$searchWin').command('getTestData');
// set data in object of echarts
myChart.setOption(option);
}
</script>
</body>
</html>
My questions are what's the possible problem with my implementation? Is Echart not compatible with ZK?
Thanks.
Sorry if this sounds a bit devastating:
In fact there's hardly anything right with your attempt.
The script file you are referring to doesn't even initialize the echarts
variable so any further attempt below that will fail.
Then your file doesn't look like a zul file and misses the MVVM specific bindings.
Next your usage of the zkbind.$
API makes me think you haven't fully understood the basics of ZK's client binding.
Invoking a binder.command
will send a command (with optional data) to the server but does not receive data - for that you have to use binder.after
and handle data in a callback.
Since there's nothing worth fixing I took the freedom to implement an integration prototype available on zkfiddle: http://zkfiddle.org/sample/uhk3i7/3-echarts (Feel free to copy/paste/change as you like)
I'd strongly recommend reading the related documentation or get professional ZK-support for your application requirements.
Asked: 2018-04-11 13:32:34 +0800
Seen: 11 times
Last updated: Apr 12 '18
Facing issue in masking on phone [closed]
coerceFromString_ override no longer works from 6.5.1 [closed]
Execute Javascript on component visible
Is there a way to resolve view model properties as input to client side javascripts?
scrollbar listner for 2 grid [closed]
Theme javascript wpd file not found