接上文
本文主要介紹一些HXCharts的使用細節(jié)
標注值
- 標注值指的是下圖紅色標記的地方:

Snip20170904_123.png

Snip20170904_126.png

Snip20170904_127.png
儀表盤與圓形圖標注值的最大值需要自己傳
折線圖與柱狀圖標注值的最大值是根據(jù)傳入的valueArray中的最大值向上取整自動計算的(向上取整就是比如value是360,最大值則向上取整到400)
在折線圖、柱狀圖、儀表盤中都可以自定義標注值個數(shù),因為圖表實現(xiàn)方式有差異,設置標注值的方式也不同,下面是設置的地方
///折線圖
- (void)setValue:(NSArray *)valueArray withYLineCount:(int)count; ///count設置標注值個數(shù)
///柱狀圖
- (instancetype)initWithFrame:(CGRect)frame withMarkLabelCount:(int)markLabelCount withOrientationType:(OrientationType)type; ///markLabelCount設置標注值個數(shù)
///儀表盤
@property (nonatomic, assign) int markLabelCount;///標注值個數(shù)
顏色
柱狀圖 儀表盤 圓形圖支持漸變色和單色 折線圖只支持單色(沒想好折線圖的漸變色怎么使用好看)
下面是漸變色和單色的效果及設置方法
效果:

Snip20170904_133.png

Snip20170904_134.png
- 設置方法:
1.漸變色:
///漸變色數(shù)組
@property (nonatomic, strong) NSArray *colorArray;
///漸變色數(shù)組所占位置
@property (nonatomic, strong) NSArray *locations;
2.單色:
///單色
@property (nonatomic, strong) UIColor *singleColor;
柱狀圖的橫豎向設置

Snip20170904_136.png

Snip20170904_137.png
- 只要在初始化方法的地方選擇OrientationType即可
typedef NS_ENUM(NSInteger, OrientationType) {
OrientationHorizontal = 0,///橫向
OrientationVertical = 1,///豎向
};
- (instancetype)initWithFrame:(CGRect)frame withMarkLabelCount:(int)markLabelCount withOrientationType:(OrientationType)type;
環(huán)形圖初始化的標注值方位

image.png
HXRingChart *ring = [[HXRingChart alloc] initWithFrame:CGRectMake(ringChartX, ringChartY, ringChartWidth, ringChartHeight) markViewDirection:MarkViewDirectionRight];
如圖,標注值是在圖表右側,可以通過設置MarkViewDirection來選擇上下左右四個方位,MarkViewDirectionNone則標注值不顯示,圖表居中。
更多屬性請到.h文件查看
最后再發(fā)一遍demo地址:https://github.com/xuuhan/HXCharts