CorePlot学习
2015-07-30 19:00
267 查看
阅读这篇文章,指出它在国外 原文地址:https://github.com/core-plot/core-plot/wiki/High-Level-Design-Overview
强烈推荐阅读该博客:/article/1355629.html
首先,我们先看一下我们绘制图表是的区域划分:
这个图标的学习非常有必要,在以后的编程中,你会有深刻体会,各个区域的划分。和名称
2 再来看看这个CorePlot开源图形库的类的层次结构 。便于我们源代码的理解
3 再来看一下他的成员对象和各个层的树形结构
4 图表视图的动画层分析
UIView的核心动画层,CALayer并不适合产生高质量的矢量图形。而且它也不支持事件处理,因此,Core Plot layers继承于
画图方法包含例如以下:
当我们绘制矢量图形时,就不用重写(override)-
5
看一下该类的定义:
the
而Plot Spaces就是元素原型和坐标系的映射关系集合,
一个PLot space 元素原型会知道图表上。必需要实现下面方法:完毕数据和坐标空间的转换
一个graph能够包括多个原型单元的。仅仅只是我们一般经常使用地就是一个而已。
10 动画
强烈推荐阅读该博客:/article/1355629.html
首先,我们先看一下我们绘制图表是的区域划分:
这个图标的学习非常有必要,在以后的编程中,你会有深刻体会,各个区域的划分。和名称
2 再来看看这个CorePlot开源图形库的类的层次结构 。便于我们源代码的理解
3 再来看一下他的成员对象和各个层的树形结构
4 图表视图的动画层分析
UIView的核心动画层,CALayer并不适合产生高质量的矢量图形。而且它也不支持事件处理,因此,Core Plot layers继承于
CPTLayer。而
CPTLayer是CALayer的子类,仅仅只是做了扩展。
CPTLayer包括画图方法,可以绘制高质量的矢量图形。而且可以处理事件
画图方法包含例如以下:
-(void)renderAsVectorInContext:(CGContextRef)context; -(void)recursivelyRenderInContext:(CGContextRef)context; -(NSData *)dataForPDFRepresentationOfLayer;
当我们绘制矢量图形时,就不用重写(override)-
drawInContext:方法,而是仅仅需重写-
renderAsVectorInContext:方法就可以把图形会知道窗体。
5
Graphs 分析
CPTGraph是Core Plot的核心类,在coreplot中graph就是整个图表,包含:坐标轴,标签,标题,以及多个图表元素。
看一下该类的定义:
@interface CPTGraph : CPTBorderedLayer @property (nonatomic, readwrite, copy) NSString *title; //标题 @property (nonatomic, readwrite, copy) CPTTextStyle *titleTextStyle; //标题文本格式 @property (nonatomic, readwrite, assign) CGPoint titleDisplacement; //标题位置 @property (nonatomic, readwrite, assign) CPTRectAnchor titlePlotAreaFrameAnchor; //我眼下觉得是PlotArea的原点 @property (nonatomic, readwrite, retain) CPTAxisSet *axisSet; //坐标轴设置 @property (nonatomic, readwrite, retain) CPTPlotAreaFrame *plotAreaFrame; //PlotArea的fram @property (nonatomic, readonly, retain) CPTPlotSpace *defaultPlotSpace; //还没理解 @property (nonatomic, readwrite, retain) NSArray *topDownLayerOrder; // @property (nonatomic, readwrite, retain) CPTLegend *legend; @property (nonatomic, readwrite, assign) CPTRectAnchor legendAnchor; @property (nonatomic, readwrite, assign) CGPoint legendDisplacement; -(void)reloadData; -(void)reloadDataIfNeeded; -(NSArray *)allPlots; -(CPTPlot *)plotAtIndex:(NSUInteger)index; -(CPTPlot *)plotWithIdentifier:(id <NSCopying>)identifier; -(void)addPlot:(CPTPlot *)plot; -(void)addPlot:(CPTPlot *)plot toPlotSpace:(CPTPlotSpace *)space; -(void)removePlot:(CPTPlot *)plot; -(void)removePlotWithIdentifier:(id <NSCopying>)identifier; -(void)insertPlot:(CPTPlot *)plot atIndex:(NSUInteger)index; -(void)insertPlot:(CPTPlot *)plot atIndex:(NSUInteger)index intoPlotSpace:(CPTPlotSpace *)space; -(NSArray *)allPlotSpaces; -(CPTPlotSpace *)plotSpaceAtIndex:(NSUInteger)index; -(CPTPlotSpace *)plotSpaceWithIdentifier:(id <NSCopying>)identifier; -(void)addPlotSpace:(CPTPlotSpace *)space; -(void)removePlotSpace:(CPTPlotSpace *)plotSpace; -(void)applyTheme:(CPTTheme *)theme; @end
the
CPTXYGraphcreates an instance of
CPTXYAxisSet, and
CPTXYPlotSpace
6 Plot Area
这个事我们图表显示的区域,该区域被坐标轴限制在一定方位内。能够显示栅格在该区域,每一个图表视图仅仅能有一个图标区域。7 Plot Spaces
我这里想称Plot space为图表元素原型,比方说柱状图,他有很多其它个柱元素组成。当中的一个就是元素原型。这时个人理解而Plot Spaces就是元素原型和坐标系的映射关系集合,
一个PLot space 元素原型会知道图表上。必需要实现下面方法:完毕数据和坐标空间的转换
-(CGPoint)plotAreaViewPointForPlotPoint:(NSDecimal *)plotPoint; -(CGPoint)plotAreaViewPointForDoublePrecisionPlotPoint:(double *)plotPoint; -(void)plotPoint:(NSDecimal *)plotPoint forPlotAreaViewPoint:(CGPoint)point; -(void)doublePrecisionPlotPoint:(double *)plotPoint forPlotAreaViewPoint:(CGPoint)point;
一个graph能够包括多个原型单元的。仅仅只是我们一般经常使用地就是一个而已。
8 Plots
Plot就是一个数据在图表中的表现形式。比方条形,柱状型等。CPTPlot的dataSource方法
@protocol CPTPlotDataSource <NSObject> -(NSUInteger)numberOfRecords; @optional // Implement one of the following -(NSArray *)numbersForPlot:(CPTPlot *)plot field:(NSUInteger)fieldEnum recordIndexRange:(NSRange)indexRange; -(NSNumber *)numberForPlot:(CPPlot *)plot field:(NSUInteger)fieldEnum recordIndex:(NSUInteger)index; @end
9 Axes
坐标轴CPTAxis和
CPTPlotSpace有密切关系,
CPTXYAxisSet包括多个
CPTAxis。
CPTAxis中的标签元素能够自己定义的。
10 动画
相关文章推荐
- Android中Handler的简单应用(一)
- 基于Spark的用户分析系统
- 1024. Palindromic Number (25)
- Problem Killer(递推)
- sort和qsort的用法
- BZOJ 1041 圆上的整点
- HDOJ(1018)
- VS2013 编译libevent 并且使用!
- 四舍五入、上取整、下取整
- 手写二分查找
- Aircrack-ng支持网卡列表(上)
- 【leetcode】Valid Palindrome
- UIButton 传递参数
- Hadoop的text通过set(Text t)或set(String s),getLength与getBytes().length的值可能不同的原因
- 引子——从Mac OS X的Lion说起
- C# 写的一个生成随机汉语名字的小程序
- Hadoop中HDFS写入文件的原理剖析
- ajax请求跨域问题-通过jsonp方式解决
- Codeforces Round #313 (Div. 2) Problem E - Gerald and Giant Chess
- Memcached使用小记