[goffice] bar/col: fix log axis handling.
- From: Morten Welinder <mortenw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [goffice] bar/col: fix log axis handling.
- Date: Wed, 25 Mar 2015 00:22:36 +0000 (UTC)
commit 2f46c05e0123251967ef578df23832bdd00fcab9
Author: Morten Welinder <terra gnome org>
Date: Tue Mar 24 20:22:28 2015 -0400
bar/col: fix log axis handling.
ChangeLog | 11 ++++++++++-
NEWS | 1 +
goffice/graph/gog-axis.c | 21 ++++++++++++++++++++-
goffice/graph/gog-axis.h | 2 ++
plugins/plot_barcol/gog-1.5d.c | 32 ++++++++++++++++++--------------
5 files changed, 51 insertions(+), 16 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 485fa09..e50898b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-03-24 Morten Welinder <terra gnome org>
+
+ * plugins/plot_barcol/gog-1.5d.c (gog_plot1_5d_axis_get_bounds):
+ Use gog_axis_is_zero_important. Avoid underflow.
+ (gog_plot1_5d_update): Use gog_axis_data_get_bounds.
+
+ * goffice/graph/gog-axis.c (gog_axis_is_zero_important): New
+ function.
+
2015-03-20 Morten Welinder <terra gnome org>
* goffice/math/go-math.c (_go_math_init): generate positive nan.
@@ -5,7 +14,7 @@
2015-03-19 Jean Brefort <jean brefort normalesup org>
* goffice/graph/gog-axis-line.c (axis_line_point): fix selection of
- axes using only part fo the plot area. [#746456]
+ axes using only part of the plot area. [#746456]
2015-03-19 Morten Welinder <terra gnome org>
diff --git a/NEWS b/NEWS
index c0aa49c..d85cc6b 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,7 @@ Johannes Deutsch:
Morten:
* Improve log axis bounds.
* Fix format used for stacked percentage graphs.
+ * Don't force bar/col axis to include 0 for log axis.
--------------------------------------------------------------------------
goffice 0.10.21:
diff --git a/goffice/graph/gog-axis.c b/goffice/graph/gog-axis.c
index c24e3dc..f49e55a 100644
--- a/goffice/graph/gog-axis.c
+++ b/goffice/graph/gog-axis.c
@@ -873,7 +873,6 @@ map_linear_calc_ticks (GogAxis *axis)
}
range = maximum - minimum;
-
maj_step = gog_axis_get_entry (axis, GOG_AXIS_ELEM_MAJOR_TICK, NULL);
if (maj_step <= 0.) maj_step = range;
while (1) {
@@ -3883,6 +3882,26 @@ gog_axis_data_get_bounds (GogAxis *axis, GOData *data,
go_data_get_bounds (data, minimum, maximum);
}
+/*
+ * gog_axis_is_zero_important:
+ * @axis: the axis to check
+ *
+ * Returns %TRUE if the axis is of a type in which zero is important and
+ * preferentially should be included in the range.
+ *
+ * This generally means a linear axis, i.e., not a log axis and not a
+ * date formatted axis.
+ */
+gboolean
+gog_axis_is_zero_important (GogAxis *axis)
+{
+ GogAxisMapDesc const *desc = axis->actual_map_desc;
+
+ return !axis->is_discrete &&
+ desc->map_finite (0.0) &&
+ desc->auto_bound != map_date_auto_bound;
+}
+
/**
* gog_axis_get_grid_line:
* @axis: #GogAxis
diff --git a/goffice/graph/gog-axis.h b/goffice/graph/gog-axis.h
index 20752e2..b34fdaa 100644
--- a/goffice/graph/gog-axis.h
+++ b/goffice/graph/gog-axis.h
@@ -108,6 +108,8 @@ void gog_axis_bound_changed (GogAxis *axis, GogObject *contrib);
void gog_axis_data_get_bounds (GogAxis *axis, GOData *data, double *minimum, double *maximum);
+gboolean gog_axis_is_zero_important (GogAxis *axis);
+
GogGridLine *gog_axis_get_grid_line (GogAxis *axis, gboolean major);
void gog_axis_set_polar_unit (GogAxis *axis, GogAxisPolarUnit unit);
diff --git a/plugins/plot_barcol/gog-1.5d.c b/plugins/plot_barcol/gog-1.5d.c
index 2f0b716..b886eba 100644
--- a/plugins/plot_barcol/gog-1.5d.c
+++ b/plugins/plot_barcol/gog-1.5d.c
@@ -162,8 +162,9 @@ gog_plot1_5d_update (GogObject *obj)
GSList *ptr;
GOData *index_dim = NULL;
GogPlot *plot_that_labeled_axis;
- GogAxis *axis;
gboolean index_changed = FALSE;
+ GogAxis *iaxis = gog_plot1_5d_get_index_axis (model);
+ GogAxis *vaxis = gog_plot1_5d_get_value_axis (model);
old_minima = model->minima;
old_maxima = model->maxima;
@@ -191,7 +192,7 @@ gog_plot1_5d_update (GogObject *obj)
if (gog_error_bar_is_visible (series->errors))
gog_error_bar_get_minmax (series->errors, &minima, &maxima);
else
- go_data_get_bounds (series->base.values[1].data, &minima, &maxima);
+ gog_axis_data_get_bounds (vaxis, series->base.values[1].data, &minima,
&maxima);
if (series->base.plot->desc.series.num_dim == 3) {
double tmp_min, tmp_max;
go_data_get_bounds (series->base.values[2].data, &tmp_min, &tmp_max);
@@ -210,17 +211,17 @@ gog_plot1_5d_update (GogObject *obj)
model->date_conv = go_data_date_conv (series->base.values[1].data);
index_dim = series->base.values[0].data;
}
- axis = gog_plot1_5d_get_index_axis (model);
+
if (model->num_elements != num_elements ||
model->implicit_index ^ (index_dim == NULL) ||
- (index_dim != gog_axis_get_labels (axis, &plot_that_labeled_axis) &&
+ (index_dim != gog_axis_get_labels (iaxis, &plot_that_labeled_axis) &&
GOG_PLOT (model) == plot_that_labeled_axis)) {
model->num_elements = num_elements;
model->implicit_index = (index_dim == NULL);
- gog_axis_bound_changed (axis, GOG_OBJECT (model));
+ gog_axis_bound_changed (iaxis, GOG_OBJECT (model));
} else {
if (index_changed)
- gog_axis_bound_changed (axis, GOG_OBJECT (model));
+ gog_axis_bound_changed (iaxis, GOG_OBJECT (model));
}
model->num_series = num_series;
@@ -257,8 +258,7 @@ gog_plot1_5d_update (GogObject *obj)
}
if (old_minima != model->minima || old_maxima != model->maxima)
- gog_axis_bound_changed (
- gog_plot1_5d_get_value_axis (model), GOG_OBJECT (model));
+ gog_axis_bound_changed (vaxis, GOG_OBJECT (model));
gog_object_emit_changed (GOG_OBJECT (obj), FALSE);
if (plot1_5d_parent_klass->update)
@@ -266,11 +266,14 @@ gog_plot1_5d_update (GogObject *obj)
}
static GOData *
-gog_plot1_5d_axis_get_bounds (GogPlot *plot, GogAxisType axis,
+gog_plot1_5d_axis_get_bounds (GogPlot *plot, GogAxisType atype,
GogPlotBoundInfo *bounds)
{
GogPlot1_5d *model = GOG_PLOT1_5D (plot);
- if (axis == gog_axis_get_atype (gog_plot1_5d_get_value_axis (model))) {
+ GogAxis *iaxis = gog_plot1_5d_get_index_axis (model);
+ GogAxis *vaxis = gog_plot1_5d_get_value_axis (model);
+
+ if (atype == gog_axis_get_atype (vaxis)) {
bounds->val.minima = model->minima;
bounds->val.maxima = model->maxima;
if (model->type == GOG_1_5D_AS_PERCENTAGE) {
@@ -292,14 +295,15 @@ gog_plot1_5d_axis_get_bounds (GogPlot *plot, GogAxisType axis,
* value. See https://bugzilla.gnome.org/show_bug.cgi?id=663717.
* The check for num_dim is there because the requirement is less
* obvious for dropbars. */
- if (plot->desc.series.num_dim == 4 && bounds->val.minima * bounds->val.maxima > 0) {
- if (bounds->val.minima > 0)
+ if (gog_axis_is_zero_important (vaxis) &&
+ plot->desc.series.num_dim == 4) {
+ if (bounds->val.minima > 0 && bounds->val.maxima > 0)
bounds->val.minima = 0;
- else
+ else if (bounds->val.minima < 0 && bounds->val.maxima < 0)
bounds->val.maxima = 0.;
}
return NULL;
- } else if (axis == gog_axis_get_atype (gog_plot1_5d_get_index_axis (model))) {
+ } else if (atype == gog_axis_get_atype (iaxis)) {
GSList *ptr;
bounds->val.minima = 1.;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]