# Android Questiongraph showing the progress between two times

#### Almora

##### Active Member
Longtime User
Is there a similar graphic sample project as in the picture?

how can I do it..
thnks..

#### Attachments

• PicsArt_08-01-10.24.59.jpg
91.7 KB · Views: 112

#### Almora

##### Active Member
Longtime User
how do i get a look like in the picture ..

chart is very difficult for me.

#### Attachments

• PicsArt_08-02-08.12.00.jpg
26 KB · Views: 95

#### emexes

##### Expert
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.

#### Almora

##### Active Member
Longtime User
can you turn it into a small project?

#### emexes

##### Expert
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:

#### Attachments

• Sun.zip
9.8 KB · Views: 57

#### Almora

##### Active Member
Longtime User
that's great. Thank you very much for your time.

#### emexes

##### Expert
that's great. Thank you very much for your time.
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.

Replies
3
Views
239
Replies
3
Views
1K
Replies
397
Views
127K
Replies
90
Views
28K
Replies
105
Views
96K