Interactive Charts

Added by Boris Grinac about 1 year ago

Hello Koen,
I have sent this question before to your email, but you asked me to enter it in this public forum, so that others would benefit from the discussion too.

We are trying to make interactive charts. Our application is simple: we need to display a sorted list of data labels in a separate view and update this sorted list as user moves cross hair cursor on the chart. The idea is to sort labels so that for each x point the minimum y label would be on top of the list.

We have studied the wt charts source and we have realized that charts are even more clever than we thought. There are two property settings:
void Wt::Chart::WCartesianChart::setCrosshairEnabled (bool crosshair = true)
void Wt::Chart::WCartesianChart::setFollowCurve (const WDataSeries * series)
and when we turn them ON, we have the cross hair cursor that follows the chart data points. By the way, this is not in examples, but this works! So most of the work is already done. Now we only need one small thing that we can not find: we need to report the data point with cross hair cursor to the server. We tried to catch MouseMove events, but they return pixel position on chart widget and it is not easy to calculate which data point we are pointing to.

We must be missing something and we need a hint.

Boris Grinac

Replies (2)

RE: Interactive Charts - Added by Ansif Ibrahimkutty 11 months ago

Hi Boris,

Did you able to fix the MouseMove events. I was looking for the same feature in Wt. My friend has added the javascript library( in Wt application, but i am worried if about security and that for this reason someone may not wish to activate it in the browser).


RE: Interactive Charts - Added by Roel Standaert 10 months ago

You can use WCartesianChart::mapFromDevice to get the (x,y) position in model coordinates.