Skip to content
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
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,11 @@ class MyViewController: UIViewController, ChartDelegate {
}

func didFinishTouchingChart(chart: Chart) {
// Do something when finished
// Do something when finished (only called after the user swipes out of the chart either on the right or the left side)
}

func didEndTouchingChart(chart: Chart) {
// Do something when the user ends touching the chart
}
}
```
Expand Down Expand Up @@ -196,6 +200,7 @@ There is no built-in method to update a chart. To accomplish this:
* `delegate`: the delegate for listening to touch events.
* `highlightLineColor`: color of the highlight line.
* `highlightLineWidth`: width of the highlight line.
* `shouldAutoHideHighlightLine`: automatically hide the highlightLine after we've ended touching the chart.
* `gridColor`: the grid color.
* `labelColor`: the color of the labels.
* `labelFont`: the font used for the labels.
Expand Down
10 changes: 9 additions & 1 deletion Source/Chart.swift
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,11 @@ open class Chart: UIControl {
Width for the highlight line.
*/
open var highlightLineWidth: CGFloat = 0.5

/**
Wether we should automatically hide the highlightLine after touches have ended.
*/
open var autoHideHighlightLine: Bool = false

/**
Alpha component for the area's color.
Expand Down Expand Up @@ -643,6 +648,8 @@ open class Chart: UIControl {

fileprivate func drawHighlightLineFromLeftPosition(_ left: CGFloat) {
if let shapeLayer = highlightShapeLayer {
shapeLayer.isHidden = false

// Use line already created
let path = CGMutablePath()

Expand Down Expand Up @@ -712,6 +719,7 @@ open class Chart: UIControl {

override open func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
handleTouchEvents(touches, event: event)
highlightShapeLayer?.isHidden = autoHideHighlightLine
delegate?.didEndTouchingChart(self)
}

Expand Down Expand Up @@ -790,4 +798,4 @@ open class Chart: UIControl {
let dy2 = level - p2.y
return (x: (p2.x * dy1 - p1.x * dy2) / (dy1 - dy2), y: level)
}
}
}