Android Tutorial Android Charts Framework

Status
Not open for further replies.

chrjak

Active Member
Licensed User
Longtime User
Am I missing something? calcPointToPixel is marked red...
 

deantangNYP

Active Member
Licensed User
Longtime User
HI Erel, Possible to have the X-Axis in float or integer?
Can it be done? This will allow it to space the values on the x-axis correctly. Thanks

AddLinePoint (LD As LineData, X As String, Y As Float, ShowTick As Boolean)

 

klaus

Expert
Licensed User
Longtime User
You can already set x as Float or Int.
If you look at the LineChart and LineChart1 example projects in the User's Guide.
This works:
B4X:
' Add the line points.
For i = 0 To 360 Step 10
    ' In the case of 2 lines or more we are adding an array of values.
    ' One for each line.
    ' Make sure to create an array for each point.
    ' You cannot reuse a single array for all points.
    Charts.AddLineMultiplePoints(LD, i, Array As Float(SinD(i), CosD(i)), i Mod 90 = 0)
Next
This too:
B4X:
' Add the line points.
Dim x As Float
For i = 0 To 500 Step 10
    ' In the case of 2 lines or more we are adding an array of values.
    ' One for each line.
    ' Make sure to create an array for each point.
    ' You cannot reuse a single array for all points.
    x = i / 100
    Charts.AddLineMultiplePoints(LD, x, Array As Float(Rnd(-20,21) + 20, Rnd(-15,16) - 20, CosD(3 * i) * 35), i Mod 50 = 0)
Next
 

deantangNYP

Active Member
Licensed User
Longtime User
Hi Klaus, thanks for the reply. If that's the case, how can i have a correct spacing proportional to the reading on the x-axis?
Please see the picture. Spacing between unit 1 and 2 , should not be the same as spacing between unit 4 and 10.
Thanks. Please advise. Did i do something incorrect?
I am using a simple AddLinePoint for testing.
B4X:
       Charts.AddLinePoint(LD, 0, 0, True )
    Charts.AddLinePoint(LD, 1, 80, True )
    Charts.AddLinePoint(LD, 2, 70, True )
    Charts.AddLinePoint(LD, 3, 40, True )
    Charts.AddLinePoint(LD, 4, 40, True )
    Charts.AddLinePoint(LD, 10, 70, True )


https://www.dropbox.com/s/c9cnrnrs48vauco/chart1.JPG?dl=0

 

klaus

Expert
Licensed User
Longtime User
Now I understand what you mean.
The LineChart doesn't support what you want to do it supposes equal distances between points.
You would need to add this feature yourself or write your own routine.
That's what I did in the DynSim simulation program.
You might have a look at chapter 11.3.1 Diagrams / Graph example program in the B4A User's Guide.
There are also other diagram or chart libraries in the forum.
 

deantangNYP

Active Member
Licensed User
Longtime User

THANKS for the reply
 

trueboss323

Active Member
Licensed User
Longtime User
Have a look at THIS post.

The code you provided saves the image to the SD root directly. What happens if the user doesnt have an SD card? Moreover, the image does not appear in the Gallery app, how can I get it to appear there?
 

swChef

Active Member
Licensed User
Longtime User
Has anyone looked into making this available as/in a service, to create a chart for a purpose other than live Activity display ?
Or is there a better alternative for that case?
 

swChef

Active Member
Licensed User
Longtime User
I didn't have time to review it today, but did you mean (a few changes) in the library itself, or is it possible on the application side? From my efforts this past weekend I think modifying the library is necessary.
 

Rob Bliss

Member
Licensed User
Has anyone been clever enough to show a popup panel when clicking a portion of a Stacked Bar Chart?? I've tried replacing the panel and canvas from BarData with ones created in the activity, but can't get the panel_touch/click events to fire (I figured BD.Target_Click wouldn't work either due to the fullstop), let alone register which section of the chart it has touched.

Any help is much appreciated.
 

Rob Bliss

Member
Licensed User
What exactly do you want to do?
What kind of data do you want to display?

I've done it now, after a bit of fiddling, using xCharts, but the idea was to click/touch a section of a stacked column, or just the column, then for a panel to appear displaying things like the value of the section, the column. Maybe colour the section names and display all the values at once. Just anything to give that bit more information. The solution given with xCharts more than suits my needs.
 

pazzokli

Active Member
Licensed User
Longtime User
Hi, I would like keep tablet in portrait mode but see line graph with x axis in vertical
Is it possible?
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…