DVBarChartView.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. //
  2. // DVBarChartView.h
  3. // xxxxx
  4. //
  5. // Created by Fire on 15/11/11.
  6. // Copyright © 2015年 DuoLaiDian. All rights reserved.
  7. //
  8. #import <UIKit/UIKit.h>
  9. #import "DVPlot.h"
  10. @class DVBarChartView;
  11. @protocol DVBarChartViewDelegate <NSObject>
  12. @optional
  13. - (void)barChartView:(DVBarChartView *)barChartView didSelectedBarAtIndex:(NSInteger)index;
  14. @end
  15. @interface DVBarChartView : UIView
  16. @property (weak, nonatomic) id<DVBarChartViewDelegate> delegate;
  17. /**
  18. * 文字大小
  19. */
  20. @property (strong, nonatomic) UIFont *textFont;
  21. /**
  22. * 文字颜色
  23. */
  24. @property (strong, nonatomic) UIColor *textColor;
  25. /**
  26. * x轴文字与坐标轴间隙
  27. */
  28. @property (assign, nonatomic) CGFloat xAxisTextGap;
  29. /**
  30. * 坐标轴颜色
  31. */
  32. @property (strong, nonatomic) UIColor *axisColor;
  33. /**
  34. * x轴的文字集合
  35. */
  36. @property (strong, nonatomic) NSArray *xAxisTitleArray;
  37. /**
  38. * 柱与柱之间的间距
  39. */
  40. @property (assign, nonatomic) CGFloat barGap;
  41. /**
  42. * 柱的宽度
  43. */
  44. @property (assign, nonatomic) CGFloat barWidth;
  45. /**
  46. * 柱的颜色
  47. */
  48. @property (strong, nonatomic) UIColor *barColor;
  49. /**
  50. * 柱的颜色
  51. */
  52. @property (strong, nonatomic) UIColor *barColor2;
  53. /**
  54. * 柱的颜色
  55. */
  56. @property (strong, nonatomic) UIColor *barColor3;
  57. /**
  58. * 柱的选中的颜色
  59. */
  60. @property (strong, nonatomic) UIColor *barSelectedColor;
  61. /**
  62. * 存放y轴数值的数组
  63. */
  64. @property (strong, nonatomic) NSMutableArray *xValues;
  65. /**
  66. * 存放第二组数据
  67. */
  68. @property (strong,nonatomic) NSMutableArray *xValues2;
  69. /**
  70. * 存放第三组数据
  71. */
  72. @property (strong,nonatomic) NSMutableArray *xValues3;
  73. /**
  74. * y值的标题数组
  75. */
  76. @property (strong, nonatomic) NSArray *xTitles;
  77. /**
  78. * y值的标题数组2
  79. */
  80. @property (strong, nonatomic) NSArray *xTitles2;
  81. /**
  82. * y值的标题数组3
  83. */
  84. @property (strong, nonatomic) NSArray *xTitles3;
  85. /**
  86. * y轴文字与坐标轴间隙
  87. */
  88. @property (assign, nonatomic) CGFloat yAxisTextGap;
  89. /**
  90. * y轴的最大值
  91. */
  92. @property (assign, nonatomic) CGFloat yAxisMaxValue;
  93. /**
  94. * y轴分为几段
  95. */
  96. @property (assign, nonatomic) int numberOfYAxisElements;
  97. /**
  98. * y轴与左侧的间距
  99. */
  100. @property (assign, nonatomic) CGFloat yAxisViewWidth;
  101. /**
  102. * y轴数值是否添加百分号
  103. */
  104. @property (assign, nonatomic, getter=isPercent) BOOL percent;
  105. /**
  106. * 是否显示点Label
  107. */
  108. @property (assign, nonatomic, getter=isShowPointLabel) BOOL showPointLabel;
  109. /**
  110. * 视图的背景颜色
  111. */
  112. @property (strong, nonatomic) UIColor *backColor;
  113. /**
  114. * 视图的背景颜色
  115. */
  116. @property (strong, nonatomic) UIColor *backColor2;
  117. /**
  118. * 视图的背景颜色
  119. */
  120. @property (strong, nonatomic) UIColor *backColor3;
  121. /**
  122. * 点是否允许点击
  123. */
  124. @property (assign, nonatomic, getter=isBarUserInteractionEnabled) BOOL barUserInteractionEnabled;
  125. /**
  126. * 标记选中哪一个柱子
  127. */
  128. @property (assign, nonatomic) NSInteger index;
  129. /**
  130. * 是否横屏
  131. */
  132. @property (assign,nonatomic,getter=isLandspace) BOOL landspace;
  133. /**
  134. * 是否是截图
  135. */
  136. @property (assign,nonatomic,getter=isShotImage) BOOL shotImage;
  137. /**
  138. * 图例名称 1
  139. */
  140. @property (strong,nonatomic) NSString *legendTitle1;
  141. /**
  142. * 图例名称 2
  143. */
  144. @property (strong,nonatomic) NSString *legendTitle2;
  145. /**
  146. * 快速创建方法
  147. */
  148. + (instancetype)barChartView;
  149. - (void)addPlot:(NSArray *)plot;
  150. - (void)removePlot;
  151. - (void)addPlot2:(NSArray *)plot;
  152. - (void)removePlot2;
  153. - (void)addPlot3:(NSArray *)plot;
  154. - (void)removePlot3;
  155. - (void)removeAllPlot;
  156. - (void)draw;
  157. -(void)selectedIndex:(NSInteger)index;
  158. @end