? depcomp ? ylwrap ? src/cut-n-paste-code/goffice/graph/.gog-style.c.swp ? src/cut-n-paste-code/goffice/graph/gog-marker-prefs.glade ? src/cut-n-paste-code/goffice/graph/gog-marker.c ? src/cut-n-paste-code/goffice/graph/gog-marker.h Index: src/cut-n-paste-code/goffice/ChangeLog =================================================================== RCS file: /cvs/gnome/gnumeric/src/cut-n-paste-code/goffice/ChangeLog,v retrieving revision 1.131 diff -u -r1.131 ChangeLog --- src/cut-n-paste-code/goffice/ChangeLog 5 Oct 2003 19:58:25 -0000 1.131 +++ src/cut-n-paste-code/goffice/ChangeLog 6 Oct 2003 09:09:03 -0000 @@ -1,3 +1,12 @@ + 2003-10-05 Emmanuel Pacaud + + * graph/gog-axis.c (gog_axis_update) : handle -1.0 .. 1.0 better. + Use user maximum and minimum if set when computing tick spacing. + Do not pull to 0, this behaviour can be forced by user by setting + manually minimum or maximum. + (gog_axis_num_markers) : fix rounding issue with direct cast from + double to int. + 2003-10-05 Jon K Hellan * utils/go-pattern.c (go_pattern_selector): gtk_combo_box renamed Index: src/cut-n-paste-code/goffice/graph/gog-axis.c =================================================================== RCS file: /cvs/gnome/gnumeric/src/cut-n-paste-code/goffice/graph/gog-axis.c,v retrieving revision 1.39 diff -u -r1.39 gog-axis.c --- src/cut-n-paste-code/goffice/graph/gog-axis.c 5 Oct 2003 02:15:00 -0000 1.39 +++ src/cut-n-paste-code/goffice/graph/gog-axis.c 6 Oct 2003 09:09:04 -0000 @@ -289,18 +289,26 @@ (parent_klass->finalize) (obj); } +/* maximum major tick number between maximum and minimum*/ +#define MAXIMUM_TICKS (double)7 + +static double axis_get_entry (GogAxis const *axis, unsigned i); + static void gog_axis_update (GogObject *obj) { GSList *ptr; GogAxis *axis = GOG_AXIS (obj); int expon; - double range, step, mant; + int minor_tick_number; + double range, step, mant, multiplier; double minima, maxima, logical_min, logical_max; double old_min = axis->auto_bound [AXIS_ELEM_MIN]; double old_max = axis->auto_bound [AXIS_ELEM_MAX]; GOData *labels; gboolean is_discrete; + double tmp; + GOData *data; gog_debug (0, g_warning ("axis::update");); @@ -341,6 +349,20 @@ minima = axis->min_val; maxima = axis->max_val; + + data = gog_dataset_get_dim (GOG_DATASET (axis), AXIS_ELEM_MIN); + if ((data != NULL) && IS_GO_DATA_SCALAR (data)) { + tmp = go_data_scalar_get_value (GO_DATA_SCALAR (data)); + if (finite (tmp)) + minima = tmp; + } + data = gog_dataset_get_dim (GOG_DATASET (axis),AXIS_ELEM_MAX); + if ((data != NULL) && IS_GO_DATA_SCALAR (data)) { + tmp = go_data_scalar_get_value (GO_DATA_SCALAR (data)); + if (finite (tmp)) + maxima = tmp; + } + if (minima < maxima) { range = fabs (maxima - minima); if (gnumeric_sub_epsilon (range) < 0.) { @@ -348,14 +370,25 @@ maxima *= 1.1; range = fabs (maxima - minima); } - step = pow (10, gnumeric_fake_trunc (log10 (range))); - if (range/step < 1.5) - step /= 5.; /* .2 .4 .6 */ - else if (range/step < 3) - step /= 2.; /* 0 5 10 */ - else if (range/step > 8) - step *= 2.; /* 2 4 6 */ + + step = range / MAXIMUM_TICKS; + multiplier = step / pow (10, floor ( log10 (step))); + + if (multiplier <= 2.0) { + multiplier = 2.0; + minor_tick_number=10; + } + else if (multiplier <= 5.0) { + multiplier = 5.0; + minor_tick_number=5; + } + else { + multiplier = 10.0; + minor_tick_number=10; + } + step = multiplier * pow (10, floor ( log10 (step))); + /* we want the bounds to be loose so jump up a step if we get too close */ mant = frexpgnum (minima/step, &expon); axis->auto_bound [AXIS_ELEM_MIN] = step * @@ -364,15 +397,7 @@ axis->auto_bound [AXIS_ELEM_MAX] = step * ceil (ldexpgnum (mant + GNUM_EPSILON, expon)); axis->auto_bound [AXIS_ELEM_MAJOR_TICK] = step; - axis->auto_bound [AXIS_ELEM_MINOR_TICK] = step / 5.; - - /* pull to zero if its nearby (do not pull both directions to 0) */ - if (axis->auto_bound [AXIS_ELEM_MIN] > 0 && - (axis->auto_bound [AXIS_ELEM_MIN] - 10. * step) < 0) - axis->auto_bound [AXIS_ELEM_MIN] = 0; - else if (axis->auto_bound [AXIS_ELEM_MAX] < 0 && - (axis->auto_bound [AXIS_ELEM_MAX] + 10. * step) < 0) - axis->auto_bound [AXIS_ELEM_MAX] = 0; + axis->auto_bound [AXIS_ELEM_MINOR_TICK] = step / (double)minor_tick_number; if (finite (axis->logical_min_val) && axis->auto_bound [AXIS_ELEM_MIN] < axis->logical_min_val) @@ -846,7 +871,7 @@ if (major_tick <= 0. || !gog_axis_get_bounds (axis, &minima, &maxima)) return 0; - return 1 + fabs (maxima - minima) / major_tick; + return floor (fabs (maxima - minima) / major_tick + 1.5); } }