#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=; i<; 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(, , , )]; //创建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

ios中core Plot (2)的更多相关文章

  1. iOS 使用 Core Plot 绘制统计图表入门

     本文转载至 http://blog.csdn.net/zhibudefeng/article/details/7677457   iOS(iPhone/iPad) 下图形组件有两个有名的,s7gra ...

  2. ios中Core Location跟Map Kit的基本使用

    地图类开发应用中,离不开地理位置跟MKMapView的使用,下面就记录下自己在使用这两个东西中学到的. 不过并不是所有苹果的设备都支持地理位置,我们在使用前应该做个判断,代码如下: BOOL loca ...

  3. 如何使用 Core Plot 的 API 帮助文档

    Core Plot 可是 iOS 下绝好的图表组件,虽说它的相关资料不甚丰富,特别是中文的,英文的还是有几篇不错的文章,不过 Core Plot 自身提供的 API 帮助文档,以及代码示例其实很有用的 ...

  4. iOS中数据库应用基础

    iOS 数据库入门 一.数据库简介 1.什么是数据库? 数据库(Database) 是按照数据结构来组织,存储和管理数据的仓库 数据库可以分为2大种类 关系型数据库(主流) PC端 Oracle My ...

  5. 谈谈iOS中的屏幕方向

    众所周知,iOS中提供了[UIDevice currentDevice].orientation与[UIApplication sharedApplication].statusBarOrientat ...

  6. iOS 图形处理 Core Graphics Quartz2D 教程

    Core Graphics Framework是一套基于C的API框架,使用了Quartz作为绘图引擎.它提供了低级别.轻量级.高保真度的2D渲染.该框架可以用于基于路径的 绘图.变换.颜色管理.脱屏 ...

  7. iOS中的数据持久化方式

    iOS中的数据持久化方式,基本上有以下四种:属性列表.对象归档.SQLite3和Core Data. 1.属性列表 涉及到的主要类:NSUserDefaults,一般 [NSUserDefaults ...

  8. ios中常见数据存储方式以及SQLite常用的语句

    在iOS中,根据不同的需求对应的有多种数据存储方式: 1.NSUserdefaults  将数据存储到沙盒中(library),方便易用,但是只能存储系统提供的数据类型(plist),不能存储自定义的 ...

  9. IOS中调用系统的电话、短信、邮件、浏览功能

    iOS开发系列--通讯录.蓝牙.内购.GameCenter.iCloud.Passbook系统服务开发汇总 2015-01-13 09:16 by KenshinCui, 26990 阅读, 35 评 ...

随机推荐

  1. Cesium中导入三维模型方法(dae到glft/bgltf) 【转】

    http://blog.csdn.net/l491453302/article/details/46766909 目录(?)[+] Cesium中目前支持gltf和bgltf两种格式.“gltf是kh ...

  2. Convert Sorted List to Binary Search Tree leetcode java

    题目: Given a singly linked list where elements are sorted in ascending order, convert it to a height ...

  3. 赋值操作符、复制构造函数、析构函数、static成员练习

    /** * 定义一个Employee类,包含雇员名字和一个唯一的雇员标识,为该类定义默认构造函数和参数为表示 * 雇员名字的string构造函数.如果该类需要复制构造函数或赋值操作符,实现这些函数 * ...

  4. python Selenium+phantomjs 小技巧

    1.元素模糊定位 如抓取下面列表: elements = doc("li[id^='result_']") 2.元素精确定位 elements =doc("div[cla ...

  5. 中文分词器ICTCLAS使用方法(Java)

    http://www.cnblogs.com/CheeseZH/archive/2012/11/27/2791037.html 吃水不忘挖井人,这篇文章给了我很大帮助:http://blog.csdn ...

  6. RAMPS1.4 3d打印控制板接线与测试3

    RAMPS1.4作为mega2560的拓展板插在mega板子上面.从而让mega板子可以控制3d打印机的工作.ramps上的接线至关重要,接错不仅不能打印,甚至还会烧坏器件和板子.请一定注意. 我的淘 ...

  7. Java扫描二维码进行会议签到思路

    1:签到页面都是同一个JSP页面 2:根据不同的会议ID进行拼接URL跳转页面进行签到 JSP页面代码如下 <%@ page language="java" pageEnco ...

  8. 开源的DirectUI界面库

    1. duilib简介 duilib是一个开源的DirectUI界面库,简洁但是功能强大.而且还是BSD的license,所以即便是在商业上,大家也可以安心使用.现在大家可以从这个网站获取到他们所有的 ...

  9. css 下边框

    float: left; width: 1200px; height: 42px; background-color: #fff0; /* background-color: #4f4aff; */ ...

  10. Angularjs 中的 controller

    接触过程序开发的小伙伴们对 MVC 的开发方式想必一点也不陌生,是的, angularjs 所採用的方式便是 MVVM 的开发方式,这里的 controller 即控制器 了解 controller ...