Hey Charles, 2009/11/5 Hubbard, Charles W <[email protected]>: > I have recently been looking at a nice way to implement a “zoom” feature for > a WCartesianChart widget. What I’d like to do is to drag the mouse across > the area I want to zoom into and then redraw the plot with the axis ranges > set accordingly. Toward that end, I spent much of yesterday learning how to > intercept and deal with mouseWentDown and mouseWentUp events (surprisingly > easy!). As part of this, I need a way to convert from mouse coordinates > (I’ve been using the set of coordinates returned through the .widget() > method on the event, so they are with respect to the widget borders) to > chart coordinates. Because I know the size of my WCartesianChart widget, > and I can query the sizes of the various paddings that have been applied to > the edges, and I know the sizes of the X and Y axes (I manually set these to > min and max of my values), the conversion from mouse coordinates to chart > coordinates should be fairly straightforward. In fact, everything *almost* > works. With my current test program, I can click somewhere inside the chart
Ideally, the first extension to WCartesianChart is to provide you with these mapping methods, since how the chart is being padded is a bit of an internal affair. These methods could be added quite easily... And I guess that would help you to implement a zooming feature (without the dragging around part) ? There is indeed a bit of extra padding going on, 5 pixels, and this happens in WAxis.C:498 - 504. There you can also see what logic is applied there. The padding was stolen from looking at graphs generated by R if I remeber correctly. > By the way, I am using Ubuntu 9.04 with the 2.2.4-3 witty package made > available by Pau Garcia i Quiles. Test code was compiled using gcc/g++ > 4.2.4 and the wthttpd library. I interact with the resulting application > using Firefox 3.5.3. Okay. That should be all the same, the charting code is still pretty much the same in Wt 3.0. Regards, koen ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ witty-interest mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/witty-interest
