我在使用 JBLineChartView 获取数据点时遇到问题。主要是;图表上的线一直隐藏,直到(且仅当)用户与它交互时。明显地;出于用户体验的原因,这里有一个空图不太可取,但我似乎无法找到将其设置为隐藏线的位置,直到用户与之交互。
即使仔细研究了提供的演示,我也找不到调用它的位置。下面是处理 View 中图表的绘制和设置的代码:
- (void)viewDidLoad
{
self.title = @"Water Quality";
_chartView = [[JBLineChartView alloc] init];
_chartView.delegate = self;
_chartView.dataSource = self;
[_chartView setState:JBChartViewStateExpanded];
_chartView.backgroundColor = [UIColor blackColor];
_chartView.showsLineSelection = YES;
_chartView.showsVerticalSelection = YES;
[_chartView setAlpha:0.5f];
_headerView = [[JBChartHeaderView alloc] initWithFrame:CGRectMake(0, 74, 320, 30)];
_chartView.frame = CGRectMake(0, 94, 320, 200);
_footerView = [[JBLineChartFooterView alloc] initWithFrame:CGRectMake(0, 294, 320, 30)];
_headerView.titleLabel.text = @"Alkalinity";
_headerView.titleLabel.textColor = [UIColor whiteColor];
_footerView.leftLabel.text = [testArray1 firstObject];
_footerView.rightLabel.text = [testArray1 lastObject];
_footerView.leftLabel.textColor = [UIColor whiteColor];
_footerView.rightLabel.textColor = [UIColor whiteColor];
_footerView.backgroundColor = [UIColor blackColor];
[_footerView setAlpha:0.5f];
_footerView.sectionCount = [testArray1 count];
// THIS IS THE VIEW WHEN THE USER INTERACTS WITH THE CHART
/*
_informationView = [[JBChartInformationView alloc] initWithFrame:CGRectMake(0, 0, 40, 300)];
[_informationView setBackgroundColor:[UIColor grayColor]];*/
[_chartView setMinimumValue:1.0f];
[_chartView setMaximumValue:20.0f];
[self.view addSubview:_footerView];
[self.view addSubview:_headerView];
[self.view addSubview:_chartView];
// [self.view addSubview:_informationView];
[_chartView reloadData];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
我意识到这有点晦涩;但是有没有人有这个框架的经验可以解释这一点?
最佳答案
您已将图表的背景颜色设置为黑色:
_chartView.backgroundColor = [UIColor blackColor];
图表中任何线条的默认颜色也是黑色。
您需要将 chartView 的背景颜色从黑色更改为其他颜色或通过以下方式提供不同的线条颜色:
(UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForLineAtLineIndex:(NSUInteger)lineIndex;
关于ios - JBChartView 数据点隐藏直到用户交互,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23924453/