gtcompscientist / KelloCharts

Kotlin Charts/graphs library for Android compatible with API 21+, several chart types with support for scaling, scrolling and animations
Apache License 2.0
50 stars 6 forks source link

Pulling Data from webservice API #6

Closed joshvapeter closed 6 years ago

joshvapeter commented 6 years ago

Hello @gtcompscientist , I have written a webservice api kotlin class and below is my value from the class. Your graph is plotting using random number. Can you plot the graph according to the below values.

private var jsonStringArray = "[{\"dailyuser\":\"2018-09-01\",\"usercount\":33},{\"dailyuser\":\"2018-09-02\",\"usercount\":44},{\"dailyuser\":\"2018-09-03\",\"usercount\":23},{\"dailyuser\":\"2018-09-04\",\"usercount\":77}] "

gtcompscientist commented 6 years ago

So my assumption would be that you are converting that data to an object with date and userCount properties. With that:

data class UserCountByDate(val dailyuser: Date, val usercount: Int)

//retrieve data
...

val arrayOfUserCounts = ArrayList<UserCountByDate>()
//convert json data to objects and add to array

val graphValues = arrayOfUserCount.map { PointValue(it.date, it.usercount) }

//add point values to the graph as shown in the README

Please note that I'm using the Deprecated Date class here, simply because it's succinct, how you manage that is up to you.

joshvapeter commented 6 years ago

Hello Anderson, I am new to kotlin programming so, please guide me what are all the kotlin file that I need to change. If you can change it for one line graph then I can handle for other graphs.

Thanks!

Joshva

“If you don’t build your dream someone will hire you to help build theirs."

On Fri, Sep 21, 2018 at 7:10 AM Charles Anderson notifications@github.com wrote:

So my assumption would be that you are converting that data to an object with date and userCount properties. With that:

data class UserCountByDate(val dailyuser: Date, val usercount: Int)

//retrieve data ...

val arrayOfUserCounts = ArrayList() //convert json data to objects and add to array

val graphValues = arrayOfUserCount.map { PointValue(it.date, it.usercount) }

//add point values to the graph as shown in the README

Please note that I'm using the Deprecated Date class here, simply because it's succinct, how you manage that is up to you.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/gtcompscientist/KelloCharts/issues/6#issuecomment-423544329, or mute the thread https://github.com/notifications/unsubscribe-auth/AWi6w2MDi1Ia4kdSSYey7kKbWyBQjS6Nks5udPNfgaJpZM4Wyt0_ .

gtcompscientist commented 6 years ago

You shouldn't need to change any files, just add your implementation.