After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 590903 - faulty x-axis in xy plot
faulty x-axis in xy plot
Status: RESOLVED NOTABUG
Product: Gnumeric
Classification: Applications
Component: Charting
git master
Other Linux
: Normal normal
: ---
Assigned To: Emmanuel Pacaud
Jody Goldberg
Depends on:
Blocks:
 
 
Reported: 2009-08-06 03:55 UTC by Andreas J. Guelzow
Modified: 2009-08-07 11:01 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Sample file (2.42 KB, application/octet-stream)
2009-08-06 13:06 UTC, Emmanuel Pacaud
Details
screenshot (10.01 KB, image/png)
2009-08-06 15:03 UTC, Jean Bréfort
Details

Description Andreas J. Guelzow 2009-08-06 03:55:45 UTC
1) new gnumeric
2) B2 gets "hello", C2 gets "good", D2 gets "bye"
3) B3:B8 gets 1.1, 1.2, 1.3, 1.4, 1.5, 1.6
4) C3:C8 gets 12, 13, 14, 15, 14, 12.5
5) D3:D8 gets 34,24,19, 27, 22, 5

select B2:D8

insert chart, XY, use first series as common abscissa

forward, insert

the problem is the x-axis: the bounds should be "automatic, but why is it using x=0 as the minimum?
Comment 1 Jean Bréfort 2009-08-06 06:28:02 UTC
I can't reproduce. All axis settings are automatic for me.
Comment 2 Emmanuel Pacaud 2009-08-06 06:37:58 UTC
I'm able to reproduce, and it's the intended behaviour (which doesn't mean I like it). The rationale being for a set of values near to zero, make the axis stick to zero. Probably similar to what XL does.
Comment 3 Andreas J. Guelzow 2009-08-06 07:33:56 UTC
Near to zero? THe values are 1.1 to 1.6, so 0 is about 180% of the range away...  
Comment 4 Jean Bréfort 2009-08-06 07:47:58 UTC
I still get 1 as minimum for the x axis. The y-axis starts from 0.
Comment 5 Emmanuel Pacaud 2009-08-06 13:05:36 UTC
The code is in gog-axis.c, starting at line 631:

	/* pull to zero if its nearby (do not pull both directions to 0) */
	if (bound[GOG_AXIS_ELEM_MIN] > 0 &&
	    (bound[GOG_AXIS_ELEM_MIN] - 10. * step) < 0)
		bound[GOG_AXIS_ELEM_MIN] = 0;
	else if (bound[GOG_AXIS_ELEM_MAX] < 0 &&
	    (bound[GOG_AXIS_ELEM_MAX] + 10. * step) > 0)
		bound[GOG_AXIS_ELEM_MAX] = 0;

Adreas, feel free to ask the list about this issue.

Jean, I'm attaching a sample file that exhibits the same behaviour.
Comment 6 Emmanuel Pacaud 2009-08-06 13:06:00 UTC
Created attachment 140020 [details]
Sample file
Comment 7 Jean Bréfort 2009-08-06 15:03:08 UTC
Created attachment 140038 [details]
screenshot

I still don't see the issue.
Comment 8 Andreas J. Guelzow 2009-08-06 17:11:14 UTC
It is surprising how often map_linear_auto_bound is called when you open Emmanuel's sample file.

I see, we first make the bounds loose and then pull 0. (Jean if you are using a 64bit machine you may just not pull 0, on my 32 bit machine it is just in in range.)

before pulling zero to range is 
(gdb) p bound[GOG_AXIS_ELEM_MIN]
$11 = 1

to

(gdb) p bound[GOG_AXIS_ELEM_MAX]
$12 = 1.7000000000000002

with step 
(gdb) p step
$13 = 0.10000000000000001

Since 0 is within 10*step, if barely, it is pulled in.

Note that if we first had pulled 0 and then made it loose, we would have had a smaller range.

So clearly this is intended and I just stumbled onto an extreme situation.

Closing as NOTABUG.

Comment 9 Jean Bréfort 2009-08-06 17:15:56 UTC
I find a bit weird that a 32 bit machine and a 64 bit machine give different outputs. This might be considered a bug.
Comment 10 Andreas J. Guelzow 2009-08-06 17:31:52 UTC
It might be interesting to know what you get for 
step = pow (10, go_fake_floor (log10 (range)));
in map_linear_auto_bound in gog-axis.c
Comment 11 Jean Bréfort 2009-08-06 18:59:18 UTC
I'm getting 0.10000000000000001
Comment 12 Andreas J. Guelzow 2009-08-06 19:02:51 UTC
Interesting. If you trace through the next step, you shuold see why you are not pulling in 0. 
Comment 13 Morten Welinder 2009-08-06 20:33:28 UTC
32-bit mode will often use the old x87 instructions with extra precision.
64-bit mode uses, AFAIK, 64-bit instructions with no extra precision.

Hence I am not surprised that we see differences.

Even on the same chip, there are numbers for which log produces different
results in 32-bit and 64-bit mode.
Comment 14 Morten Welinder 2009-08-06 20:35:25 UTC
Maybe we should not use an integer like 10 for the pull-in-0 logic.
Doing so almost is asking for user-visible rounding issues.

How about 9.99?
Comment 15 Andreas J. Guelzow 2009-08-06 22:32:11 UTC
Tha seem like a good idea
Comment 16 Morten Welinder 2009-08-07 00:57:28 UTC
Fixed.
Comment 17 Jean Bréfort 2009-08-07 05:58:16 UTC
This might have broken the xls compatibility.
Comment 18 Jean Bréfort 2009-08-07 06:28:48 UTC
To maintai XL compatibility (if it is what we want, since I largely prefer starting the axis form 1. in such a case), I propose:

	if (bound[GOG_AXIS_ELEM_MIN] > 0 &&
	    (bound[GOG_AXIS_ELEM_MIN] - 10. * step) < DBL_EPSILON)
		bound[GOG_AXIS_ELEM_MIN] = 0;
	else if (bound[GOG_AXIS_ELEM_MAX] < 0 &&
	    (bound[GOG_AXIS_ELEM_MAX] + 10. * step) > -DBL_EPSILON)
		bound[GOG_AXIS_ELEM_MAX] = 0;
Comment 19 Andreas J. Guelzow 2009-08-07 07:25:42 UTC
Do we have any reason to believe that a factor of 10.00 is required for XL compatibility. I suspect that the value 10.00 was just used because it seems to give the right answer in a bunch of cases. 9.99 would likely give similar answers.
Comment 20 Jean Bréfort 2009-08-07 07:41:34 UTC
I made a test with Emmanuel's sample: XL does have an x-axis starting from 0. With 9.99, our axis starts from 1.
Comment 21 Andreas J. Guelzow 2009-08-07 07:55:46 UTC
Perhaps we should then just use 10.01 or something to that effect.
Comment 22 Jean Bréfort 2009-08-07 07:57:04 UTC
Or consider it is an XL bug and do not reproduce it.
Comment 23 Morten Welinder 2009-08-07 11:01:16 UTC
We do not have XL compatibility for axes.  For date axes, for example, I
recently made us choose sane dates for ticks instead of round number-of-
days-since-1900.