Skip to content

Commit

Permalink
If we don't have any data to display in a chart, draw something, inst…
Browse files Browse the repository at this point in the history
…ead of a blank chart.
  • Loading branch information
luddep committed Aug 11, 2010
1 parent 938c095 commit a205c11
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions LPChartView.j
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ var labelViewHeight = 20,

- (CPArray)itemFrames
{
return (dataSource && drawView && _data && _maxValue >= 0) ? [self calculateItemFramesWithSets:_data maxValue:_maxValue] : [CPArray array];
return (dataSource && drawView && _data) ? [self calculateItemFramesWithSets:_data maxValue:_maxValue] : [CPArray array];
}

- (void)reloadData
Expand Down Expand Up @@ -238,7 +238,13 @@ var labelViewHeight = 20,
_framesSet = [CPArray array];

if (!sets.length)
return _framesSet;
return _framesSet;

// If the chart has no data to display,
// we set the max value to 1 so that it will
// at least draw an empty line at the bottom of the chart.
if (aMaxValue === 0)
aMaxValue = 1;

var width = drawViewSize.width,
height = drawViewSize.height - (2 * drawViewPadding),
Expand Down

0 comments on commit a205c11

Please sign in to comment.