GBLineChart.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. //
  2. // GBLineChart.h
  3. // GBChartDemo
  4. //
  5. // Created by midas on 2018/12/10.
  6. // Copyright © 2018 Midas. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "GBLineChartData.h"
  10. typedef NS_ENUM(NSInteger, GBXLabelAlignmentStyle) {
  11. GBXLabelAlignmentStyleFitXAxis = 0,
  12. GBXLabelAlignmentStyleFullXAxis = 1
  13. };
  14. @interface GBLineChart : UIView
  15. /******************* xLabel属性 ***************************/
  16. /** xlabel宽度,默认是根据x轴宽度计算平分或字体最大宽度取最大值 */
  17. @property (nonatomic, assign) CGFloat xLabelWidth;
  18. /** xlabel字体 默认10 */
  19. @property (nonatomic, strong) UIFont *xLabelFont;
  20. /** xlabel颜色 默认是graycolor */
  21. @property (nonatomic, strong) UIColor *xLabelColor;
  22. /** x轴上的标题 */
  23. @property (nonatomic, strong) NSArray *xLabelTitles;
  24. /** xLabel旋转角度,默认为0 */
  25. @property (nonatomic, assign) CGFloat xLabelRotationAngle;
  26. /** xLabel对齐方式 */
  27. @property (nonatomic, assign) GBXLabelAlignmentStyle xLabelAlignmentStyle;
  28. /******************* yLabel属性 ***************************/
  29. /** 是否显示Y坐标值,默认YES */
  30. @property (nonatomic, assign) BOOL showYLabels;
  31. /** ylabel高度,默认根据y轴高度计算平分 */
  32. @property (nonatomic) CGFloat yLabelHeight;
  33. /** ylabel字体 默认10 */
  34. @property (nonatomic) UIFont *yLabelFont;
  35. /** ylabel颜色 默认graycolor */
  36. @property (nonatomic) UIColor *yLabelColor;
  37. /** y轴上的标题 */
  38. @property (nonatomic, strong) NSArray *yLabelTitles;
  39. /** y轴label数据的格式,默认是 @"%1.f" */
  40. @property (nonatomic, strong) NSString *yLabelFormat;
  41. /**Block formatter for custom string in y-axis labels. If not set, defaults to yLabelFormat */
  42. @property (nonatomic, copy) NSString* (^yLabelBlockFormatter)(CGFloat value);
  43. /******************* 坐标轴属性 ***************************/
  44. /** 距左边距,默认25 */
  45. @property (nonatomic, assign) CGFloat chartMarginLeft;
  46. /** 距右边距,默认25 */
  47. @property (nonatomic, assign) CGFloat chartMarginRight;
  48. /** 距上边距,默认0 */
  49. @property (nonatomic, assign) CGFloat chartMarginTop;
  50. /** 距下边距,默认25 */
  51. @property (nonatomic, assign) CGFloat chartMarginBottom;
  52. /** 是否显示x y坐标轴,默认YES */
  53. @property (nonatomic, assign) BOOL showCoordinateAxis;
  54. /** 坐标轴线宽,默认为1 */
  55. @property (nonatomic, assign) CGFloat coordinateAxisLineWidth;
  56. /** 坐标轴颜色,默认darkgray */
  57. @property (nonatomic, strong) UIColor *coordinateAxisColor;
  58. /** x坐标轴颜色,默认darkgray */
  59. @property (nonatomic, strong) UIColor *xAxisColor;
  60. /** y坐标轴颜色,默认darkgray */
  61. @property (nonatomic, strong) UIColor *yAxisColor;
  62. /******************* 横向网格线属性 ***************************/
  63. /** 是否显示网格线,默认YES */
  64. @property (nonatomic, assign) BOOL showYGridsLine;
  65. /** 网格线线宽,默认为1 */
  66. @property (nonatomic, assign) CGFloat yGridsLineWidth;
  67. /** 风格线颜色,默认是lightgray */
  68. @property (nonatomic, strong) UIColor *yGridsLineColor;
  69. /** 风格线是否dash 默认YES */
  70. @property (nonatomic, assign) BOOL showYGridsLineDash;
  71. /******************* 折线属性 ***************************/
  72. /**折线图上的数据*/
  73. @property (nonatomic, strong) NSArray <GBLineChartData *> *lineChartDatas;
  74. /** 是否有动画,默认YES */
  75. @property (nonatomic, assign) BOOL displayAnimated;
  76. /** 是否圆滑曲线,默认NO */
  77. @property (nonatomic) BOOL showSmoothLines;
  78. /******************* 竖线属性 ***************************/
  79. /**是否显示竖线 默认为NO*/
  80. @property (nonatomic, assign) BOOL showVerticalLine;
  81. /**竖线宽度 默认为1*/
  82. @property (nonatomic, assign) CGFloat verticalLineWidth;
  83. /**竖线颜色 默认黑色*/
  84. @property (nonatomic, strong) UIColor *verticalLineColor;
  85. /** 竖线x值*/
  86. @property (nonatomic, assign) CGFloat verticalLineXValue;
  87. /******************* Method ***************************/
  88. /** 画折线图 */
  89. - (void)strokeChart;
  90. /** 更新折线图
  91. @param datas GBLineChart数组
  92. */
  93. - (void)updateChartDatas:(NSArray <GBLineChartData *> *)datas;
  94. @end