Android Question Creating a bar chart using two array's

Colin Evans

Active Member
Licensed User
Longtime User
Following on from my previous post, I would like to know how best to add the data contained in two array's
B4X:
For i = 0 To 99
                    Dim str As Map = results.Get(i)
                    Dim strVar As String = str.Get("interval_end")
                    Dim strArray() As String=Regex.Split("T",strVar)
                    Dim TextExtract As String=strArray(0)
                    from=TextExtract
                    cons = str.Get("consumption")
                    tim0 = str.Get("interval_start")
                    tim0 = tim0.SubString2(11,16)
                    tim1 = str.Get("interval_end")
                    tim1 = tim1.SubString2(11,16)
                    N(i) = tim0 
                    V(i) = cons
                    AddRow(Array As String(from, tim0, tim1, cons))
                Next

the data held in N and V, I basically want to show the bar chart based on three segments of the data, i.e. N(1) and V(1) to N(33) and V(33), then be able to select N(34) V(34) to N(66) V(66) and then select N(67) V(67) to N(100) V(100), hope that makes sense, I have tried using a Bar Chart example but sadly getting nowhere
 

Colin Evans

Active Member
Licensed User
Longtime User
Yes just tried 1 to 5, when you scroll you can see the red line and the graph data is a very small part of the barchart image but just a white image, turn to landscape and it shows the 10 bars, weird
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Yes just tried 1 to 5,
Sorry, but I just tested klaus project on 3 devices 10 inch tablet, 7 inch tablet and a Galaxy S10e phone for range of 1 to 5. The graph and data points looks great on all of them, portrait and landscape. What are you testing on, a 2 inch device?
 
Upvote 0

OliverA

Expert
Licensed User
Longtime User
Upvote 0

klaus

Expert
Licensed User
Longtime User
What is the width of your chart?
Attached a new version with a small change.
Are you sure you tested it with the last version of the xChart class?
On my device, with a chart width of about 340dips, it displays up to 52 bars with the attached new version.
1588854184837.png
 

Attachments

  • xChart.bas
    143.2 KB · Views: 203
Upvote 0

klaus

Expert
Licensed User
Longtime User
Sorry, no use the attached library.
Looking closer at your chart it looks strange to me.
It seems that you have bars with 0 values !?
With 5 bars it should look like this:

1588854970463.png
 

Attachments

  • xChart.b4xlib
    23.7 KB · Views: 204
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Hi, copied the new class in libraries and re run
Screenshot_1.pngScreenshot_2.png as you said it should look like yours, the next one is with for i 1 to 48 which is basically what I want
Screenshot_3.png
 
Upvote 0

Colin Evans

Active Member
Licensed User
Longtime User
Thanks Klaus and everyone else, I think I was confusing myself, now I've got my head in gear it's working fine, thank you very much, I believe I was using the library in Klaus's example but the xChart.bas in my app, I'm sorted now thanks
 
Upvote 0
Top