JBChartView Data Points Hidden until user interaction

237 Views Asked by At

I'm having trouble with JBLineChartView for my data points. Primarily; the line on the graph is hidden until (and only while) the user interacts with it. Obviously; having an empty graph here is less then desirable for user experience reasons, but I cannot seem to find where it would be set to hide the line until the user interacts with it.

Even after digging through the provided demo I cannot find where it would be called. Here is the code that handles the drawing and setup of the chart in the 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.
}

I realize this is somewhat obscure; but does anyone have experience with this framework that can explain this?

1

There are 1 best solutions below

1
On BEST ANSWER

You have set your chart's background color to black:

_chartView.backgroundColor = [UIColor blackColor];

The default color of any line within the chart is also black.

You need to either change the background color of the chartView from black to something else or supply a different line color via:

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