0

Problem Using ECharts

asked 2018-04-11 13:32:34 +0800

lightbluesky gravatar image lightbluesky
0 1

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.

delete flag offensive retag edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2018-04-12 16:47:13 +0800

cor3000 gravatar image cor3000
4293 1 7
ZK Team

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.

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow
2 followers

RSS

Stats

Asked: 2018-04-11 13:32:34 +0800

Seen: 10 times

Last updated: Apr 12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More