Skip to content

Commit

Permalink
Fixed highlight bugs - in two places there was use of x-index methods
Browse files Browse the repository at this point in the history
(Closes #1535)
  • Loading branch information
danielgindi committed Sep 23, 2016
1 parent b03f74d commit 8905a46
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/RadarChartRenderer.swift
Expand Up @@ -299,7 +299,7 @@ open class RadarChartRenderer: LineRadarRenderer
set.isHighlightEnabled
else { continue }

guard let e = set.entryForIndex(Int(high.x)) as? RadarChartDataEntry
guard let e = set.entryForXValue(high.x) as? RadarChartDataEntry
else { continue }

if !isInBoundsX(entry: e, dataSet: set)
Expand Down
62 changes: 28 additions & 34 deletions Source/Charts/Renderers/ScatterChartRenderer.swift
Expand Up @@ -194,8 +194,6 @@ open class ScatterChartRenderer: LineScatterCandleRadarRenderer
let animator = animator
else { return }

let chartXMax = dataProvider.chartXMax

context.saveGState()

for high in indices
Expand All @@ -205,41 +203,37 @@ open class ScatterChartRenderer: LineScatterCandleRadarRenderer
set.isHighlightEnabled
else { continue }

guard let e = set.entryForIndex(Int(high.x))
else { continue }
let entries = set.entriesForXValue(high.x)

if !isInBoundsX(entry: e, dataSet: set)
{
continue
}

context.setStrokeColor(set.highlightColor.cgColor)
context.setLineWidth(set.highlightLineWidth)
if set.highlightLineDashLengths != nil
{
context.setLineDash(phase: set.highlightLineDashPhase, lengths: set.highlightLineDashLengths!)
}
else
for entry in entries
{
context.setLineDash(phase: 0.0, lengths: [])
}

let x = high.x // get the x-position
let y = high.y * Double(animator.phaseY)

if x > chartXMax * animator.phaseX
{
continue
if entry.y != high.y { continue }

if !isInBoundsX(entry: entry, dataSet: set) { continue }

context.setStrokeColor(set.highlightColor.cgColor)
context.setLineWidth(set.highlightLineWidth)
if set.highlightLineDashLengths != nil
{
context.setLineDash(phase: set.highlightLineDashPhase, lengths: set.highlightLineDashLengths!)
}
else
{
context.setLineDash(phase: 0.0, lengths: [])
}

let x = entry.x // get the x-position
let y = entry.y * Double(animator.phaseY)

let trans = dataProvider.getTransformer(forAxis: set.axisDependency)

let pt = trans.pixelForValues(x: x, y: y)

high.setDraw(pt: pt)

// draw the lines
drawHighlightLines(context: context, point: pt, set: set)
}

let trans = dataProvider.getTransformer(forAxis: set.axisDependency)

let pt = trans.pixelForValues(x: x, y: y)

high.setDraw(pt: pt)

// draw the lines
drawHighlightLines(context: context, point: pt, set: set)
}

context.restoreGState()
Expand Down

0 comments on commit 8905a46

Please sign in to comment.