Android Question graph showing the progress between two times

Discussion in 'Android Questions' started by Almora, Aug 1, 2019.

  1. Almora

    Almora Active Member Licensed User

    Is there a similar graphic sample project as in the picture?

    how can I do it..
    thnks..
     

    Attached Files:

  2. Jeffrey Cameron

    Jeffrey Cameron Active Member Licensed User

  3. Almora

    Almora Active Member Licensed User

    how do i get a look like in the picture ..

    chart is very difficult for me.
     

    Attached Files:

  4. emexes

    emexes Well-Known Member Licensed User

    Well, the math behind it is simple enough.

    Dim X1 As Float = 123 'left
    Dim X2 As Float = 987 'right
    Dim Y1 As Float = 135 'top
    Dim Y2 As Float = 357 'bottom

    Dim T1 As Float = 5 * 60 + 27 'eg time-of-day in minutes
    Dim T2 As Float = 19 * 60 + 41

    and then you just need something to calculate the X and Y of the sun position or path at time T

    Dim P As Float = (T - T1) / (T2 - T1) 'P is proportion 0..half..1 of T within time range T1..midday..T2
    Dim X As Float = X1 + P * (X2 - X1)
    Dim Y As Float = Y2 + SinD(P * 180) * (Y1 - Y2) 'shape good enough; if you really need a circular arc, it can be done with a bit more math

    so all you have to do now is put coloured pixels at those locations... how hard could that be?!?!

    A starting point might be to make a small square panel to represent your sun (background = yellow) and set the corner radius sufficiently large to turn the square into a circle (or somewhere in between, to make your app more memorable ;-) You can then move the sun about by changing the panel's Left and Top (aka X and Y) properties.
     
    Shelby, José J. Aguilar and Almora like this.
  5. Almora

    Almora Active Member Licensed User

    can you turn it into a small project?
     
  6. emexes

    emexes Well-Known Member Licensed User

    I wasn't going to, but... luckily for you, I ain't got nuthin' better to do over dinner, so... give this a try.

    Plan (Designer) vs Realisation:

    upload_2019-8-2_18-50-52.png upload_2019-8-2_18-50-5.png
     

    Attached Files:

    • Sun.zip
      File size:
      9.8 KB
      Views:
      9
  7. Almora

    Almora Active Member Licensed User

    that's great. Thank you very much for your time.
     
  8. emexes

    emexes Well-Known Member Licensed User

    Just noticed from screenshots that there is a bug in the time-formatting routine: the hours must be getting rounded off to the nearest integer.

    Solution is to Floor the Time / 60 divisions eg:

    NumberFormat2(Floor(SunriseTime / 60), 1, 0, 0, False)

    so that there is no fractional part for NumberFormat2 to round off.
     
    Almora and Shelby like this.
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