swift - Add UIButtons to data points in a line graph, plotting date and time in X-axis -


i trying plot data on simple line graph. below class storing data.

how plot yvalues time or date strings?

also, add title uibutton each data point in graph. tapping on uibutton should display corresponding detailednote small popup. have searched , digged lot of chart libraries ios didn't find way add simple functionality.

graph-with-buttons-at-data-points.png

also, way filter , plot data "today", "last week", "last month" or interval of time?

can of ios libraries core plot , uibeizerpath without 3rd party frameworks/libraries? prefer use uibeizerpath can smoothen graph.. https://medium.com/@ramshandilya/draw-smooth-curves-through-a-set-of-points-in-ios-34f6d73c8f9#.28frf03to

can point me right resources.. posting swift code highly appreciated!

class noteentry { var title: string?  var detailednote: string?  var yvalue: float? = 0  let timestring : string  = {     let formatter = nsdateformatter()     formatter.dateformat = "h:mm a"     formatter.amsymbol = "am"     formatter.pmsymbol = "pm"     return formatter.stringfromdate(nsdate()) }()  let datestring: string = {     let formatter = nsdateformatter()     formatter.dateformat = "d"     return formatter.stringfromdate(nsdate()) }()  let dayoftheweekstring: string = {     let formatter = nsdateformatter()     formatter.dateformat = "eee"     return formatter.stringfromdate(nsdate()) }()  let monthandyearstring: string = {     let formatter = nsdateformatter()     formatter.dateformat = ""     return formatter.stringfromdate(nsdate()) }()  } 

here answer of how swiftcharts:

  1. how plot yvalues time or date strings? have convert strings dates. otherwise chart not know how order them. advice store in model class dates instead of strings. formatting need strings, or have @ least in separate (computed) variables or extensions. how make charts dates in swiftcharts there examples in library, orient them.

  2. title uibutton can use kind of uiviews chart points / overlays / etc. line titles, have line layer , layer adds tappable titles, see e.g. notificationsexample - near want do. uses handlingview instead of uibutton able tap handling in closure instead of using selectors. selector lose context of chart point you're handling tap for.

  3. filtering data "today", "last week" etc. recommend opening new question this. shouldn't bundle many questions. not related charts library, no charts library you. have use nsdatecomponents. maybe there's library time operations - said separate question.

  4. core plot third party framework :) of course can develop chart scratch i'd recommend using library. particular case swiftcharts seems suitable, should able chart done modified version of notificationsexample use dates instead of numbers (copy dates other example), , adjusting tappable overlays.

for more questions feel free comment or issue opened in swiftcharts.

(disclaimer: i'm author of swiftcharts).


Comments

Popular posts from this blog

python - How to insert QWidgets in the middle of a Layout? -

python - serve multiple gunicorn django instances under nginx ubuntu -

module - Prestashop displayPaymentReturn hook url -