Skip to content

liyinjie01/DVLineChart

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 

Repository files navigation

DVLineChart

A Simple LineChartView For Simple data statistics

img

简单描述

这是一个使用时比较简单的一个图表,可以自定义多个属性,可以滚动显示图表,并且支持“点”和“点处文字”的点击事件,两个点击时间调用同一个方法(主要是点比较小,难以选中,所以将“点处文字”添加了上去,使其可以点击),双击缩小,变大,缩放。字体、颜色、间隙这些属性就不给大家介绍了,介绍些其他属性的作用,若有疑问,可以参照Demo

####x轴数据<DVLineChartView.h>

/**
 *  x轴的文字集合
 */
@property (strong, nonatomic) NSArray *xAxisTitleArray;


  • x轴的数据就是从上面的数组属性中取出的

####y轴数据<DVLineChartView.h>

/**
 *  y轴的最大值
 */
@property (assign, nonatomic) CGFloat yAxisMaxValue;
/**
 *  y轴分为几段(默认5)
 */
@property (assign, nonatomic) int numberOfYAxisElements;


  • y轴的数据是由y轴的一个最大值和y轴需要分为几段来确定的

####坐标点数据<DVPlot.h>

/**
 *  坐标点数组
 */
@property (strong, nonatomic) NSArray *pointArray;
/**
 *  是否将颜色充满图表
 */
@property (assign, nonatomic, getter=isChartViewFill) BOOL chartViewFill;


  • 坐标点是通过上面这个数组中的数据来画出来的
  • 下面的BOOL值代表的是“是否要给图表下面填充颜色”

####设置图表背景颜色


/**
 *  视图的背景颜色
 */
@property (strong, nonatomic) UIColor *backColor;


####横向分割线是否显示(横向分割线颜色)<DVLineChartView.h>

/**
 *  是否显示横向分割线
 */
@property (assign, nonatomic, getter=isShowSeparate) BOOL showSeparate;

/**
 *  横向分割线的颜色
 */
@property (strong, nonatomic) UIColor *separateColor;

####是否显示坐标点处的文字


/**
 *  是否显示点Label
 */
@property (assign, nonatomic, getter=isShowPointLabel) BOOL showPointLabel;

####y轴和屏幕左侧的距离


/**
 *  y轴与左侧的间距
 */
@property (assign, nonatomic) CGFloat yAxisViewWidth;

####如果数值是百分比数值

/**
 *  y轴数值是否添加百分号(if the number you need to show is percentage value, you can through this property to control it. default is NO)
 */
@property (assign, nonatomic, getter=isPercent) BOOL percent;
  • 当传入的数值是百分比数值时,通过这个属性来添加百分号 ####坐标点是否添加点击事件

/**
 *  点是否允许点击
 */
@property (assign, nonatomic, getter=isPointUserInteractionEnabled) BOOL pointUserInteractionEnabled;


@property (weak, nonatomic) id<DVLineChartViewDelegate> delegate;


@protocol DVLineChartViewDelegate <NSObject>

@optional
- (void)lineChartView:(DVLineChartView *)lineChartView DidClickPointAtIndex:(NSInteger)index;

@end

####这个图表框架可以支持多条线 img


/**
 *  存放plot的数组
 */
@property (strong, nonatomic) NSMutableArray *plots;

- (void)addPlot:(DVPlot *)plot;
  • 通过上面的方法和属性可以画出多条线出来

####我们可以通过一个索引值来对图表进行定位

/**
 *  定位时的索引值
 */
@property (assign, nonatomic) NSInteger index;
  • 当 index<0 时,无法进行定位

About

A Simple LineChart For Simple data statistics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Languages

  • Objective-C 100.0%