最近公司项目用到了折线图,所有就选了github上star最多的PNChart,但是文档真的不友好,各种相似的属性,并且没有备注,所有就把项目里做的标注给发出来。效果如图
- (void)coifigChartStyle:(PNLineChart *)lineChart withXArray:(NSArray *)xArray yArray:(NSArray *)yArray{
//设置坐标轴是否可见
// lineChart.showCoordinateAxis = YES;
[lineChart setXLabels:xArray];
//设置是否显示网格线
lineChart.showYGridLines = YES;
lineChart.showGenYLabels = YES;
//设置坐标轴宽度
lineChart.axisWidth = 2;
//是否曲线x显示
// _lineChart.showSmoothLines = YES;
//x轴y轴颜色
lineChart.axisColor = RGB(216, 216, 216);
//lineChart.axisWidth = 1;
//x轴字体颜色
lineChart.xLabelColor = RGB(216, 216, 216);
//y轴字体颜色
// lineChart.yLabelColor = RGB(216, 216, 216);
//是否显示x轴y轴
lineChart.showCoordinateAxis = NO;
//y轴分多少份
lineChart.yLabelNum = 7;
//显示标注
lineChart.showLabel = YES;
//y轴最大值
lineChart.yFixedValueMax = 130;
//y轴最小值
lineChart.yFixedValueMin = 0;
//y轴字体颜色
lineChart.yLabelColor = [UIColor clearColor];
//chartCavanWidth chartCavanHeight 可视范围
// lineChart.chartCavanHeight = 300;
PNLineChartData *data01 = [PNLineChartData new];
//显示点标注
data01.showPointLabel = YES;
//点标注字体
data01.pointLabelFont = SYSFONT_(9);
//点标注颜色
data01.color = [UIColor orangeColor];
//点标注个数
data01.itemCount = lineChart.xLabels.count;
//点标注样式,圆角 三角
data01.inflexionPointStyle = PNLineChartPointStyleCircle;
data01.getData = ^(NSUInteger index){
CGFloat yValue = [yArray[index] floatValue];
return [ PNLineChartDataItem dataItemWithY:yValue];
};
lineChart.chartData = @[data01];
//开始绘图
[lineChart strokeChart];
}