zoukankan      html  css  js  c++  java
  • CorePlot学习

    阅读这篇文章,指出它在国外    原文地址: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:方法就可以把图形会知道窗体。

    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包括多个CPTAxisCPTAxis中的标签元素能够自己定义的。


    10 动画







    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    svn命令
    samba配置
    查看登录用户who
    facl笔记
    计算100以内所有奇数的和以及所有偶数的和;分别显示之
    计算100以内所有能被3整除的正整数的和
    特殊权限:SUID,SGID,Sticky
    vi命令笔记
    nginx、fastCGI、php-fpm关系梳理(转载参考)
    Nginx + CGI/FastCGI + C/Cpp
  • 原文地址:https://www.cnblogs.com/hrhguanli/p/4690308.html
Copyright © 2011-2022 走看看