【发布时间】:2011-10-26 09:25:56
【问题描述】:
- 如何在缩放后获得正确的值?
- 如何在缩放后获得正确的比例数字?
- 如何将 Yaxis 放在另一侧,如下图所示
我现在遇到的问题是如果触摸图表我可以得到正确的Y值,那么你可以获得正确的Y值,但是如果我放大,值会出错!
我尝试使用这个函数来获取比例
-(BOOL)plotSpace:(CPTPlotSpace*)space shouldScaleBy:(CGFloat)interactionScale aboutPoint:(CGPoint)interactionPoint
但我得到的刻度数不正确
请大家帮忙!!!
这是正确的屏幕截图:
这是错误的
-(BOOL)plotSpace:(CPTPlotSpace*)space shouldScaleBy:(CGFloat)interactionScale aboutPoint:(CGPoint)interactionPoint
{
NSDecimal plotPoint[2];
CPTXYPlotSpace *xySpace = (CPTXYPlotSpace *)space;
[xySpace plotPoint:plotPoint forPlotAreaViewPoint:interactionPoint];
NSLog(@"Dragg Event Scale: %f",real_scaleValue);
NSString *showingcontent_testing=[NSString stringWithFormat:@"Scale Y VAlue $:%f",
([[NSDecimalNumber decimalNumberWithDecimal:plotPoint[CPTCoordinateY]] doubleValue])];
return YES;
}
// This method is call when user touch & drag on the plot space.
- (BOOL)plotSpace:(CPTPlotSpace *)space shouldHandlePointingDeviceDraggedEvent:(id)event atPoint:(CGPoint)point
{
if( ((self.view.frame.size.height- point.y+20)<324)
&&((self.view.frame.size.height- point.y+20)>22))
{
NSDecimal plotPoint[2];
CPTXYPlotSpace *xySpace = (CPTXYPlotSpace *)space;
[xySpace plotPoint:plotPoint forPlotAreaViewPoint:point];
NSLog(@"Dragg Event Scale: %f",real_scaleValue);
showingcontent=[NSString stringWithFormat:@"Price $:%f",
(([[NSDecimalNumber decimalNumberWithDecimal:plotPoint[CPTCoordinateY]] doubleValue])*real_scaleValue)-13.42623-5.573770-0.163934];
current_price_show.text=showingcontent;
[self.view bringSubviewToFront:current_price_show];
CGRect separator_line_frame = separator_line.frame;
separator_line_frame.origin.y =self.view.frame.size.height- point.y+20;
// final y destination
separator_line.frame = separator_line_frame;
[self.view bringSubviewToFront:separator_line];
}
return YES;
}
【问题讨论】:
标签: iphone charts zooming core-plot