0

Realtime dynamic charting

asked 2011-03-15 11:54:20 +0800

dagarwal82 gravatar image dagarwal82
246 4

I want to have a grid which will be showing charts (charts are to be added to the model dynamically) and I want charts to keep refresh (Precisely I want to collect all the data and then refresh all charts in one go).

If I use rowrenderer and creates charts in there and everytime model is changed, it is creating the charts again(Right?). Is there anything built in.

delete flag offensive retag edit

10 Replies

Sort by ยป oldest newest

answered 2011-03-15 20:28:44 +0800

samchuang gravatar image samchuang
4084 4

Hi,

I don't understand your question clearly.

When model changed, will call rowrenderer. Your rowrenderer shall modify the chart's model to create chart.

link publish delete flag offensive edit

answered 2011-03-16 02:03:12 +0800

dagarwal82 gravatar image dagarwal82
246 4

updated 2011-03-16 02:04:22 +0800

MyRowRenderer extends RowRenderer {
@Override
	public void render(Row row, Object data) throws Exception {
                  List<MyModel> modelList = (List<MyModel>)data;
                for(MyModel myModel : modelList) {
                    Panel panel = new Panel();
       	            panel.setTitle(myModel.getTitle());
		    Panelchildren panelChild = new Panelchildren();
	            panelChild.setParent(panel);
                 
                     Listbox lb = new Listbox();
	             Listitem item1 = new Listitem();
          
                     Listcell cell1 = new Listcell("Total Memory");
  		     Listcell cell2 = new Listcell(myModel.getTotalMemory());
                     cell1.setParent(item1);
	             cell2.setParent(item1);
                     Chart chart = new Chart();
		     chart.setType("line");

		     chart.setHeight("100px");
		     chart.setWidth("190px");
                     XYModel model = new SimpleXYModel();
                     model.addValue("tm", myModel.getTimeStamp(), myModel.getCurrentValue());
                     chart.setModel(model);

                      chart.setParent(panelChild);
		      panel.setParent(row);

}

        }

}
class MyModel  {
    long timestamp;
    long currentValue;
    String title;
//getter/setter
}
my.zul {
<grid id="grid" rowRenderer="@{myRowRenderer}" model="@{win$MyController.modeList, load-after='statTimer.onTimer'}" sizedByContent="true">
</grid>
<timer id="statTimer" repeat="true" delay="3000"/>
}
class MyController extends GenericForwardComposer{
List<MyModel> modelList;
public void onTimer$statTimer(Event event) {

    modelList.clear();   
    repopulateModelList();
}

}
Now, the problem is : 1) I see flickering grid, ie. grid is disappeared and then rendered again. 2) Makes the page very slow. 3) I want to be able to show the real time graphs, ie. no flickering, only graphs lines are moving 4) I want to be able to add/remove charts in the grid, ie adding more MyModel to the modelList. 5) Since the renderer is creating the whole grid again then how am I supposed to hold the old model of the chart.
link publish delete flag offensive edit

answered 2011-03-17 06:38:30 +0800

dagarwal82 gravatar image dagarwal82
246 4

Any thoughts ?

link publish delete flag offensive edit

answered 2011-03-17 19:46:01 +0800

samchuang gravatar image samchuang
4084 4

updated 2011-03-17 19:47:28 +0800

Hi

without a runnable example, I don't know which operation will cause slow performance.

from the code, I am guessing, when you use jfreechart, you create all the chart image at server side. if this is the cause, maybe you can try to use client side chart engine
for example, you can try to use flashchart or try Fusion chart

or maybe you can log each operation, to find out which one is the real cause

link publish delete flag offensive edit

answered 2011-03-18 11:10:24 +0800

dagarwal82 gravatar image dagarwal82
246 4

Thanks samchuang.

You are right, I am using default chart implementation of zk (may be its jfreechart) and it is sending png images each time the model is changed.

I need to show around 40 real time charts( It is a dashboard). can you guide me implementing the best client side charts ( I was evaluating JSChart and HighChart and found them quite good but not sure how to implement with zk)

link publish delete flag offensive edit

answered 2011-03-20 20:11:00 +0800

samchuang gravatar image samchuang
4084 4

Hi

so, you don't consider use fusion chart or flashchart in ZK ?

if you wanna to integreate other chart engine, you can refer to ZK_Client-side_Reference

link publish delete flag offensive edit

answered 2011-03-21 01:59:19 +0800

dagarwal82 gravatar image dagarwal82
246 4

Will it be feasible to show 40 fusion/flash charts in a single page? (Performance wise) ? I however tried fusionchart but was getting error 'Widget required....' . I have integrated JSChart now, testing the performance( However there seems to no JSON support for the dataset in JSChart and x coordinate calibration have some problems. Couldn't integrate Highchart)

link publish delete flag offensive edit

answered 2011-03-21 20:05:43 +0800

samchuang gravatar image samchuang
4084 4

do you download Fusion chart from here ?

It should be working

link publish delete flag offensive edit

answered 2011-03-21 23:15:26 +0800

dagarwal82 gravatar image dagarwal82
246 4

Yes, I downloaded zk-Fusionchart-bin-2.2.50-FL-2011-02-21.zip from the same location and taken out the jar file inside it and added it to the WEB-INF/lib folder of my zk project. Then, I added a code to create fusionchart in my composer class(<fusionchart> tag doesn't work and not recognizable) and it throws an error alert while rendering the zul file as something like 'Widget class required for <Fusionchart zYbV82> with default'

link publish delete flag offensive edit

answered 2011-03-22 20:22:00 +0800

samchuang gravatar image samchuang
4084 4

I tried the zk-Fusionchart-demo-2.2.50-FL-2011-02-21, and it's working, maybe you can check it

link publish delete flag offensive edit
Your reply
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

RSS

Stats

Asked: 2011-03-15 11:54:20 +0800

Seen: 1,262 times

Last updated: Mar 22 '11

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