How to graph MySQL data in android Kotlin?

-1

How can I create a kotlin android graphic using PHP to query the data stored in MySQL on an External server? Someone has an example. Thanks

    
asked by Damian Castillo 14.10.2018 в 17:16
source

1 answer

1

In your question there is no code so I will not provide an example, I will tell you how you can do it:

1) On the server side, with PHP, you need the script you invoke to devolve, for example, a file json , with the data to be plotted. This may be that you send the series. To do that the simplest thing is to place two data of the series in an associative array and generate the json with json_encode(array())

2) On the Android side, you need to bring the data from the server. To do this there are multiple libraries that you can use: Volley , Retrofit , or some other you know. You will see at what moment you want to update the data, that is, before which event (s) you are going to invoke the php on the server so that a new set of information arrives to you.

3) Once the data is received, you have to decode the json . You can deal directly with the json using the library jackson for example, or model the data in classes and use gson which in my opinion is simpler. Once this is done you will have a list of numerical data to graph.

4) To make the graphic I use a library called MPCharts . You will have to add it to the project in the gradle of the application, in github it explains how to do it and it is all the documentation of the project ( link ). At this point you will have to see the documentation and prepare the data to plot according to the graphic you choose. For example, if you sent two series, one that reflects the x axis and another the y axis of a graphing cartesiando, you will have to go through the two lists and assemble the points to plot. Maybe the graphic you choose, makes you change how you send the data in the json, maybe you choose to send the points already calculated instead of separate series. Once you give it a read you'll see it clearer.

    
answered by 14.10.2018 в 19:05