Skip to content

Commit 1d36786

Browse files
committed
Merge pull request honcheng#14 from lbehnke/d7bcf381562a51fc3fbb23a9850e151ebe0c44e2
Please pull fix for *div by zero* issue
2 parents daef8fd + d7bcf38 commit 1d36786

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

iOSPlot/Shared/PCLineChartView.m

+10-1
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,16 @@ - (void)drawRect:(CGRect)rect
125125
}
126126

127127
float margin = 45;
128-
float div_width = (self.frame.size.width-2*margin)/([self.xLabels count]-1);
128+
float div_width;
129+
if ([self.xLabels count] == 1)
130+
{
131+
div_width = 0;
132+
}
133+
else
134+
{
135+
div_width = (self.frame.size.width-2*margin)/([self.xLabels count]-1);
136+
}
137+
129138
for (NSUInteger i=0; i<[self.xLabels count]; i++)
130139
{
131140
if (i % self.numXIntervals == 1 || self.numXIntervals==1) {

0 commit comments

Comments
 (0)