CorePlot学习一
来源:互联网 发布:webstorm mac 破解版 编辑:程序博客网 时间:2024/05/21 06:01
阅读这篇国外文章手记而已 原文地址:https://github.com/core-plot/core-plot/wiki/High-Level-Design-Overview
强烈推荐阅读该博客:http://blog.csdn.net/kmyhy/article/details/7819661
首先,我们先看一下我们绘制图表是的区域划分:
这个图标的学习很有必要,在以后的编程中,你会有深刻体会,各个区域的划分,和名称
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
CPTXYGraph
creates an instance of CPTXYAxisSet
, andCPTXYPlotSpace
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 动画
- CorePlot学习一
- CorePlot学习
- CorePlot学习零---安装
- CorePlot
- CorePlot学习二---[深入浅出iOS库]之图形库CorePlot
- CorePlot学习七---坐标轴的详细分析
- CorePlot学习八---如何更新数据
- CorePlot学习七---坐标轴的详细分析
- CorePlot学习三---自定义CorePlot label及majorGridLine莫名其妙消失的Bug
- CorePlot学习五----corePlot使用技巧及iOS内存优化之道
- CorePlot学习四--- 如何定制Core Plot主题
- CorePlot-曲线图
- CorePlot-饼状体
- corePlot柱状图
- CorePlot学习六---点击scatterPlot中的symbol点时弹出相应的注释
- CorePlot开源框架
- iOS coreplot 画图 入门
- CorePlot画表数据
- 11g 单实例重新安装GRID报ASM已经存在
- 最大团问题-分支限界算法
- Filter
- MPMoviePlayerViewController 播放完不退出
- junit作为多线程环境的启动入口
- CorePlot学习一
- levelDB的安装与小范例
- c++中的继承中的问题
- 网络库总结
- struts2 常量配置及详解
- We7的区县网站群建设策略
- 使用Splatting在PowerShell中传递参数
- linux 进程间信号量管理程序之sem_timedwait使用
- 赵雅智_Android Paint