FSLineChart 0.1.7

FSLineChart 0.1.7

测试已测试
Lang语言 Obj-CObjective C
许可 Apache 2
发布上次发布2015年3月

Arthur Guibert 维护。




  • Arthur Guibert

适用于 iOS 的折线图库。

屏幕截图

 

安装 FSLineChart

将 FSLineChart 项目的所有内容添加到您的目录,或者只需将以下行添加到您的 Podfile 中。

pod "FSLineChart"

如何使用

FSLineChart 是 UIView 的子类,因此它可以作为常规视图添加。阻塞结构允许您以您想要的方式格式化图表上显示的值。以下是一个简单的示例:

NSArray* months = @[@"January", @"February", @"March", @"April", @"May", @"June", @"July"];

FSLineChart* lineChart = [[FSLineChart alloc] initWithFrame:CGRectMake(20, 260, [UIScreen mainScreen].bounds.size.width - 40, 166)];

lineChart.labelForIndex = ^(NSUInteger item) {
    return months[item];
};

lineChart.labelForValue = ^(CGFloat value) {
    return [NSString stringWithFormat:@"%.02f", powf(10,value)];
};

[lineChart setChartData:chartData];

您还可以设置多个参数。其中一些参数包括 colorfillColor 必须在调用 setChartData 方法之前设置。所有这些属性都是可用的。

// Index label properties
@property (copy) FSLabelForIndexGetter labelForIndex;
@property (nonatomic, strong) UIFont* indexLabelFont;
@property (nonatomic) UIColor* indexLabelTextColor;
@property (nonatomic) UIColor* indexLabelBackgroundColor;

// Value label properties
@property (copy) FSLabelForValueGetter labelForValue;
@property (nonatomic, strong) UIFont* valueLabelFont;
@property (nonatomic) UIColor* valueLabelTextColor;
@property (nonatomic) UIColor* valueLabelBackgroundColor;
@property (nonatomic) ValueLabelPositionType valueLabelPosition;

// Number of visible step in the chart
@property (nonatomic) int gridStep;
@property (nonatomic) int verticalGridStep;
@property (nonatomic) int horizontalGridStep;

// Margin of the chart
@property (nonatomic) CGFloat margin;

@property (nonatomic) CGFloat axisWidth;
@property (nonatomic) CGFloat axisHeight;

// Decoration parameters, let you pick the color of the line as well as the color of the axis
@property (nonatomic, strong) UIColor* axisColor;
@property (nonatomic) CGFloat axisLineWidth;

// Chart parameters
@property (nonatomic, strong) UIColor* color;
@property (nonatomic, strong) UIColor* fillColor;
@property (nonatomic) CGFloat lineWidth;

// Data points
@property (nonatomic) BOOL displayDataPoint;
@property (nonatomic, strong) UIColor* dataPointColor;
@property (nonatomic, strong) UIColor* dataPointBackgroundColor;
@property (nonatomic) CGFloat dataPointRadius;

// Grid parameters
@property (nonatomic) BOOL drawInnerGrid;
@property (nonatomic, strong) UIColor* innerGridColor;
@property (nonatomic) CGFloat innerGridLineWidth;

// Smoothing
@property (nonatomic) BOOL bezierSmoothing;
@property (nonatomic) CGFloat bezierSmoothingTension;

// Animations
@property (nonatomic) CGFloat animationDuration;

示例

您可以通过克隆仓库来查看一个简单的示例。如果要查看在更大项目中集成的示例,我也在 ChartLoot 上使用 FSLineChart。