Skip to content

Commit

Permalink
try to fix wrong position bug. use entry.xIndex instead of j of dataS…
Browse files Browse the repository at this point in the history
…et.entryCount to calculate the offset and position
  • Loading branch information
liuxuan30 committed Jul 16, 2015
1 parent 15b3f43 commit baca6dd
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
12 changes: 1 addition & 11 deletions Charts/Classes/Charts/BarChartView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -56,17 +56,7 @@ public class BarChartView: BarLineChartViewBase, BarChartRendererDelegate
// extend xDelta to make space for multiple datasets (if ther are one)
_deltaX *= CGFloat(_data.dataSetCount)

var maxEntry = 0

for (var i = 0, count = barData.dataSetCount; i < count; i++)
{
var set = barData.getDataSetByIndex(i)

if (maxEntry < set!.entryCount)
{
maxEntry = set!.entryCount
}
}
var maxEntry = barData.xValCount

var groupSpace = barData.groupSpace
_deltaX += CGFloat(maxEntry) * groupSpace
Expand Down
4 changes: 2 additions & 2 deletions Charts/Classes/Renderers/BarChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ public class BarChartRenderer: ChartDataRendererBase
var e = entries[j]

// calculate the x-position, depending on datasetcount
var x = CGFloat(e.xIndex + j * dataSetOffset) + CGFloat(index)
+ groupSpace * CGFloat(j) + groupSpaceHalf
var x = CGFloat(e.xIndex + e.xIndex * dataSetOffset) + CGFloat(index)
+ groupSpace * CGFloat(e.xIndex) + groupSpaceHalf
var vals = e.values

if (!containsStacks || vals == nil)
Expand Down
2 changes: 1 addition & 1 deletion Charts/Classes/Utils/ChartTransformer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public class ChartTransformer: NSObject
var e = entries[j]

// calculate the x-position, depending on datasetcount
var x = CGFloat(e.xIndex + (j * (setCount - 1)) + dataSet) + space * CGFloat(j) + space / 2.0
var x = CGFloat(e.xIndex + (e.xIndex * (setCount - 1)) + dataSet) + space * CGFloat(e.xIndex) + space / 2.0
var y = e.value

valuePoints.append(CGPoint(x: x, y: CGFloat(y) * phaseY))
Expand Down

0 comments on commit baca6dd

Please sign in to comment.