Skip to content

Commit

Permalink
Use indexed() where appropriate
Browse files Browse the repository at this point in the history
  • Loading branch information
jjatie committed Nov 6, 2020
1 parent 88a89f6 commit 861a9c0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
3 changes: 2 additions & 1 deletion Source/Charts/Highlight/ChartHighlighter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// https://github.com/danielgindi/Charts
//

import Algorithms
import Foundation
import CoreGraphics

Expand Down Expand Up @@ -73,7 +74,7 @@ open class ChartHighlighter : NSObject, Highlighter

guard let data = self.data else { return vals }

for (i, set) in zip(data.indices, data) where set.isHighlightEnabled
for (i, set) in data.indexed() where set.isHighlightEnabled
{
// extract all y-values from all DataSets at the given x-value.
// some datasets (i.e bubble charts) make sense to have multiple values for an x-value. We'll have to find a way to handle that later on. It's more complicated now when x-indices are floating point.
Expand Down
7 changes: 3 additions & 4 deletions Source/Charts/Highlight/CombinedHighlighter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
// https://github.com/danielgindi/Charts
//

import Algorithms
import Foundation
import CoreGraphics

Expand All @@ -35,10 +36,8 @@ open class CombinedHighlighter: ChartHighlighter
let dataObjects = chart.combinedData?.allData
else { return vals }

for i in dataObjects.indices
for (i, dataObject) in dataObjects.indexed()
{
let dataObject = dataObjects[i]

// in case of BarData, let the BarHighlighter take over
if barHighlighter != nil && dataObject is BarChartData,
let high = barHighlighter?.getHighlight(x: x, y: y)
Expand All @@ -48,7 +47,7 @@ open class CombinedHighlighter: ChartHighlighter
}
else
{
for (j, set) in zip(dataObject.indices, dataObject) where set.isHighlightEnabled
for (j, set) in dataObject.indexed() where set.isHighlightEnabled
{
let highs = buildHighlights(dataSet: set, dataSetIndex: j, xValue: xValue, rounding: .closest)

Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Highlight/RadarHighlighter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ open class RadarHighlighter: PieRadarHighlighter
let sliceangle = chart.sliceAngle
let factor = chart.factor

for (i, dataSet) in zip(chartData.indices, chartData)
for (i, dataSet) in chartData.indexed()
{
guard let entry = dataSet.entryForIndex(index) else { continue }

Expand Down
2 changes: 1 addition & 1 deletion Source/Charts/Renderers/YAxisRendererRadarChart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ open class YAxisRendererRadarChart: YAxisRenderer
let xOffset = axis.labelXOffset

let entries = axis.entries[from..<to]
zip(entries.indices, entries).forEach { index, entry in
entries.indexed().forEach { index, entry in
let r = CGFloat(entry - axis._axisMinimum) * factor
let p = center.moving(distance: r, atAngle: chart.rotationAngle)
let label = axis.getFormattedLabel(index)
Expand Down

0 comments on commit 861a9c0

Please sign in to comment.