Commit 6993c6f4 authored by Achilles's avatar Achilles

客流详情界面并状图bug.

parent dc98caef
......@@ -5,25 +5,25 @@
#import "VankeBusinessChartCell_iPhone.h"
#define CHART_DIAMETER 200
#define COLOR_R 90
#define COLOR_G 60
#define COLOR_B 30
#pragma mark -
@implementation VankeBusinessChartCell_iPhone
PNPieChart *chartPieChart;
NSArray *chartColors;
SUPPORT_AUTOMATIC_LAYOUT( YES )
SUPPORT_RESOURCE_LOADING( YES )
- (void)load
{
[self initChartColors];
}
- (void)unload
{
chartColors = nil;
chartPieChart = nil;
}
......@@ -46,14 +46,13 @@ SUPPORT_RESOURCE_LOADING( YES )
}
}
- (void)layoutDidFinish
{
[self drawPieChart];
}
- (void) drawPieChart {
chartPieChart = [[PNPieChart alloc] initWithFrame:CGRectMake((self.width - CHART_DIAMETER)/2.0, 0, CHART_DIAMETER, CHART_DIAMETER) items:[self getChartItems]];
chartPieChart = [[PNPieChart alloc] initWithFrame:CGRectMake((self.width - CHART_DIAMETER)/2.0 + 20, 0, CHART_DIAMETER, CHART_DIAMETER) items:[self getChartItems]];
chartPieChart.descriptionTextColor = [UIColor blackColor];
chartPieChart.descriptionTextFont = [UIFont fontWithName:@"微软雅黑" size:12.0];
chartPieChart.descriptionTextShadowColor = [UIColor clearColor];
......@@ -74,22 +73,18 @@ SUPPORT_RESOURCE_LOADING( YES )
-(NSArray*) getChartItems {
ChartValue *data = self.data;
NSInteger colorLen = [chartColors count];
for (NSInteger i = 0; i < [data.values count]; ++i) {
PNPieChartDataItem *item = [data.values objectAtIndex:i];
item.color = [chartColors objectAtIndex:i % colorLen];
item.color = [self randomColor:i];
}
// [data.values enumerateObjectsUsingBlock:^(ProjectSaleVolume *obj, NSUInteger idx, BOOL * _Nonnull stop) {
// UIColor *color = [chartColors objectAtIndex:idx % colorLen];
// float itemValue = [obj.amount floatValue];
// NSString *itemDesc = obj.dimensionValue;
// [items addObject:[PNPieChartDataItem dataItemWithValue:itemValue color:color description:itemDesc]];
// }];
return data.values;
}
-(void) initChartColors {
chartColors = @[PNYellow, PNBlue, PNTwitterColor, PNPinkDark, PNGreen, PNTitleColor,PNLightGreen, PNFreshGreen, PNDeepGreen, PNRed, PNMauve, PNBrown, PNStarYellow, PNDarkBlue, PNDeepGrey, PNPinkGrey, PNLightGrey, PNCleanGrey, PNDarkYellow, PNCloudWhite, PNLightBlue, PNBlack, PNiOSGreenColor];
-(UIColor*) randomColor: (NSInteger) i {
CGFloat r = ((COLOR_R * i + 20) % 255) / 255.0;
CGFloat g = ((COLOR_G * i + 180) % 255) / 255.0;
CGFloat b = ((COLOR_B * i + 35) % 255) / 255.0;
return [UIColor colorWithRed: r green:g blue:b alpha:1.0f];
}
@end
......
......@@ -66,10 +66,10 @@ ON_CREATE_VIEWS( signal )
self.list.whenReloading = ^
{
NSInteger chartTotal = 0;
PassengerFlowResponse *resp = [_passengerFlowModel getServerResp];
if (nil != resp) {
chartTotal = [resp dataCount];
NSInteger chartTotal = 0;
if (nil != resp && [resp dataCount] > 0) {
chartTotal = 1;
}
self.list.total = 1 + chartTotal;
......@@ -80,8 +80,8 @@ ON_CREATE_VIEWS( signal )
photo.order = 0;
photo.size = CGSizeMake(0, 230);
for (int i = 0; i < chartTotal; ++i) {
BeeUIScrollItem *bizChart = self.list.items[i + 1];
if (chartTotal > 0) {
BeeUIScrollItem *bizChart = self.list.items[1];
bizChart.clazz = [VankeBusinessChartCell_iPhone class];
// 取值
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment