Android Question How to Create BARChart and Line Graph using Json Extracted Values

Makumbi

Well-Known Member
Licensed User
B4X:
[{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"MATHEMATICS","Mid":null,"Ends":null,"Grade":"3","Term":"END TERM 3 2019","Years":"2020","Total":74,"PHOTOS":null,"autofield":1},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"ENGLISH","Mid":null,"Ends":null,"Grade":"2","Term":"END TERM 3 2019","Years":"2020","Total":82,"PHOTOS":null,"autofield":2},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"LITERACY2","Mid":null,"Ends":null,"Grade":"2","Term":"END TERM 3 2019","Years":"2020","Total":85,"PHOTOS":null,"autofield":3},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"LITERACY1","Mid":null,"Ends":null,"Grade":"3","Term":"END TERM 3 2019","Years":"2020","Total":76,"PHOTOS":null,"autofield":4},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"R.E","Mid":null,"Ends":null,"Grade":"3","Term":"END TERM 3 2019","Years":"2020","Total":79,"PHOTOS":null,"autofield":5},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"END TERM 3 2019","Years":"2020","Total":317,"PHOTOS":null,"autofield":6},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"TOTAL MARKS","Mid":null,"Ends":null,"Grade":null,"Term":"END TERM 3 2019","Years":"2020","Total":317,"PHOTOS":null,"autofield":7},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"TOTAL AGG","Mid":null,"Ends":null,"Grade":null,"Term":"END TERM 3 2019","Years":"2020","Total":10,"PHOTOS":null,"autofield":8},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"TOTAL AGG","Mid":null,"Ends":null,"Grade":null,"Term":"END TERM 3 2019","Years":"2020","Total":10,"PHOTOS":null,"autofield":9},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"DIVISION","Mid":null,"Ends":null,"Grade":null,"Term":"END TERM 3 2019","Years":"2020","Total":1,"PHOTOS":null,"autofield":10},{"Account":"17-06393","class":"P2","Stream":"T","Names":"NAMIIRO HELLENA PRAISE","Subject":"DIVISION","Mid":null,"Ends":null,"Grade":null,"Term":"END TERM 3 2019","Years":"2020","Total":1,"PHOTOS":null,"autofield":11}]

i have the Json record above

and so i wanted to use the code below to insert this record which is having scores and their subjects
Example
Mathematics 74
LiteracyA 85
English 82
LiteracyB 85
TOTAL MARKS :317

B4X:
Dim parser As JSONParser
parser.Initialize(<text>)
Dim root As List = parser.NextArray
For Each colroot As Map In root
Dim Account As String = colroot.Get("Account")
Dim Years As String = colroot.Get("Years")
Dim Mid As String = colroot.Get("Mid")
Dim autofield As Int = colroot.Get("autofield")
Dim Grade As String = colroot.Get("Grade")
Dim Term As String = colroot.Get("Term")
Dim Subject As String = colroot.Get("Subject")
Dim Names As String = colroot.Get("Names")
Dim Total As Int = colroot.Get("Total")
Dim Ends As String = colroot.Get("Ends")
Dim Stream As String = colroot.Get("Stream")
Dim class As String = colroot.Get("class")
' Dim PHOTOS As String = colroot.Get("PHOTOS")
Next

I have attached a sample database which can be used so that i can be help using that example please help me out thanks
so i would want to display the bar chart and line graph as attached in the samples below. in the array which i wanted to be generated it should automatically pick results from the json and then insert them into the array so that this Chart is generated thank you for the big effort
 

Attachments

  • Backup BarChart 2020-01-15 20.37.zip
    27.8 KB · Views: 53
  • Screenshot_1579524155.png
    Screenshot_1579524155.png
    49.8 KB · Views: 65
Top