iOS-Chart 中的组合图表 - 不呈现折线图的负值

Combined Charts in iOS-Chart - Negative values for Line Chart are not rendered

我正在使用 io-Charts (https://github.com/danielgindi/Charts/)。 我将不得不在组合图表中显示条形图和折线图。 xAxis 将反映从 -12 到 12 的值和 y 值范围在 -3000 到 3000.While 之间的条形图正确呈现负 y 和 x 轴,折线图不显示小于 [=33= 的值]建议在下面link,

Negative values not displayed in line charts using ios-charts using Swift

我设置了_chartView.xAxis.axisMinimum = -12; // 从 -12 而不是 0 开始。

请在当前图表下方找到,

图表视图的设置和折线图的数据集,

    - (LineChartData *)generateLineData

{ LineChartData *d = [[LineChartData alloc] init];

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

[entries addObject:[[ChartDataEntry alloc] initWithX:0 y:-3000]];
[entries addObject:[[ChartDataEntry alloc] initWithX:0.5 y:-999]];
[entries addObject:[[ChartDataEntry alloc] initWithX:1 y:-1000]];
[entries addObject:[[ChartDataEntry alloc] initWithX:2 y:-1000]];
[entries addObject:[[ChartDataEntry alloc] initWithX:3.5 y:-1300]];
[entries addObject:[[ChartDataEntry alloc] initWithX:4 y:-900]];
[entries addObject:[[ChartDataEntry alloc] initWithX:5 y:-1200]];
[entries addObject:[[ChartDataEntry alloc] initWithX:6 y:-2500]];
[entries addObject:[[ChartDataEntry alloc] initWithX:8 y:-1300]];
[entries addObject:[[ChartDataEntry alloc] initWithX:9 y:1400]];
[entries addObject:[[ChartDataEntry alloc] initWithX:11 y:-900]];
[entries addObject:[[ChartDataEntry alloc] initWithX:12 y:-3000]];
[entries addObject:[[ChartDataEntry alloc] initWithX:-1 y:-1000]];
[entries addObject:[[ChartDataEntry alloc] initWithX:-2 y:-1300]];
[entries addObject:[[ChartDataEntry alloc] initWithX:-4 y:-1100]];
[entries addObject:[[ChartDataEntry alloc] initWithX:-5 y:-1500]];
[entries addObject:[[ChartDataEntry alloc] initWithX:-6 y:-1500]];
[entries addObject:[[ChartDataEntry alloc] initWithX:-8 y:-1100]];
[entries addObject:[[ChartDataEntry alloc] initWithX:-9 y:-1000]];
[entries addObject:[[ChartDataEntry alloc] initWithX:-11 y:-1500]];

LineChartDataSet *set = [[LineChartDataSet alloc] initWithValues:entries label:@"Line DataSet"];
[set setColor:[UIColor colorWithRed:240/255.f green:238/255.f blue:70/255.f alpha:1.f]];
set.lineWidth = 2.5;
set.fillColor = [UIColor colorWithRed:240/255.f green:238/255.f blue:70/255.f alpha:1.f];
set.mode = LineChartModeHorizontalBezier;
set.drawValuesEnabled = NO;
set.drawCirclesEnabled = NO;
set.axisDependency = AxisDependencyLeft;

[d addDataSet:set];

return d;

}

我不确定我是否缺少图表视图的某些设置。

通过将 x 值从 -12 到 12 的折线图数据集重新排序来解决此问题,在我最初的问题中,数据集是混合的,折线图的顺序不正确。