欢迎光临
我们一直在努力

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

这两个雷达图表具有相同的橙色位数据点,但灰色不同.但是,正如您所看到的那样,它是自动缩放的,并且橙色位在第二个图表上变得更大,即使它们是完全相同的数据点.有没有办法关闭自动缩放功能?我希望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雷达图表关闭自动缩放