Android Question How do I draw graphics?

Itila Tumer

Active Member
Licensed User
Longtime User
Hi,
According to the data from the text every 10 seconds I need to write data to the chart. I've looked at examples from the forum, but it's complicated and I don't understand. How do I do it more simply.
 

klaus

Expert
Licensed User
Longtime User
You need to give some more detailed explanations on what exactly you want to do.

According to the data from the text every 10 seconds
What kind of text?
What kind of data?
Where does it come from?
How many data on the chart?
 
Last edited:
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
You need to give some more detailed explanations on what exactly you want to do.


What kind of text?
What kind of datea?
Where does it come from?
How many data on the chart?


Hi Klaus,
The X axis shows time. The y-axis shows numerical data. I want to draw the graph dynamically according to the data from every second. Incoming data are numeric values that I get from an array. I have studied samples and libraries but have become thoroughly confused.
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I'm getting an error in the library installation.
How did you do it?
Without knowing what you have done it's impossible to give a concrete advice.

You have two possibilties:
1. Use the class, the xChart.bas file, add it with Project/Add Existing Modules. This works with older B4A versions.
2. Use the xChart.b4xlib, you must add it in the AdditionalLibraries folder, don't add the xChart.xml file. This works only for B4A 8.80+.
If you have B4A 9.00, then you should redefine the AdditionalLibraries folder, have a look HERE to see how to do it.
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
I get an error like that. I do not understand why?
Error description: xChart has been defined twice. You must remove the library reference or code module.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
I get an error like that. I do not understand why?
Error description: xChart has been defined twice. You must remove the library reference or code module.
Either use the Class in your project OR the Library. Not both at the same time.
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User
Post errors as TEXT Please!


Error occurred on line: 1027 (xChart)
java.lang.NumberFormatException: Invalid double: "null"
at java.lang.StringToReal.invalidReal(StringToReal.java:63)
at java.lang.StringToReal.parseDouble(StringToReal.java:269)
at java.lang.Double.parseDouble(Double.java:295)
at b4a.xChartsDemo.xchart._getscalemant(xchart.java:2081)
at b4a.xChartsDemo.xchart._calcscaleauto(xchart.java:1596)
at b4a.xChartsDemo.xchart._initchart(xchart.java:3990)
at b4a.xChartsDemo.xchart._drawchart(xchart.java:482)
at b4a.xChartsDemo.main._createlinechart1data(main.java:547)
at b4a.xChartsDemo.main._activity_create(main.java:403)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
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.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
at b4a.xChartsDemo.main.afterFirstLayout(main.java:104)
at b4a.xChartsDemo.main.access$000(main.java:17)
at b4a.xChartsDemo.main$WaitForLayout.run(main.java:82)
at android.os.Handler.handleCallback(Handler.java:725)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5306)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1102)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:869)
at dalvik.system.NativeStart.main(Native Method)
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
I just downloaded the xChart_V3_8.zip file from the forum and running the B4A project, you are right, I get the same error.
I am very sorry for the inconvenience.
As a workaround, load the program in the IDE, run the Designer, and quit it, and confirm to save it. Then the program works.
The project has been updated in the first post in the xChart class thread.
 
Upvote 0

Itila Tumer

Active Member
Licensed User
Longtime User

Thanks, I have one more question.
The data in the dynamic graph is random.
I want to send data from a list or array.
I've been in a few trials, but it hasn't. How can I do it?
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
Use smothing like this:
B4X:
xChart1.AddLineMultiplePoints(YourXValue, Array As Double(Y1, Y2), True)
xChart1.DrawChart
AddLineMultiplePoints(X As String, YArray As Double, ShowTick As Boolean)
X = String for the X axis value
YArray = Array of Doubles with the Y values.
True = Show the x value on the chart.
 
Last edited:
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…