Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
ecoapps opened this issue Oct 26, 2016 · 1 comment
Closed

Comments

@ecoapps
Copy link

ecoapps commented Oct 26, 2016

Reposting from StackOverFlow:
http://stackoverflow.com/questions/40258956/add-uibuttons-to-data-points-in-a-line-graph-plotting-date-and-time-in-x-axis

Can I implement the following with Charts??


I am trying to plot some data on a simple line graph. Below is my class for storing the data.

How do I plot my yValues with time or date which are strings?

Also, I would like to add title as a UIButton to each data point in the graph. Tapping on the UIButton should display the corresponding detailedNote is a small popup. I have searched and digged into a lot of Chart libraries for iOS but didn't find a way to add this simple functionality.

graph-with-buttons-at-data-points.png
https://i.stack.imgur.com/HlTZT.png

Also, what is the way to filter and plot data for "Today", "Last Week", "Last Month" or for any interval of time?

Can I do all of this with iOS libraries like Core Plot and UIBeizerPath without help from any 3rd party frameworks/libraries? I prefer to use UIBeizerPath as I can smoothen the graph.. https://medium.com/@ramshandilya/draw-smooth-curves-through-a-set-of-points-in-ios-34f6d73c8f9#.28frf03to

Can someone point me to the right resources.. Posting swift code is 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())
}()

}
@liuxuan30
Copy link
Member

liuxuan30 commented Oct 27, 2016

I guess the first thing you should do is to play with ChartsDemo. You will find all answers there. Adding buttons are useless with this library.

And I believe all your needs will be satisfied with this library - or definitely you can write them without any 3rd parties

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants