博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ios中core Plot (2)
阅读量:7126 次
发布时间:2019-06-28

本文共 1940 字,大约阅读时间需要 6 分钟。

#import "ViewController.h"@interface ViewController ()//指定要画得view@property(nonatomic,assign)CPTGraphHostingView *hostview;//指定画布@property(nonatomic,retain)CPTXYGraph *graph;@property(nonatomic,retain)NSMutableArray *data;@end@implementation ViewController- (void)viewDidLoad{    [super viewDidLoad];    self.data=[NSMutableArray array];    for (int i=0; i<50; i++) {                id x=[NSNumber numberWithInt:i];        id y=[NSNumber numberWithInt:(i+0.11)];        [self.data addObject:@{
@"x":x,@"y":y}]; } self.hostview=[[CPTGraphHostingView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)]; //创建x,Y轴画布 self.graph=[[[CPTXYGraph alloc] initWithFrame:CGRectZero] autorelease]; //设置主题 CPTTheme *them=[CPTTheme themeNamed:kCPTStocksTheme]; //设置x.y周画布的主题 [self.graph applyTheme:them]; self.graph.paddingBottom=0.0f; self.graph.paddingLeft=0.0f; self.graph.paddingRight=0.0f; self.graph.paddingTop=0.0f; self.hostview.hostedGraph=self.graph; [self.view addSubview:self.hostview]; CPTMutableLineStyle *linestyle=[CPTMutableLineStyle lineStyle]; linestyle.lineWidth=3.0f; linestyle.lineColor=[CPTColor redColor]; linestyle.miterLimit=1.0f; CPTScatterPlot *scatter=[[CPTScatterPlot alloc] init]; scatter.dataLineStyle=linestyle; scatter.dataSource=self; scatter.identifier=@"red"; [self.graph addPlot:scatter]; }-(NSUInteger)numberOfRecordsForPlot:(CPTPlot *)plot;{ return self.data.count;}-(NSNumber *)numberForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index{ NSString *key= (fieldEnum==CPTScatterPlotFieldX?@"x":@"y"); NSDictionary *dic=self.data[index]; NSLog(@"%@--->%@",key,dic[key]); return dic[key]; }- (void)didReceiveMemoryWarning{ [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated.}- (void)dealloc{ [_graph release]; [super dealloc];}@end

 

转载地址:http://lbeel.baihongyu.com/

你可能感兴趣的文章
PYTHON1.day10
查看>>
Android性能优化篇 [ 谷歌官方 ]
查看>>
ThinkPHP/---获取今天开始的时间戳与结束的时间戳
查看>>
matlib常用知识
查看>>
Directx11教程(43) 纹理映射(13)-动态纹理映射
查看>>
opengl 教程(13) 摄像机坐标系
查看>>
[leetcode-526-Beautiful Arrangement]
查看>>
yii CGridView colum 链接
查看>>
windows 如何将安装Anaconda之前已经安装的python版本(中已安装的库)移动到 Anaconda中...
查看>>
【OCP-12c】2019年CUUG OCP 071考试题库(79题)
查看>>
Centos 7.0 Linux - 给普通用户加sudo权限
查看>>
load data infile出现“ERROR 13 (HY000): Can't get stat of '/tmp/test2.txt' (Errcode: 2)”问题
查看>>
主席树的学习
查看>>
TOPCODER->使用方法->(1)如何注册
查看>>
(How to)使用IE9的F12开发人员工具分析模拟登陆网站(百度首页)的内部逻辑过程
查看>>
matplotlib的函数作用
查看>>
(转)医疗IT运维系统
查看>>
Oracle 给表添加备注
查看>>
python 设计模式之备忘录模式 (还没开始写)
查看>>
Linux 如何测试 IO 性能(磁盘读写速度)
查看>>