I plan to draw a line chart to show the trend of the stock price. And the user can select the time period and stock codes, so the line chart will contain some stocks price(all the selected stocsk will be shown in one line chart) in the given period.

Since the number of the line and time period are not stable, and we also need to fetch price data every second. How to do that? I know I should use "DataPoint_Init" and "ListAppend" to add the price.

But since we have lots of price point, and not sure about the number of the line. How to control that? I mean how to use the cycle or loop in the line chart. Will you please give some example or instructions. 

Thanks a lot.


I'm not sure I fully understood your question but I'll give some guidelines that hope might help you:

  • If you want to show stock prices for different stock codes, you will need to add each of the stock prices for each code to a separate series.
  • Regarding the automatic update, there's two different approaches for this: either the page periodically polls changes and re-renders (polling) the chart or the server notifies of existent changes (push). Pooling is the simpler way to implement but you have to be careful about the load you might put on the server if the polling period is low and the number of users is high.

To implement automatic pooling there's at least one forge component that you can you to help you implementing that.

Take a look a webblock AutoRefreshWidget_Click in component UIProvider.

Here's a sample eSpace that might help you on this and give us some feedback if it worked.