Skip to content

Commit

Permalink
Minor RadarChart fix for unequal datasets in terms of entry count
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Feb 27, 2016
1 parent dee295e commit 4b9ebfa
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Charts/Classes/Renderers/RadarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,17 +34,32 @@ public class RadarChartRenderer: LineRadarChartRenderer

if (radarData != nil)
{
var mostEntries = 0

for set in radarData!.dataSets
{
if set.entryCount > mostEntries
{
mostEntries = set.entryCount
}
}

for set in radarData!.dataSets as! [IRadarChartDataSet]
{
if set.isVisible && set.entryCount > 0
{
drawDataSet(context: context, dataSet: set)
drawDataSet(context: context, dataSet: set, mostEntries: mostEntries)
}
}
}
}

internal func drawDataSet(context context: CGContext, dataSet: IRadarChartDataSet)
/// Draws the RadarDataSet
///
/// - parameter context:
/// - parameter dataSet:
/// - parameter mostEntries: the entry count of the dataset with the most entries
internal func drawDataSet(context context: CGContext, dataSet: IRadarChartDataSet, mostEntries: Int)
{
guard let
chart = chart,
Expand Down Expand Up @@ -91,6 +106,13 @@ public class RadarChartRenderer: LineRadarChartRenderer
}
}

// if this is the largest set, close it
if dataSet.entryCount < mostEntries
{
// if this is not the largest set, draw a line to the center before closing
CGPathAddLineToPoint(path, nil, center.x, center.y)
}

CGPathCloseSubpath(path)

// draw filled
Expand Down

0 comments on commit 4b9ebfa

Please sign in to comment.