接上文
本文主要介紹一些HXCharts的使用細(xì)節(jié)
標(biāo)注值
- 標(biāo)注值指的是下圖紅色標(biāo)記的地方:
儀表盤與圓形圖標(biāo)注值的最大值需要自己傳
折線圖與柱狀圖標(biāo)注值的最大值是根據(jù)傳入的valueArray中的最大值向上取整自動(dòng)計(jì)算的(向上取整就是比如value是360拧篮,最大值則向上取整到400)
在折線圖史飞、柱狀圖、儀表盤中都可以自定義標(biāo)注值個(gè)數(shù)瓷翻,因?yàn)閳D表實(shí)現(xiàn)方式有差異聚凹,設(shè)置標(biāo)注值的方式也不同,下面是設(shè)置的地方
///折線圖
- (void)setValue:(NSArray *)valueArray withYLineCount:(int)count; ///count設(shè)置標(biāo)注值個(gè)數(shù)
///柱狀圖
- (instancetype)initWithFrame:(CGRect)frame withMarkLabelCount:(int)markLabelCount withOrientationType:(OrientationType)type; ///markLabelCount設(shè)置標(biāo)注值個(gè)數(shù)
///儀表盤
@property (nonatomic, assign) int markLabelCount;///標(biāo)注值個(gè)數(shù)
顏色
柱狀圖 儀表盤 圓形圖支持漸變色和單色 折線圖只支持單色(沒想好折線圖的漸變色怎么使用好看)
下面是漸變色和單色的效果及設(shè)置方法
效果:
- 設(shè)置方法:
1.漸變色:
///漸變色數(shù)組
@property (nonatomic, strong) NSArray *colorArray;
///漸變色數(shù)組所占位置
@property (nonatomic, strong) NSArray *locations;
2.單色:
///單色
@property (nonatomic, strong) UIColor *singleColor;
柱狀圖的橫豎向設(shè)置
- 只要在初始化方法的地方選擇OrientationType即可
typedef NS_ENUM(NSInteger, OrientationType) {
OrientationHorizontal = 0,///橫向
OrientationVertical = 1,///豎向
};
- (instancetype)initWithFrame:(CGRect)frame withMarkLabelCount:(int)markLabelCount withOrientationType:(OrientationType)type;
環(huán)形圖初始化的標(biāo)注值方位
HXRingChart *ring = [[HXRingChart alloc] initWithFrame:CGRectMake(ringChartX, ringChartY, ringChartWidth, ringChartHeight) markViewDirection:MarkViewDirectionRight];
如圖齐帚,標(biāo)注值是在圖表右側(cè)妒牙,可以通過設(shè)置MarkViewDirection來選擇上下左右四個(gè)方位,MarkViewDirectionNone則標(biāo)注值不顯示对妄,圖表居中湘今。
更多屬性請(qǐng)到.h文件查看
最后再發(fā)一遍demo地址:https://github.com/xuuhan/HXCharts