Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change Background Color of Line Chart Entry on Selection in ios-charts

Tags:

ios-charts

I'm using the iOS Charts framework and am trying to achieve this custom selection style.

Screenshot of Chart

In this screenshot, the blue circles are my line data entries, and the purple box that red arrow points to on the '15.2' entry represents what I'm trying to achieve. So basically, instead of the standard "crosshair" the framework provides when the user selects an entry, I'd like to draw a custom selection view under the user selected entry akin to the purple box.

I'm still new to this framework - is there an easy way to accomplish this I'm missing?

like image 928
spirograph Avatar asked Nov 19 '25 02:11

spirograph


1 Answers

Well I've had a play and I couldn't find the iOS equivalent of the custom highlighter for android.

I have however changed the standard highlighter to match your requirements. If you just disable the horizontal highlighter and adjust width then add colour/ alpha to your requirements you should be able to achieve what you need.

        graphDataSet.setDrawHighlightIndicators(true)
        graphDataSet.drawHorizontalHighlightIndicatorEnabled = false
        graphDataSet.highlightLineWidth = 75
        graphDataSet.highlightColor = UIColor.blue.withAlphaComponent(0.5)

graphDataSet is your LineChartDataSet

let graphDataSet = LineChartDataSet(values: someValue, label: "Label")

Example

like image 69
M.Hem Avatar answered Nov 22 '25 02:11

M.Hem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!