xujunwen

PNLineChart's inflexion Point support two sharp, such as cycle, square

... ... @@ -10,7 +10,6 @@
#import <QuartzCore/QuartzCore.h>
#import "PNChartDelegate.h"
@interface PNLineChart : UIView
/**
... ... @@ -48,8 +47,6 @@
@property (nonatomic) CGFloat chartMargin;
@property (nonatomic) BOOL showLabel;
... ...
This diff is collapsed. Click to expand it.
... ... @@ -5,14 +5,36 @@
#import <Foundation/Foundation.h>
/**
* not support PNLineChartPointStyleTriangle style recently
*/
typedef NS_ENUM(NSUInteger, PNLineChartPointStyle) {
PNLineChartPointStyleNone = 0,
PNLineChartPointStyleCycle,
PNLineChartPointStyleTriangle,
PNLineChartPointStyleSquare
};
@class PNLineChartDataItem;
typedef PNLineChartDataItem *(^LCLineChartDataGetter)(NSUInteger item);
@interface PNLineChartData : NSObject
@property (strong) UIColor *color;
@property NSUInteger itemCount;
@property (copy) LCLineChartDataGetter getData;
@property (nonatomic, assign) PNLineChartPointStyle inflexionPointStyle;
/**
* if PNLineChartPointStyle is cycle, inflexionPointWidth equal cycle's diameter
* if PNLineChartPointStyle is square, that means the foundation is square with
* inflexionPointWidth long
*/
@property (nonatomic, assign) CGFloat inflexionPointWidth;
@property (nonatomic, assign) CGFloat lineWidth;
@end
... ...
... ... @@ -7,4 +7,22 @@
@implementation PNLineChartData
- (id)init
{
self = [super init];
if (self) {
[self setDefaultValues];
}
return self;
}
- (void)setDefaultValues
{
_inflexionPointStyle = PNLineChartPointStyleNone;
_inflexionPointWidth = 6.f;
_lineWidth = 2.f;
}
@end
... ...
... ... @@ -64,12 +64,14 @@
lineChart.yLabelFormat = @"%1.1f";
lineChart.backgroundColor = [UIColor clearColor];
[lineChart setXLabels:@[@"SEP 1",@"SEP 2",@"SEP 3",@"SEP 4",@"SEP 5",@"SEP 6",@"SEP 7"]];
lineChart.showCoordinateAxis = YES;
// Line Chart Nr.1
NSArray * data01Array = @[@60.1, @160.1, @126.4, @262.2, @186.2, @127.2, @176.2];
PNLineChartData *data01 = [PNLineChartData new];
data01.color = PNFreshGreen;
data01.itemCount = lineChart.xLabels.count;
data01.inflexionPointStyle = PNLineChartPointStyleCycle;
data01.getData = ^(NSUInteger index) {
CGFloat yValue = [data01Array[index] floatValue];
return [PNLineChartDataItem dataItemWithY:yValue];
... ... @@ -80,6 +82,7 @@
PNLineChartData *data02 = [PNLineChartData new];
data02.color = PNTwitterColor;
data02.itemCount = lineChart.xLabels.count;
data02.inflexionPointStyle = PNLineChartPointStyleSquare;
data02.getData = ^(NSUInteger index) {
CGFloat yValue = [data02Array[index] floatValue];
return [PNLineChartDataItem dataItemWithY:yValue];
... ...