goffice r2355 - in trunk: . goffice/graph
- From: mortenw svn gnome org
- To: svn-commits-list gnome org
- Subject: goffice r2355 - in trunk: . goffice/graph
- Date: Sat, 28 Mar 2009 22:58:32 +0000 (UTC)
Author: mortenw
Date: Sat Mar 28 22:58:32 2009
New Revision: 2355
URL: http://svn.gnome.org/viewvc/goffice?rev=2355&view=rev
Log:
2009-03-28 Morten Welinder <terra gnome org>
* goffice/graph/gog-axis.c (map_linear_calc_ticks): Make sure
we get zero and not almost-zero when we need to.
Modified:
trunk/ChangeLog
trunk/goffice/graph/gog-axis.c
Modified: trunk/goffice/graph/gog-axis.c
==============================================================================
--- trunk/goffice/graph/gog-axis.c (original)
+++ trunk/goffice/graph/gog-axis.c Sat Mar 28 22:58:32 2009
@@ -667,6 +667,7 @@
int t, maj_i, maj_N, min_i, min_N, N;
double maj_step, min_step;
double range, ratio;
+ double zero_threshold;
if (!gog_axis_get_bounds (axis, &minimum, &maximum)) {
gog_axis_set_ticks (axis, 2, create_invalid_axis_ticks (0.0, 1.0));
@@ -686,6 +687,8 @@
min_N = (ratio >= G_MAXINT ? 1 : (int)ratio);
min_step = maj_step / min_N;
+ zero_threshold = maj_step * DBL_EPSILON;
+
/*
* We used to round minimum to nearest maj_step, but that is very
* wrong:
@@ -721,6 +724,8 @@
t = 0;
for (maj_i = 0; ; maj_i++) {
double maj_pos = minimum + maj_i * maj_step;
+ if (fabs (maj_pos) < maj_i * zero_threshold)
+ maj_pos = 0;
ticks[t].position = maj_pos;
ticks[t].type = GOG_AXIS_TICK_MAJOR;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]