Android Question How to Represent this information on the curve

Makumbi

Well-Known Member
Licensed User
Please help me i wanted to code this present this info on the curve

i have marks scores
say english 90
science70
mtc 60
sst 50
total marks 255
 

Attachments

  • .png
    .png
    14.7 KB · Views: 174

klaus

Expert
Licensed User
Longtime User
You can use the xChart class or b4x library.

Attached a small project with your example.
xChart doesn't draw a curve joining the bars like in your picture, because for me, it has no meaning.

1578393830249.png


The example project includes the xChart CustomView module.
If you want to use it, you might better use the xChart.b4xlib.

Just a question:
What represents the value of 255 in 'total marks 255' ?
If I calculate the total of the 4 values, what I did in the demo program, I get 270.
Therefore the question.
 

Attachments

  • BarChart.zip
    27.7 KB · Views: 186
Upvote 0

Makumbi

Well-Known Member
Licensed User
You can use the xChart class or b4x library.

Attached a small project with your example.
xChart doesn't draw a curve joining the bars like in your picture, because for me, it has no meaning.

View attachment 87244

The example project includes the xChart CustomView module.
If you want to use it, you might better use the xChart.b4xlib.

Just a question:
What represents the value of 255 in 'total marks 255' ?
If I calculate the total of the 4 values, what I did in the demo program, I get 270.
Therefore the question.
Thank you for the support is it possible to represent this with a curve only thank you in advance


Thank you klaus for the for effort

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

How can i use the above json code to insert data into a table so that i end up with barchat and line graph thanks
 
Last edited:
Upvote 0

Makumbi

Well-Known Member
Licensed User

B4X:
When i run it gives me this error am using b4a version 9 thanks
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:21)
    at anywheresoftware.b4a.objects.ActivityWrapper.build(ActivityWrapper.java:342)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:21)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:349)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at b4a.BarChart.main._activity_create(main.java:384)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.BarChart.main.afterFirstLayout(main.java:104)
    at b4a.BarChart.main.access$000(main.java:17)
    at b4a.BarChart.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    at anywheresoftware.b4a.objects.drawable.ColorDrawable.build(ColorDrawable.java:65)
    ... 25 more
java.lang.reflect.InvocationTargetException
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:21)
    at anywheresoftware.b4a.objects.CustomViewWrapper.build(CustomViewWrapper.java:90)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.DynamicBuilder.build(DynamicBuilder.java:21)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:349)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at b4a.BarChart.main._activity_create(main.java:384)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:732)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:351)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at b4a.BarChart.main.afterFirstLayout(main.java:104)
    at b4a.BarChart.main.access$000(main.java:17)
    at b4a.BarChart.main$WaitForLayout.run(main.java:82)
    at android.os.Handler.handleCallback(Handler.java:873)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:193)
    at android.app.ActivityThread.main(ActivityThread.java:6669)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object reference
    at anywheresoftware.b4a.objects.drawable.ColorDrawable.build(ColorDrawable.java:65)
    ... 26 more
** Activity (main) Resume **
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Do you test it Debug or Release Mode?
Which B4A version do you use? It seems version 9, I use version 9.50.
I have downloaded the zip file back from the forum, post #4, and it works on my device without an error.
 
Last edited:
Upvote 0
Top