Jump to content

phpMyGraph - error with negative numbers


MattR

Recommended Posts

I'm using phpMyGraph and I've run into a problem. I'm making a graph for temperatures over the day, and filling in any missing data with blanks (i.e. if it's only 12 noon, 13:00 - 23:00 get inserted with empty data/empty bars so the bars are all proportionate). Array for the actual data I've got:

 

Array
(
    [00] => -1.4
    [01] => -1.2
    [02] => -1.5
    [03] => -2.3
    [04] => -3.2
)

 

Basically just data from midnight to 04:00. It draws fine like this, all the bars are below the 0 line, but they're all very thick and take up the entire width of the graph, as that's all the data there is; see first attachment, (ignore the chopped off title), it's spreading it out and it isn't very clear. So, for the other hours I just loop through and populate it with 0, just so there's an empty space for each one:

 

Array
(
    [00] => -1.4
    [01] => -1.2
    [02] => -1.5
    [03] => -2.3
    [04] => -3.2
    [05] => 0
    [06] => 0
    [07] => 0
    [08] => 0
    [09] => 0
    [10] => 0
    [11] => 0
    [12] => 0
    [13] => 0
    [14] => 0
    [15] => 0
    [16] => 0
    [17] => 0
    [18] => 0
    [19] => 0
    [20] => 0
    [21] => 0
    [22] => 0
    [23] => 0
)

 

What I'd expect to see is the bars from before with the bars from 05-23 there as well, but empty. This method works fine, other graphs are OK, the problem is that if the first value is a negative, and there is a 0 anywhere in the data after that, no bars will show at all, see second attachment. If I put a positive number at the start, they show fine, if I have a negative at the start and replace the 0 with 0.0000001, it's fine, it's only if it starts with a negative and contains a 0. Putting 0.0000001 instead of 0 is not a solution as then the value on the bar is 1E-12 or something. I've looked at the code and can't see why it happens, if anyone can I'd be very grateful. Apart from this issue the class is very good. Unfortunately though there doesn't seem to be a clear way of contacting the author via their website.

 

Thanks.

 

[attachment deleted by admin]

Link to comment
Share on other sites

  • 6 months later...

Hi,

 

I stumbled on this posting and was not aware of this bug in my graph class.

The problem is now fixed in version 5.0.4

I also added my e-mail adres on the top of my phpMyGraph page, so next time send me a bugreport.

Thanks for using my software and reporting the bug.

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.