Skip to content

Commit

Permalink
New X shape for Scatter
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgindi committed Feb 9, 2016
1 parent daa8103 commit dc7ba3d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ public class ScatterChartDataSet: LineScatterCandleRadarChartDataSet, IScatterCh
@objc
public enum ScatterShape: Int
{
case Cross
case Triangle
case Circle
case Square
case Circle
case Triangle
case Cross
case X
case Custom
}

Expand Down
45 changes: 30 additions & 15 deletions Charts/Classes/Renderers/ScatterChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -163,21 +163,6 @@ public class ScatterChartRenderer: LineScatterCandleRadarChartRenderer
CGContextFillEllipseInRect(context, rect)
}
}
else if (shape == .Cross)
{
CGContextSetStrokeColorWithColor(context, dataSet.colorAt(j).CGColor)
_lineSegments[0].x = point.x - shapeHalf
_lineSegments[0].y = point.y
_lineSegments[1].x = point.x + shapeHalf
_lineSegments[1].y = point.y
CGContextStrokeLineSegments(context, _lineSegments, 2)

_lineSegments[0].x = point.x
_lineSegments[0].y = point.y - shapeHalf
_lineSegments[1].x = point.x
_lineSegments[1].y = point.y + shapeHalf
CGContextStrokeLineSegments(context, _lineSegments, 2)
}
else if (shape == .Triangle)
{
CGContextSetFillColorWithColor(context, dataSet.colorAt(j).CGColor)
Expand Down Expand Up @@ -216,6 +201,36 @@ public class ScatterChartRenderer: LineScatterCandleRadarChartRenderer
CGContextFillPath(context)
}
}
else if (shape == .Cross)
{
CGContextSetStrokeColorWithColor(context, dataSet.colorAt(j).CGColor)
_lineSegments[0].x = point.x - shapeHalf
_lineSegments[0].y = point.y
_lineSegments[1].x = point.x + shapeHalf
_lineSegments[1].y = point.y
CGContextStrokeLineSegments(context, _lineSegments, 2)

_lineSegments[0].x = point.x
_lineSegments[0].y = point.y - shapeHalf
_lineSegments[1].x = point.x
_lineSegments[1].y = point.y + shapeHalf
CGContextStrokeLineSegments(context, _lineSegments, 2)
}
else if (shape == .X)
{
CGContextSetStrokeColorWithColor(context, dataSet.colorAt(j).CGColor)
_lineSegments[0].x = point.x - shapeHalf
_lineSegments[0].y = point.y - shapeHalf
_lineSegments[1].x = point.x + shapeHalf
_lineSegments[1].y = point.y + shapeHalf
CGContextStrokeLineSegments(context, _lineSegments, 2)

_lineSegments[0].x = point.x + shapeHalf
_lineSegments[0].y = point.y - shapeHalf
_lineSegments[1].x = point.x - shapeHalf
_lineSegments[1].y = point.y + shapeHalf
CGContextStrokeLineSegments(context, _lineSegments, 2)
}
else if (shape == .Custom)
{
CGContextSetFillColorWithColor(context, dataSet.colorAt(j).CGColor)
Expand Down

0 comments on commit dc7ba3d

Please sign in to comment.