Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues #182, #122 #183

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Charts/Classes/Data/CandleChartDataSet.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class CandleChartDataSet: BarLineScatterCandleChartDataSet
/// the color of the shadow line
public var shadowColor: UIColor?

/// use candle color for the shadow
public var makeShadowSameColorAsCandle = false

/// color for open <= close
public var decreasingColor: UIColor?

Expand Down
4 changes: 4 additions & 0 deletions Charts/Classes/Data/ChartData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -687,6 +687,10 @@ public class ChartData: NSObject

var entry = _dataSets[dataSetIndex].entryForXIndex(xIndex)

if (entry?.xIndex != xIndex) {
return false
}

return removeEntry(entry, dataSetIndex: dataSetIndex)
}

Expand Down
22 changes: 20 additions & 2 deletions Charts/Classes/Renderers/CandleStickChartRenderer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,20 @@ public class CandleStickChartRenderer: ChartDataRendererBase

// draw the shadow

CGContextSetStrokeColorWithColor(context, (dataSet.shadowColor ?? dataSet.colorAt(j)).CGColor)
var shadowColor = dataSet.shadowColor ?? dataSet.colorAt(j)
if (dataSet.makeShadowSameColorAsCandle)
{
if (e.open > e.close)
{
shadowColor = dataSet.decreasingColor ?? dataSet.colorAt(j)
}
else if (e.open < e.close)
{
shadowColor = dataSet.increasingColor ?? dataSet.colorAt(j)
}
}

CGContextSetStrokeColorWithColor(context, shadowColor.CGColor);

CGContextStrokeLineSegments(context, _shadowPoints, 2)

Expand All @@ -112,7 +125,12 @@ public class CandleStickChartRenderer: ChartDataRendererBase
trans.rectValueToPixel(&_bodyRect)

// draw body differently for increasing and decreasing entry
if (e.open >= e.close)

if (e.open == e.close) {
CGContextSetStrokeColorWithColor(context, shadowColor.CGColor)
CGContextStrokeRect(context, _bodyRect)
}
else if (e.open > e.close)
{

var color = dataSet.decreasingColor ?? dataSet.colorAt(j)
Expand Down