3

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?

spirograph
  • 59
  • 1
  • 5
  • Did you figure this out? It is possible, if you see the documentation here https://github.com/PhilJay/MPAndroidChart/wiki/Highlighting you will see about the custom highlighter. I’ve not ever implemented it myself, but will have a poke around. You working in Swift or Obj C? – M.Hem Feb 02 '19 at 17:56
  • @M.Hem Thanks for the doc link. Haven't figure it out yet unfortunately. I'm working in Swift, and any help is much appreciated. – spirograph Feb 03 '19 at 18:45
  • Can you add some code of chart setup so I can help on that ? – CodeChanger Feb 05 '19 at 08:41

1 Answers1

3

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

M.Hem
  • 165
  • 2
  • 7