gpt4 book ai didi

ios-charts 雷达图关闭自动缩放

转载 作者:可可西里 更新时间:2023-11-01 06:03:25 34 4
gpt4 key购买 nike

enter image description here

enter image description here

这两个雷达图橙色位的数据点相同,但灰色位不同。但是,如您所见,它是自动缩放的,并且橙色位在第二张图表上最终变大了,即使它们是完全相同的数据点。有没有办法关闭自动缩放?我也希望 100% 直接到达图表的边缘。

-(void)setupRadarChart
{
self.radarChart.descriptionText = @"";
self.radarChart.webLineWidth = .75;
self.radarChart.innerWebLineWidth = 0.375;
self.radarChart.webAlpha = 1.0;
self.radarChart.userInteractionEnabled = NO;
self.radarChart.xAxis.enabled = YES;
ChartYAxis *yAxis = self.radarChart.yAxis;
yAxis.enabled = NO;
ChartLegend *l = self.radarChart.legend;
l.position = ChartLegendPositionBelowChartLeft;
l.font = [UIFont systemFontOfSize:UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ? 12 : (headerWidth/40)];
[self setRadarData];
}

- (void)setRadarData
{
NSMutableArray *parties = [[NSMutableArray alloc] init];
for (PillarModel *m in [DataManager sharedData].pillars)
{
[parties addObject:m.abbreviation];
}
NSMutableArray *yVals2 = [[NSMutableArray alloc] init];
NSMutableArray *benchMark = [[NSMutableArray alloc] init];
BOOL shouldAdd = YES;

for (PillarModel *pillar in [DataManager sharedData].pillars)
{ int totalPillarScore = (int)[[DataManager sharedData] getTotalScorePossible:[[DataManager sharedData] getIndividualQuestionResultsForPillar:pillar.pillarId]];
if ((isCompany ? [[DataManager sharedData] getCompanyScoresForCategory:pillar] : [[DataManager sharedData] getIndividualScoreForCategory:pillar.pillarId]) != 0)
{
shouldAdd = NO;
}
if (pillar.pillarId == numberOfPillars -1 && shouldAdd) {
[yVals2 addObject:[[ChartDataEntry alloc] initWithValue:0.01 xIndex:pillar.pillarId]];

}
else{
double val = (isCompany ? (double)[[DataManager sharedData] getCompanyScoresForCategory:pillar]/totalPillarScore : (double)[[DataManager sharedData] getIndividualScoreForCategory:pillar.pillarId] / totalPillarScore);
[yVals2 addObject:[[ChartDataEntry alloc] initWithValue:val xIndex:pillar.pillarId]];
}
float pillarBenchMark = [[[[[DataManager sharedData].benchmarkJSONDict objectForKey:hightlightedView.lowercaseString] objectForKey:pillar.title] objectForKey:@"pillar"] intValue];
float ifNoBenchMarkThanCompanyScore = (pillarBenchMark ? pillarBenchMark : (isCompany ? [[DataManager sharedData] getIndividualScoreForCategory:pillar.pillarId]: [[DataManager sharedData] getCompanyScoresForCategory:pillar]));
[benchMark addObject:[[ChartDataEntry alloc] initWithValue:ifNoBenchMarkThanCompanyScore/totalPillarScore xIndex:pillar.pillarId]];
}

NSMutableArray *xVals = [[NSMutableArray alloc] init];

for (int i = 0; i < numberOfPillars; i++)
{
[xVals addObject:parties[i % parties.count]];
}

NSString *label = (isCompany ? @"Company score" : @"Your score");
RadarChartDataSet *set2 = [[RadarChartDataSet alloc] initWithYVals:yVals2 label:label];
[set2 setColor:[DataManager sharedData].mainColor];
set2.drawFilledEnabled = YES;
set2.fillAlpha = 1.0f;
set2.lineWidth = 2.0;

RadarChartDataSet *benchMarkSet = [[RadarChartDataSet alloc] initWithYVals:benchMark label:@"Benchmark"];
[benchMarkSet setColor:[UIColor colorWithRed:125/255.0f green:125/255.0f blue:125/255.0f alpha:0.6f]];
benchMarkSet.drawFilledEnabled = YES;
benchMarkSet.fillAlpha = 0.0f;
benchMarkSet.lineWidth = 2.0;
benchMarkSet.highlightLineDashLengths = @[[NSNumber numberWithInt:2]];
benchMarkSet.highlightLineDashPhase = 2;

RadarChartData *data = [[RadarChartData alloc] initWithXVals:xVals dataSets:@[set2, benchMarkSet]];
[data setValueFont:[UIFont fontWithName:@"HelveticaNeue-Light" size:8.f]];
[data setDrawValues:NO];

self.radarChart.data = data;
}

最佳答案

孙博弘的回答是不正确的,但它让我意识到这是多么容易解决。这既解决了自动缩放问题,也解决了边缘问题。

self.radarChart.yAxis.customAxisMin = 0;
self.radarChart.yAxis.customAxisMax = 1;

关于ios-charts 雷达图关闭自动缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36432519/

34 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com