Hey Alessandro,

2008/5/28 Alessandro <[EMAIL PROTECTED]>:
> I've got a question regarding the CartesianChart, which is probably a
> general issue about charts.
>
> I create a CartesianChart, whose model gets updated after the chart
> has been painted (or should have been painted...). It seems that the
> chart is painted after the following function returns (see below). In
> my application I'll have a thread modifying the model and the chart
> should reflect the most recent data. Am I doing anything wrong?
>
> WApplication *createApplication(const WEnvironment& env) {
>       WApplication *app = new WApplication(env);
>       app->setTitle("Charts example");
>       app->root()->setPadding(10);
>       int nColumn = 3;
>       int nRow = 10;
>       Wt::WStandardItemModel* model = new Wt::WStandardItemModel(nRow,
> nColumn, app->root());
>       timeSeriesExample(model, app->root()); // add a few point to the
> model and create the chart, as it is shown in the Chart example of the
> wt distribution.
>       // why it's not painting the chart now?

The createApplication object should return a application object, and
nothing will be rendered before this function returns.

To get the behaviour you intend, you should probably use WTimer to
fire a slot from which you call addPoint(model).

You cannot manipulate the model from another "work" thread, unless you
take the WApplication lock (see Wt::WApplication::getUpdateLock()),
which prevents concurrent access to the application's state. If you do
it this way, you can still use a WTimer to periodically poll for
updates to the chart (the slot connected to the timer's timeout event
can then be empty).

If you want to "push" changes to the clients, then you can use
server-initiated updates (Wt::WApplication::enableUpdates), but this
currently does not work reliably through proxies (see the chat
example). Whenever we reach the point that server push does work well,
it is very easy to switch from "polling" to "pushing".

Regards,
koen

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
witty-interest mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/witty-interest

Reply via email to