0

I am building a statistics section of my app and for that reason i use the wonderful ios-charts library. After i finished all my work, i wanted to add a feature where when the user doubleTaps on one bar of the chart, then it switches to another chart, containing that data visualized in another way.

But the problem is that the library uses the doubleTap gesture for zoom only. So i cannot add my own, because it would conflict, and i cannot change the handler, because the function is private. (and i really don't want to change the source code)

And after researching on their GitHub i found, that you can use your own gesture if you subclass the chartView.

My question is, how should i solve this problem? I tried the subclassing, but couldn't get the variables and funcs i needed, i tried overriding, but that gave me an error message stating that this variable/function does not exist in the superclass.

I would appreciate some help with code examples so that i can learn how to do it the right way.

Elliot Czigány
  • 188
  • 1
  • 14
  • Maybe you could look into using an Action sheet, https://developer.apple.com/documentation/swiftui/actionsheet? – Joakim Danielson May 07 '21 at 10:42
  • @JoakimDanielson excuse me but how would an action sheet solve this problem? – Elliot Czigány May 07 '21 at 11:34
  • Instead of a double tap you have long press and then a menu to select the option from, it might not be ideal but I suggested it as a mere alternative to investigate if you don't get a better solution – Joakim Danielson May 07 '21 at 11:43
  • check this class `BarLineChartViewBase` see there line number 135 set it as false. so double tap will be disable. if you want to change double tap event. you can check line number 558 double tap function called. –  May 07 '21 at 11:54
  • @RB's Thank you, i have found these lines too, but i want a way without changing the source code – Elliot Czigány May 07 '21 at 18:03
  • @ElliotCzigány for that you should try some code in double tap function. –  May 08 '21 at 04:04

1 Answers1

0

Create a MarkerView when user clicks on Chart

Follow the link to make chart bars clickable & implement your own functionality.