Skip to content

Commit

Permalink
Avoid crashes when datasets are empty (fixes #320)
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Aug 27, 2015
1 parent f38ad4d commit aa8645c
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Charts/Classes/Renderers/BarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public class BarChartRenderer: ChartDataRendererBase
{
var dataSet = dataSets[i] as! BarChartDataSet

if (!dataSet.isDrawValuesEnabled)
if !dataSet.isDrawValuesEnabled || dataSet.entryCount == 0
{
continue
}
Expand Down
4 changes: 2 additions & 2 deletions Charts/Classes/Renderers/BubbleChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class BubbleChartRenderer: ChartDataRendererBase

for set in bubbleData.dataSets as! [BubbleChartDataSet]
{
if (set.isVisible)
if set.isVisible && set.entryCount > 0
{
drawDataSet(context: context, dataSet: set)
}
Expand Down Expand Up @@ -152,7 +152,7 @@ public class BubbleChartRenderer: ChartDataRendererBase

for dataSet in dataSets
{
if (!dataSet.isDrawValuesEnabled)
if !dataSet.isDrawValuesEnabled || dataSet.entryCount == 0
{
continue
}
Expand Down
4 changes: 2 additions & 2 deletions Charts/Classes/Renderers/CandleStickChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CandleStickChartRenderer: LineScatterCandleRadarChartRenderer

for set in candleData.dataSets as! [CandleChartDataSet]
{
if (set.isVisible)
if set.isVisible && set.entryCount > 0
{
drawDataSet(context: context, dataSet: set)
}
Expand Down Expand Up @@ -190,7 +190,7 @@ public class CandleStickChartRenderer: LineScatterCandleRadarChartRenderer
{
var dataSet = dataSets[i]
if (!dataSet.isDrawValuesEnabled)
if !dataSet.isDrawValuesEnabled || dataSet.entryCount == 0
{
continue
}
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Renderers/HorizontalBarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ public class HorizontalBarChartRenderer: BarChartRenderer
{
var dataSet = dataSets[i] as! BarChartDataSet

if (!dataSet.isDrawValuesEnabled)
if !dataSet.isDrawValuesEnabled || dataSet.entryCount == 0
{
continue
}
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Renderers/LineChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ public class LineChartRenderer: LineScatterCandleRadarChartRenderer
{
var dataSet = dataSets[i] as! LineChartDataSet

if (!dataSet.isDrawValuesEnabled)
if !dataSet.isDrawValuesEnabled || dataSet.entryCount == 0
{
continue
}
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Renderers/PieChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class PieChartRenderer: ChartDataRendererBase
{
for set in pieData!.dataSets as! [PieChartDataSet]
{
if (set.isVisible)
if set.isVisible && set.entryCount > 0
{
drawDataSet(context: context, dataSet: set)
}
Expand Down
4 changes: 2 additions & 2 deletions Charts/Classes/Renderers/RadarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class RadarChartRenderer: LineScatterCandleRadarChartRenderer
{
for set in radarData!.dataSets as! [RadarChartDataSet]
{
if (set.isVisible)
if set.isVisible && set.entryCount > 0
{
drawDataSet(context: context, dataSet: set)
}
Expand Down Expand Up @@ -133,7 +133,7 @@ public class RadarChartRenderer: LineScatterCandleRadarChartRenderer
{
var dataSet = data.getDataSetByIndex(i) as! RadarChartDataSet

if (!dataSet.isDrawValuesEnabled)
if !dataSet.isDrawValuesEnabled || dataSet.entryCount == 0
{
continue
}
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Renderers/ScatterChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public class ScatterChartRenderer: LineScatterCandleRadarChartRenderer
{
var dataSet = dataSets[i]

if (!dataSet.isDrawValuesEnabled)
if !dataSet.isDrawValuesEnabled || dataSet.entryCount == 0
{
continue
}
Expand Down

0 comments on commit aa8645c

Please sign in to comment.