PNChart icon indicating copy to clipboard operation
PNChart copied to clipboard

如果 在饼状图 输入的比例值 错误

Open KongXiangX opened this issue 8 years ago • 0 comments

例:错误的数据 // 数据 NSArray *items = @[[PNPieChartDataItem dataItemWithValue:5.56 color:[UIColor grayColor]description:@"其他"], [PNPieChartDataItem dataItemWithValue:70.415 color:[UIColor orangeColor] description:@"WWDC"], [PNPieChartDataItem dataItemWithValue:24.45 color:PNDeepGreen description:@"GOOG I/O"], ];

饼状图 显示的百分比和 会大于100% —————————————— 我做了加了一些判定 更改 在如下方法中

  • (void)strokeChart{} //一个警告 的提醒 int tem = 0; for (int i = 0; i < _items.count; i++) { UILabel *descriptionLabel = [self descriptionLabelForItemAtIndex:i]; int a = [descriptionLabel.text floatValue] * 100; tem += a;

      if (tem > 10000) {
          NSLog(@"超过10000了");
          int b = tem - 10000;
          int c = a - b;
          CGFloat d = c/100.0;
          descriptionLabel.text = [NSString stringWithFormat:@"%.2f%% \n %@",d,currentItem.textDescription];
    
          NSLog(@"----%@",descriptionLabel.text);
      }
      [_contentView addSubview:descriptionLabel];
      [_descriptionLabels addObject:descriptionLabel];
    

    }

KongXiangX avatar Jan 13 '17 01:01 KongXiangX