隐藏JBChartView数据点直到用户交互

时间:2014-05-29 01:40:58

标签: ios jbchartview

我的数据点遇到JBLineChartView问题。为主;图表中的线被隐藏,直到(并且仅在用户)与其交互时。明显;由于用户体验原因,这里有一个空图表是不太理想的,但我似乎无法找到将其设置为隐藏该行的位置,直到用户与之交互为止。

即使在完成提供的演示之后,我也无法找到它的调用位置。以下是处理视图中图表的绘制和设置的代码:

- (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.
}

我意识到这有点模糊;但有没有人有这个框架的经验可以解释这个?

1 个答案:

答案 0 :(得分:1)

您已将图表的背景颜色设置为黑色:

_chartView.backgroundColor = [UIColor blackColor];

图表中任何行的默认颜色也是黑色。

您需要将chartView的背景颜色从黑色更改为其他颜色或通过以下方式提供不同的线条颜色:

(UIColor *)lineChartView:(JBLineChartView *)lineChartView colorForLineAtLineIndex:(NSUInteger)lineIndex;