ASE Home Page Products Download Purchase Support About ASE
ChartDirector General
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  JsChartViewer.streamUpdate
Posted by Omar on Sep-08-2011 02:38
Hi Peter,

Can I use JsChartViewer.streamUpdate to load images already created with ChartDirector using $c->makeChart  ?

I want to created 5 or more images when the pages start loading and then load them sequentially when the page is done loading.

Already I use a javascript function to change the image src, but I want to see if there is no flick using streamUpdate.

Thanks

  Re: JsChartViewer.streamUpdate
Posted by Peter Kwan on Sep-08-2011 18:53
Hi Omar,

You can actually use your own Javascript (since you have already written that) to change the image src without flickering. The trick is double buffering. Instead of changing the visible <IMG> src, you may change a invisible <IMG> src (or use a standalone Javascript Image object). Then in the "onload" event of the invisible <IMG> (which occurs after the complete image is loaded), you can copy the src of the URL to your visible <IMG> src.

The "streamUpdate" is itself written in Javascript and it uses the above method to update the image. That's why there is no flickering.

If you would like to use "streamUpdate" instead of using your own Javascript, note that "streamUpdate" always loads the image using the same URL that loads the <IMG> in the first place. For example, if your <IMG> is originally using the URL "createAnImage.php", the streamUpdate will load the image again using the same URL "createAnImage.php". In a realtime chart, the "createAnImage.php" is supposed to return an updated image. For your case, you would need to design your "createAnImage.php" so that it will return the 5 images sequentially each time it is activated.

Personally, I think using your own Javacript to update the image should be easier, since you have already written that. Changing the code to use an invisible Image object and using an "onload" event to update the visible <IMG> should not be difficult.

Hope this can help.

Regards
Peter Kwan