zoukankan      html  css  js  c++  java
  • [翻译] FSLineChart

    FSLineChart

    A line chart library for iOS.

    一个iOS的线状图控件。

    Installing FSLineChart - 安装

    Add the contents of the FSLineChart project to your directory or simply add the following line to your Podfile:

    将下面一句话添加到你的Podfile文件当中:

    pod "FSLineChart"
    

    How to use - 使用

    FSLineChart is a subclass of UIView so it can be added as regular view. The block structure allows you to format the values displayed on the chart the way you want. Here is a simple example:

    FSLineChart继承自UIView,所以,你可以像普通view那样子来使用它。在block当中,你可以构造你需要显示的数据,以下是使用示例:

    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];

    You can also set several parameters. All those properties are available:

    你也可以单独的设置参数,所有你可以设置的参数都在下面:

    // 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;

    Examples - 例子

    You can clone the repo to see a simple example. I'm also using FSLineChart on ChartLoot if you want to see the integration in a bigger project.

    你可以参考示例来查看,我在这个项目ChartLoot中使用了这个控件,你们可以去看看。

  • 相关阅读:
    XHTML学习笔记 Part3:核心属性
    XHTML学习笔记 Part2:核心元素
    XHTML学习笔记 part1
    北航非全日制-软件学院考研攻略(经验仅来自于2019年,2020年招生简章有变动,需谨慎)
    为什么能抓到网站https传输的明文密码?------顺便说说“知乎”和“支付宝”的安全性对比
    JetBrain系列学生免费授权
    印象笔记模板推荐使用
    测试用例评审总结与规范
    Django入门
    Django在根据models生成数据库表时报 __init__() missing 1 required positional argument: 'on_delete'
  • 原文地址:https://www.cnblogs.com/YouXianMing/p/4214344.html
Copyright © 2011-2022 走看看