gujjula / core-plot

Automatically exported from code.google.com/p/core-plot
0 stars 0 forks source link

Graph Appears Inverted when added as a subView #199

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

-(void)barPlot:(CPBarPlot *)plot barWasSelectedAtRecordIndex:(NSUInteger)index
{
    barChart.title = [NSString stringWithFormat:@"Amount Spent : $ %lu", (index+10)*(index+10)];

    DaysBarGraphViewController * viewDaysController = [[DaysBarGraphViewController alloc] init];

    [UIView beginAnimations:@"Animation" context:nil];
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:super.view cache:YES];

    CGRect frame = viewDaysController.view.frame;
    frame = CGRectMake(0,50, frame.size.width, frame.size.height);
    [viewDaysController.view setFrame:frame];

    [super.view addSubview:viewDaysController.view];

    [UIView commitAnimations];
    }

Original issue reported on code.google.com by abhishek...@gmail.com on 2 Sep 2010 at 4:30

GoogleCodeExporter commented 9 years ago
It works fine when i add the graph on the previous layer:   
[super.view.superview addSubview:viewDaysController.view];

Original comment by abhishek...@gmail.com on 2 Sep 2010 at 5:42

GoogleCodeExporter commented 9 years ago
Can you describe the problem better? Which one of these views is you 
CPLayerHostingView?

Original comment by eskr...@mac.com on 3 Sep 2010 at 12:01

GoogleCodeExporter commented 9 years ago
Hi Eric, thanks for showing your concern.

I believe i didn't choose the correct terminologies and that must have confused 
you.

Okay , so i have 3 View Controllers :- 

1. DataVisualizationViewController 
2. WeekBarGraphViewController
3. DaysBargraphViewController

I added WeekBarGraphViewController's view as a subview on 
DataVisualizationViewController upon occurrence of some event. Now when a bar 
from WeekBarGraphViewController's view is Tapped I want to add another subview 
which will be DaysBarGraphViewController's view on WeekBarGraphViewController. 
When i do the later the view of DaysBarGraphViewController is added as a 
subview on WeekBarGraphViewControllers's view but the graph on 
DaysBarGraphViewController gets inverted. 

Let me know if you need more information.

In addition to this i also wanted to ask about adding gestures on the graphs - 
like detecting swipes , pinches etcs as the generic code for doing so doesnt 
seems to work,
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {

NSLog(@" hello ");

UITouch *touch =[touches anyObject];

gestureStartPoint = [touch locationInView:self.view];

}

-(void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {

UITouch *touch = [touches anyObject];

CGPoint currentPosition = [touch locationInView :self.view];

CGFloat deltaX = fabsf(gestureStartPoint.x - currentPosition.x);

CGFloat deltaY = fabsf(gestureStartPoint.y - currentPosition.y);

if( deltaX > kMinimumGestureLength && deltaY <= kMaximumVariance) {

barChart.title = [NSString stringWithFormat:@"Horizontal : $ %lu"];

[self performSelector:@selector(eraseText) withObject:nil afterDelay:2];

}

else if (deltaY >= kMinimumGestureLength && deltaX <= kMaximumVariance) {

barChart.title = [NSString stringWithFormat:@"Vertical : $ %lu"];

[self performSelector:@selector(eraseText) withObject:nil afterDelay:2];

}

}

-(void)eraseText {

barChart.title =@"";

}

 I'm guessing may be because CPLayerHostingView is composed of many many Layers. Any hint on this will help to get me started. 

Thanks in advance 

Original comment by abhishek...@gmail.com on 3 Sep 2010 at 4:11

GoogleCodeExporter commented 9 years ago
Hi , SO i was able to get the swipes to work using the following functions :- 

(BOOL)  - plotSpace:shouldHandlePointingDeviceDownEvent:atPoint:
    Notifies that plot space intercepted a device down event.
(BOOL)  - plotSpace:shouldHandlePointingDeviceDraggedEvent:atPoint:
    Notifies that plot space intercepted a device dragged event.
(BOOL)  - plotSpace:shouldHandlePointingDeviceCancelledEvent:
    Notifies that plot space intercepted a device cancelled event.
(BOOL)  - plotSpace:shouldHandlePointingDeviceUpEvent:atPoint:
    Notifies that plot space intercepted a device up event.
(CGPoint)   - plotSpace:willDisplaceBy:
    Notifies that plot space is going to scroll.
(CPPlotRange *)     - plotSpace:willChangePlotRangeTo:forCoordinate:
    Notifies that plot space is going to change a plot range.
(void)  - plotSpace:didChangePlotRangeForCoordinate:
    Notifies that plot space has changed a plot range. 

However I'm still finding difficulty with the multi touch gestures ( I'm mainly 
focusing on pinch and zoom ) i read this post where markmac tried to subclass 
CPLayerHosting View in order to comment of the code that was disabling 
multi-touches but that didn't work for me. I am hoping anyone will have a valid 
solution of implementing multi-touch gestures on graphs.

-Thanks

Original comment by abhishek...@gmail.com on 3 Sep 2010 at 9:17

GoogleCodeExporter commented 9 years ago
I'm afraid multitouch is not yet handled, as you have discovered. It is a high 
priority.

Original comment by drewmcco...@mac.com on 12 Sep 2010 at 10:10