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

Message ListMessage List     Post MessagePost Message

  question about JsChartViewer streamUpdate
Posted by Joe McEnaney on Dec-01-2011 04:21
Hi Peter,

First - thanks so much for this great product. I use it for financial charting and have had my client - a day trader - say that these charts are excellent.

I'm doing an update to put in streaming charts using the JsChartViewer code.


function updateDisplay()
{
    if (window.JsChartViewer)
        JsChartViewer.get('mainChart').streamUpdate();
}
window.setInterval("updateDisplay()", 3000);


All good, the streaming works perfectly.  Now - above my chart - i have a number of links to quickly change the Interval, for example, I look up a chart for AAPL and the chart displays a 6 month daily chart.  using the links above it, I can quickly swap the chart to show a 1 day, 2 day, 30 day, 1 year, 5 year, 10 year etc.  That's a simple javascript replacement of the image src attribute and also works perfectly.

I have noticed though that when the streaming is turned on, it will refresh the original src attribute of the image, not the current one. So if the page loads with a 6 month chart, and I use the hyperlinks to change that to a 5 day chart - the chart will soon refresh back to a 6 month chart.

Is there a way to tell it to 'refresh' or perhaps just put in code to stop and start the streamUpdate?

thanks for all you assistance.

best

Joe

  Re: question about JsChartViewer streamUpdate
Posted by Peter Kwan on Dec-02-2011 01:47
Hi Joe,

Currently, the only way to "reset" the JsChartViewer is to delete the <IMG> tag or to reload the web page.

For your case, you may consider the following method:

(a) Since you can directly do a "javascript replacement of the image src attribute", you may use similar method to update the chart periodically (instead of using streamUpdate). In this way, you do not need to use streamUpdate at all.

(b) Instead of using "javascript replacement of the image src attribute", you may use "javascript replacement of the entire <IMG> tag". (This is equivalent to removing the old tag in replacing it with a new tag.) I have just tried something like:

//xxx = the ID of the <DIV> container that contains the <IMG> tag
document.getElementById("xxx").innerHTML = "<img id='ChartImage1' src='realtimechart.php?xxx=10'>";

and it appears to work.

(Note: The above method is very basic. You may need some more code to avoid "flickering" when the <IMG> tag is replaced.)

(c) Instead of using "javascript replacement of the image src attribute", your Javascript may just reload the entire web page.

Hope this can help.

Regards
Peter Kwan