|
|
@@ -31,11 +31,45 @@
|
|
|
@implementation KPICell
|
|
|
|
|
|
- (void)setInfoDic:(NSMutableDictionary *)infoDic {
|
|
|
- _infoDic = infoDic;
|
|
|
+ _infoDic = [self prepareData:infoDic];
|
|
|
[self.KPIView setPieChartData:infoDic];
|
|
|
[self reload];
|
|
|
}
|
|
|
|
|
|
+- (NSMutableDictionary *)prepareData:(NSMutableDictionary *)infoDic {
|
|
|
+
|
|
|
+ NSMutableArray* arr_data =[infoDic[@"arr_val"] mutableCopy];
|
|
|
+ float total = 0;
|
|
|
+ for(int i=0;i<arr_data.count;i++)
|
|
|
+ {
|
|
|
+ NSMutableDictionary* item =[arr_data[i] mutableCopy];
|
|
|
+ if([item[@"display"] boolValue])
|
|
|
+ {
|
|
|
+
|
|
|
+ total+=[item[@"A_val"] floatValue];
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ NSMutableArray *tmpArr = [NSMutableArray array];
|
|
|
+ for(int i=0;i<arr_data.count;i++ )
|
|
|
+ {
|
|
|
+
|
|
|
+ NSMutableDictionary* item =[arr_data[i] mutableCopy];
|
|
|
+ if([item[@"display"] boolValue]==true)
|
|
|
+ {
|
|
|
+ float percent =[item[@"A_val"] floatValue] / total *100;
|
|
|
+ item[@"CP_val"] = [NSNumber numberWithFloat:percent];
|
|
|
+ arr_data[i] = item;
|
|
|
+
|
|
|
+ }
|
|
|
+ [tmpArr addObject:item];
|
|
|
+ }
|
|
|
+ infoDic[@"arr_val"] = tmpArr;
|
|
|
+
|
|
|
+ return infoDic;
|
|
|
+}
|
|
|
+
|
|
|
- (void)reload {
|
|
|
|
|
|
NSArray *subViews = [self.itemsContainer.subviews mutableCopy];
|