Closed GoogleCodeExporter closed 9 years ago
You could possibly just make a CPBorderedLayer subclass called
CPSelectionLayer, and expose that layer via a property in the graph. That class
would have methods for positioning it in the plot space, and hiding it etc.
The layer would then be added on top of all other layers when it is visible.
Original comment by drewmcco...@mac.com
on 18 Feb 2011 at 3:46
This sounds like a specialized CPAnnotation. It just needs to handle the mouse
interaction to make it appear, disappear, and resize.
Original comment by eskr...@mac.com
on 19 Feb 2011 at 1:45
There are similarities, but I think it would be better to have a separate
entity called a selection rect. For example, people might want to customize its
appearance, perhaps putting little arrows or crosshairs in it, or something
like that.
The other thing is that it defines an area of the plot space, which a
CPPlotSpaceAnnotation is anchored to a single point. So there are some
fundamental differences, and it would probably be cleaner to make a custom
class to handle those differences.
Original comment by drewmcco...@mac.com
on 19 Feb 2011 at 4:03
I have a solution to draw an area selection rectangle.
I wrote a class "AreaSelectionRectangle" which draws a dashed rectangle with
Quartz, it only draws it, it's up to you on how to use it (for example to
select an area, or to zoom inside this area).
You just need to add the class to your Controller and set it as as subViews to
your CPLayerHostingView hostView
Then you need to put your CPXYGraph *graph to zPosition = -1
I've tried it on the example DatePlot and it works (but remember it just draws
a dashed rectangle and doesn't select any point yet).
Please try it (see attachment and let me know if code is good or crappy :-)
// --------------------------------------------------------------------------------
// Begin: code to add an area selection rectangle
// ----------------------------------------------------------------------------
myAreaSelection = [[AreaSelectionRectangle alloc] initWithFrame:[hostView bounds]];
NSArray *areaSelections = [[NSArray alloc] initWithObjects:myAreaSelection,nil];
// Add the areaSelections as a subView
// The same can be done in "Interface Builder" by putting
[hostView setSubviews:areaSelections];
[areaSelections release];
// Put the graph at zPosition -1 to display the areaSelection
graph.zPosition = -1;
// ------------------------------------------------------------------------------
// End: code to add an area selection rectangle
// ------------------------------------------------------------------------------
Original comment by celgil...@gmail.com
on 25 Feb 2011 at 11:33
Attachments:
[deleted comment]
The above code to put "myAreaSelection" as a "subView" for the "hostView" works
OK when "hostView" is not resized.
Since "myAreaSelection" is not set to autoresize I suggest doing it in
Interface Builder
It's better to put the AreaSelectionRectangle (NSView subclass) in Interface
Builder as a subview of "hostView"
and enable "Autosizing".
If you have a background (CPBorderedLayer) you must set its zPoisition to -2
and the CPXYGraph graph zPosition to -1.
Also in the above code we don't need an NSArray to put as a subView. We just
can use method addSubview:
hope this helps
Original comment by celgil...@gmail.com
on 25 Feb 2011 at 5:13
Moved to GitHub issue #10.
https://github.com/core-plot/core-plot/issues/10
Original comment by eskr...@mac.com
on 29 Dec 2013 at 1:40
Original issue reported on code.google.com by
drewmcco...@mac.com
on 18 Feb 2011 at 3:34