码迷,mamicode.com
首页 > 其他好文 > 详细

CorePlot学习 使用技巧

时间:2015-06-24 14:23:00      阅读:174      评论:0      收藏:0      [点我收藏+]

标签:

corePlot 使用技巧:

//设置内边距:
graph.plotAreaFrame.paddingLeft   +=5;
graph.plotAreaFrame.paddingTop    +=5;
graph.plotAreaFrame.paddingRight  +=5;
graph.plotAreaFrame.paddingBottom +=17.5;

 

[self setAllowPinchScaling:NO];//禁止缩放

 

//设置坐标只能按照X轴横向滑动:(其他方向请自行理解)
plotSpace.yRange = [CPTPlotRangeplotRangeWithLocation:CPTDecimalFromInt(0)length:CPTDecimalFromFloat(1)];

plotSpace.globalYRange = [CPTPlotRangeplotRangeWithLocation:CPTDecimalFromInt(0)length:CPTDecimalFromFloat(1)];

plotSpace.xRange = [CPTPlotRangeplotRangeWithLocation:CPTDecimalFromInt(1)length:CPTDecimalFromFloat(1)];

plotSpace.globalXRange = [CPTPlotRangeplotRangeWithLocation:CPTDecimalFromInt(0)length:CPTDecimalFromFloat(2)];

 
//自定义轴label:
x.axisLabels          = [self buildLabelTitle];

x.labelingPolicy      = CPTAxisLabelingPolicyNone;//当设置这个Policy之后,坐标轴label及背景线tick都需要自己绘制,否则显示为空,请不要过度惊慌

x.minorTickLocations  = [NSSetsetWithArray:locationLabels];

 
- (NSMutableSet*)buildLabelTitle

{

    NSMutableSet *newAxisLabels = [NSMutableSetset];

   

    CPTMutableTextStyle *textStyleB = [CPTMutableTextStyletextStyle];

    textStyleB.color = [CPTColorcolorWithComponentRed:CPTFloat((float)0x09/0xFF)green:CPTFloat((float)0x31/0xFF)blue:CPTFloat((float)0x4A/0xFF)alpha:CPTFloat(1.0)];

 


    int n = 1;

    for ( NSUInteger i =30; i > 0; i--)

    {

        CPTAxisLabel *newLabel = [[CPTAxisLabelalloc] initWithText:@“这里是内容”

                                                          textStyle:textStyleB];

        newLabel.tickLocation =CPTDecimalFromUnsignedInteger(n++);

        newLabel.offset = 5;

        [locationLabels addObject:[NSNumber numberWithFloat:(n-1) -0.25]];

        [locationLabels addObject:[NSNumber numberWithFloat:(n-1) +0.25]];

        [newAxisLabels addObject:newLabel];

        [newLabel release];

    }

    return newAxisLabels;

}

 

//刷新图表内容:
[[bar1graph] reloadData];

 

CorePlot学习 使用技巧

标签:

原文地址:http://www.cnblogs.com/mins/p/4597496.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!