【问题标题】:CorePlot: How to Get a Correct Value After Zoom? How to Get A Correct Scale Number After Zoom?CorePlot:如何在缩放后获得正确的值?缩放后如何获得正确的比例数字?
【发布时间】:2011-10-26 09:25:56
【问题描述】:
  1. 如何在缩放后获得正确的值?
  2. 如何在缩放后获得正确的比例数字?
  3. 如何将 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


    【解决方案1】:

    您在转换不同绘图比例的值时遇到的问题是舍入问题。您以像素为单位获得触摸点。在任何绘图范围内只有有限数量的像素。如果放大,则会增加任意两个给定值之间的像素数。

    要将 y 轴向右移动,请减少右侧填充并确保宿主视图填满屏幕的宽度。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-08-01
      • 1970-01-01
      • 1970-01-01
      • 2020-01-21
      • 2021-09-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多