B4A Library MPAndroidCharts - Various type of graphs / charts (most recent library files in post #362)

Discussion in 'Additional libraries, classes and official updates' started by Johan Schoeman, Sep 5, 2015.

  1. Johan Schoeman

    Johan Schoeman Expert Licensed User

    I would suggest that for now you use V1.06 (attached). I need to revisit V1.07 as I discovered an error in V1.07 that I need to rethink and correct.....
     

    Attached Files:

  2. Pencil3

    Pencil3 Member Licensed User

    Have a question that I have not been able to figure out on my own. I am trying to use your single line chart to plot points from a db. Have that working almost perfectly, I would like to plot the last 7 entries from the db. When using LineData = 7 the first 7 entries from the db are plotted. How can I set it to plot the last 7 entries?
     
  3. beaker

    beaker Member Licensed User

    Thanks Johan, that seems to have fixed it. Again, apologies for the delay since your post #271 but I'm not getting emails alerting me to all new posts in this thread. I only seem to get the odd one now and then.
     
    Johan Schoeman likes this.
  4. Descartex

    Descartex Well-Known Member Licensed User

    I think it is not a problem of the library, but of the data that you pass to the chart.
    Try to pass only the last 7 data in your database and will surely display correctly as you want.
    Regards.
     
    Pencil3 and Johan Schoeman like this.
  5. jahswani

    jahswani Active Member Licensed User

    SELECT * FROM DATAS LIMIT 7;
     
    Pencil3 likes this.
  6. Pencil3

    Pencil3 Member Licensed User

    Thank you, I tried this and it does only pull 7 entries, but they are still the first 7, not the last 7 that I would like to graph.

     
  7. jahswani

    jahswani Active Member Licensed User

    SELECT * FROM DATAS ORDER BY ID DESC LIMIT 7;
     
    Johan Schoeman and Pencil3 like this.
  8. Pencil3

    Pencil3 Member Licensed User

    Thank you! Very much appreciate the help. You have put me on the right track. I just need to flip the points on the graph now so that the last entry shows on the right side of the graph and first entry on the left side. The graph currently shows the opposite.

     
  9. Pencil3

    Pencil3 Member Licensed User

    Thanks again jahswani for pointing me in the right direction.

    "SELECT * FROM (SELECT * FROM db DATAS ORDER BY ID DESC LIMIT 7) TMP ORDER BY ID ASC"

     
    jahswani likes this.
  10. Pencil3

    Pencil3 Member Licensed User

    I may be missing something as far as rounding goes. If I try to plot the value "38.5" the graph displays it as "38.00". Another example would be trying to plot the value "9.5". On the graph it shows as "9.0". What am I overlooking?
     
  11. beaker

    beaker Member Licensed User

    Have you tried setting the GraphValueDigits property?
     
    jahswani likes this.
  12. Pencil3

    Pencil3 Member Licensed User

    Yes, I did, but it didn't help. For example when I set mlc1.GraphValueDigits = Array As Int(2, 2, 2, 2, 2) and plot the value of "38.5" the value is plotted on the graph as 38.0.

     
  13. beaker

    beaker Member Licensed User

    Hmmm... I thought that would fix your problem. Without seeing the code it's difficult to say. Your values aren't being converted to integers somewhere along the line are they?
     
  14. Johan Schoeman

    Johan Schoeman Expert Licensed User

    Can you upload a small sample project? Will be easier to see what the problem is.
     
  15. Pencil3

    Pencil3 Member Licensed User

    Beaker is correct, they are being converted. Trying to figure it out lol.

    Code:
    Dim SalValue As List :SalValue.Initialize
                
    Dim SalDate As List    :SalDate.Initialize
                
    Dim txtSal As String
                
    Dim CursorSal As Cursor
                           
                txtSal=
    "SELECT * FROM (SELECT * FROM db DATAS ORDER BY ID DESC LIMIT 14) TMP ORDER BY ID ASC"
                CursorSal=Starter.SQL1.ExecQuery(txtSal)
                
    For i=0 To CursorSal.RowCount -1
                    CursorSal.Position=i
                    SalValue.Add(CursorSal.GetInt(
    "A01Sal"))
                    SalDate.Add(CursorSal.GetString(
    "A01Date"))
                
    Next
               
                
    Dim PSal(SalValue.Size) As Float
                
    Dim CSal(SalDate.Size) As String
       
                
    For i=0 To SalValue.Size -1
                    PSal(i)=SalValue.Get(i)
                    CSal(i)=SalDate.Get(i)
                
    Next
     
  16. beaker

    beaker Member Licensed User

    Could it be this line that's causing the issue by any chance?
    Code:
    SalValue.Add(CursorSal.GetInt("A01Sal"))
    This might be better:
    Code:
    SalValue.Add(CursorSal.GetDouble("A01Sal"))
    or
    Code:
    SalValue.Add(CursorSal.GetString("A01Sal"))
    I've used GetString and assigned the value to a Float variable for the multiline chart. This worked for me.
     
    Pencil3 likes this.
  17. Pencil3

    Pencil3 Member Licensed User

    Success! Thank you beaker! Last night I tried:

    Code:
    SalValue.Add(CursorSal.GetString("A01Sal"))
    And I received empty string errors.

    I just tried your second suggestion of:

    Code:
    SalValue.Add(CursorSal.GetDouble("A01Sal"))
    And presto, works perfectly. Thank you again.

     
  18. beaker

    beaker Member Licensed User

    Good, I'm pleased we found the issue. I think I've avoided the empty string issue by making sure the field(s) can't be empty either by validating the data before committing it to the DB Table and/or making sure the field's NotNull constraint is set to 'True'.

    I think this has become off-topic for this thread now :oops:
     
    Pencil3 likes this.
  19. peacemaker

    peacemaker Well-Known Member Licensed User

    HI, All

    It's very interesting lib, trying the b4aMPMultiLineChartV5 sample.
    But maybe any help, if it's possible: if we need to combine several lines on a single chart - the first line is the main one, making the max chart Y-size - the scale for whole the chart. And for the best data comparision at the same time - all next lines must be added within the scale of the first main line.
    If main line values, say, are 600 ... 800 (Min1 ... Max1), but others are 0...5, or 0...100 - they must be scaled: * (Max1 - Min1) to fill the whole chart Y-size. But the visible values of the scaled lines should be shown real, without scaling.
    Is it possible ?

    See the screenshots:
    1) the main line is red, the view should be as "0.28" (all lines maximally expanded by Y-axle)

    2) green line value scaled is on "correctly scaled" = 379, but with value marker is needed as from "real values", really it's value = 50.

    So, task is to show all lines maximally expanded by Y-axle, with real values on the markers.
     

    Attached Files:

    Last edited: Aug 14, 2017
  20. peacemaker

    peacemaker Well-Known Member Licensed User

    I mean in the prev post - it would be super, if to just add mlc1.Chart_x_Alias like mlc1.Chart_x_Data. And draw using _Data, but _Alias for showing on the marker.
    This will allow to combine not only digit line charts, but any event lines.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice