[56K WARN] JPGraph axis question [SOLVED]

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

[56K WARN] JPGraph axis question [SOLVED]

Post by Chris Corbyn »

Hi,

I'm using JPGraph to plot a line graph but the units are in degrees (0-360).

Now, if the line ran from 0-360 it would all be good ;-) BUT, Some lines do the opposite and go from 270-90 (looping back to the start of the circle).

Can I get my X axis scale in JPGraph to go 270-360, then 0-90?

Like this (not JPGraph in this case);

Image

I'm actually on quite a tight dealine to get this fixed :?

Thanks if anybody can help.
Last edited by Chris Corbyn on Sun May 01, 2005 3:13 pm, edited 3 times in total.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

I could even shift the value for the sake of constructing the graph so long as I can make it look like I have used the actual values by printing 270-360, then 0-90 on the axis (a dirty fix)... Can I do this if I can't make a split scale?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Actually, in an ideal world it should go 180-360, 0-180.

Do I need to rephrase my question or is it just that nobody has used JPGraph?
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

Have you considered creating two graphs and parsing them next to each other?
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

Hmm... you could have an idea there.

What this is all for is realted to the suns position in the sky. Everything goes pear shaped in the southern hemisphere (I have already got the code to work out which hemisphere it's working in).

The only issue with that is that there will be a gap between the two lines (at the 360 degrees point)...

I'll play around but ideally I need a wonky scale :P
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

OK one problem is fixed.....

I have gone from this.....
Image

to this....

Image

By adding 360 to anything less than 180. But now the values appear wrong on the scale. Can I somehow overwrite the values on the X axis with my own text without destroying the plotted points?

I'm currently using 'intlin' but I'll change to whatever works.
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

It's OK guys I have worked this out.

I tried this before and it didn't work but now I know why.

$graph->xaxis->SetTickLabels($ticks_array);

I didn't realise it takes every single integer as a tick (so I need hundreds of ticks but I for() loops will suffice to make these ;-) ).
Post Reply