保持y轴固定在地方?

编程入门 行业动态 更新时间:2024-10-23 23:24:47
本文介绍了保持y轴固定在地方?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

这是继续这个问题的代码.... 只允许在core-plot barchart中水平滚动?

this is the code in the continuation of this question....Allow horizontal scrolling only in the core-plot barchart?

-(BOOL)pointingDeviceDraggedAtPoint:(CGPoint)interactionPoint { if ( !self.allowsUserInteraction || !self.graph.plotArea ) { return NO; } CGPoint pointInPlotArea = [self.graph.plotArea convertPoint:interactionPoint toLayer:self.graph.plotArea]; if ( isDragging ) { pointInPlotArea.y = lastDragPoint.y;//-- Madhup Changed it for allwoing scrolling only in horizontal direction --// //-- Madhup Changed it for allwoing scrolling only in horizontal direction --// //CGPoint displacement = CGPointMake(pointInPlotArea.x-lastDragPoint.x, pointInPlotArea.y-lastDragPoint.y); CGPoint displacement = CGPointMake(pointInPlotArea.x-lastDragPoint.x, 0); //--******************************--// CGPoint pointToUse = pointInPlotArea; // Allow delegate to override if ( [self.delegate respondsToSelector:@selector(plotSpace:willDisplaceBy:)] ) { displacement = [self.delegate plotSpace:self willDisplaceBy:displacement]; pointToUse = CGPointMake(lastDragPoint.x+displacement.x, lastDragPoint.y+displacement.y); } NSDecimal lastPoint[2], newPoint[2]; [self plotPoint:lastPoint forPlotAreaViewPoint:lastDragPoint]; [self plotPoint:newPoint forPlotAreaViewPoint:pointToUse]; CPPlotRange *newRangeX = [[self.xRange copy] autorelease]; CPPlotRange *newRangeY = [[self.yRange copy] autorelease]; NSDecimal shiftX = CPDecimalSubtract(lastPoint[0], newPoint[0]); NSDecimal shiftY = CPDecimalSubtract(lastPoint[1], newPoint[1]); newRangeX.location = CPDecimalAdd(newRangeX.location, shiftX); newRangeY.location = CPDecimalAdd(newRangeY.location, shiftY); // Delegate override if ( [self.delegate respondsToSelector:@selector(plotSpace:willChangePlotRangeTo:forCoordinate:)] ) { newRangeX = [self.delegate plotSpace:self willChangePlotRangeTo:newRangeX forCoordinate:CPCoordinateX]; newRangeY = [self.delegate plotSpace:self willChangePlotRangeTo:newRangeY forCoordinate:CPCoordinateY]; } self.xRange = newRangeX; self.yRange = newRangeY; //-- Madhup Changed it for keeping y axis fixed --// NSLog(@"%@",self.graph.axisSet.axes); NSMutableArray *axisArr= [[NSMutableArray alloc] initWithArray:self.graph.axisSet.axes]; CPXYAxis *yAxis = [axisArr objectAtIndex:1]; CGPoint point = yAxis.position; point.y -= lastDragPoint.x; yAxis.position = point; [axisArr replaceObjectAtIndex:1 withObject:yAxis]; self.graph.axisSet.axes = axisArr; [axisArr release]; NSLog(@"%@",self.graph.axisSet.axes); //--******************************--// lastDragPoint = pointInPlotArea; return YES; } return NO; }

现在从代码中你可以看到我能够停止滚动的地图只在水平方向,但仍然我不能保持y轴固定。我已经在这个方法中写了一些代码,但它似乎不工作。

Now from the code you people can see that i am able to stop the scrolling of map only in horizontal direction, but still I am not able to keep the y-axis fixed. I have written some code for that in this method too but it does not seem to be working.

推荐答案

如果你想修复滚动时添加此行

if you want to fix axis when scrolling add this lines

CPTXYAxisSet *axisSet = (CPTXYAxisSet *)_graph.axisSet; axisSet.xAxis.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0]; axisSet.yAxis.axisConstraints = [CPTConstraints constraintWithLowerOffset:0.0];

更多推荐

保持y轴固定在地方?

本文发布于:2023-11-26 08:10:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1633319.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:地方

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!