Beispiel #1
0
static void
gog_pie_series_update (GogObject *obj)
{
	double *vals = NULL, total;
	int len = 0;
	GogPieSeries *series = GOG_PIE_SERIES (obj);
	unsigned old_num = series->base.num_elements;
	GogShowNegsMode mode = GOG_PIE_PLOT (series->base.plot)->show_negatives;

	if (series->base.values[1].data != NULL) {
		vals = go_data_get_values (series->base.values[1].data);
		len = go_data_get_vector_size (series->base.values[1].data);
	}
	series->base.num_elements = len;

	for (total = 0. ; len-- > 0 ;) {
		double val = vals[len];
		if (go_finite (val)) {
			if (val < 0)
				val = (mode == GOG_SHOW_NEGS_SKIP)? 0.: -val;
			total += val;
		}
	}
	series->total = total;

	/* queue plot for redraw */
	gog_object_request_update (GOG_OBJECT (series->base.plot));
	if (old_num != series->base.num_elements)
		gog_plot_request_cardinality_update (series->base.plot);

	if (series_parent_klass->update)
		series_parent_klass->update (obj);
}
Beispiel #2
0
void
gog_chart_request_cardinality_update (GogChart *chart)
{
	g_return_if_fail (GOG_IS_CHART (chart));

	if (chart->cardinality_valid) {
		chart->cardinality_valid = FALSE;
		gog_object_request_update (GOG_OBJECT (chart));
	}
}
Beispiel #3
0
static void
color_scale_pre_remove (GogObject *parent, GogObject *scale)
{
	/* Unlink the color scale */
	GSList const *l = gog_axis_contributors (gog_color_scale_get_axis (GOG_COLOR_SCALE (scale)));
	gog_color_scale_set_axis (GOG_COLOR_SCALE (scale), NULL);
	for (; l; l = l->next)
		gog_object_request_update (GOG_OBJECT (l->data));
	gog_chart_request_cardinality_update (GOG_CHART (parent));
}
Beispiel #4
0
static void
gog_smoothed_curve_dataset_dim_changed (GogDataset *set, int dim_i)
{
	GogSmoothedCurveClass *klass = (GogSmoothedCurveClass *) G_OBJECT_GET_CLASS (set);
	g_return_if_fail (dim_i >= -1 && dim_i <= klass->max_dim);
	{
		GogSmoothedCurve const *sc = GOG_SMOOTHED_CURVE (set);
		if (dim_i == -1) {
			GOData *name_src = sc->name->data;
			char *name = (name_src != NULL)
				? go_data_get_scalar_string (name_src) : NULL;
			gog_object_set_name (GOG_OBJECT (set), name, NULL);
		} else
			gog_object_request_update (GOG_OBJECT (set));
	}
}
Beispiel #5
0
static void
gog_xy_dropbar_series_update (GogObject *obj)
{
	const double *x_vals, *y_vals, *z_vals;
	GogSeries *series = GOG_SERIES (obj);
	unsigned old_num = series->num_elements;

	series->num_elements = gog_series_get_xyz_data (series,
							&x_vals, &y_vals, &z_vals);
	/* queue plot for redraw */
	gog_object_request_update (GOG_OBJECT (series->plot));
	if (old_num != series->num_elements)
		gog_plot_request_cardinality_update (series->plot);

	if (series_parent_klass->update)
		series_parent_klass->update (obj);
}
Beispiel #6
0
static void
gog_pie_plot_set_property (GObject *obj, guint param_id,
			   GValue const *value, GParamSpec *pspec)
{
	GogPiePlot *pie = GOG_PIE_PLOT (obj);

	switch (param_id) {
	case PLOT_PROP_INITIAL_ANGLE: {
		double a = g_value_get_double (value);
		a = fmod (a, 360);
		if (a < 0) a += 360;
		pie->initial_angle = a;
		break;
	}
	case PLOT_PROP_DEFAULT_SEPARATION: {
		double f = g_value_get_double (value);
		pie->default_separation = CLAMP (f, 0., 5.);
		break;
	}
	case PLOT_PROP_IN_3D:
		pie->in_3d = g_value_get_boolean (value);
		break;
	case PLOT_PROP_SPAN:
		pie->span = g_value_get_double (value);
		break;
	case PLOT_PROP_SHOW_NEGS : {
		GSList *ptr = GOG_PLOT (obj)->series;
		pie->show_negatives = gog_show_neg_mode_from_str (g_value_get_string (value));
		/* we need to update all the series */
		while (ptr) {
			gog_object_request_update (GOG_OBJECT (ptr->data));
			ptr = ptr->next;
		}
		break;
	}

	default: G_OBJECT_WARN_INVALID_PROPERTY_ID (obj, param_id, pspec);
		 return; /* NOTE : RETURN */
	}

	/* none of the attributes triggers a size change yet.
	 * When we add data labels we'll need it */
	gog_object_emit_changed (GOG_OBJECT (obj), FALSE);
}
Beispiel #7
0
static void
color_scale_post_add (GogObject *parent, GogObject *child)
{
	/* Link the color scale to an axis without a preexisting color scale */
	GogChart *chart = GOG_CHART (parent);
	GSList *ptr;
	GogAxis *axis;
	GogAxisType type;
	GSList const *l;

	for (ptr = chart->axes; ptr && ptr->data; ptr = ptr->next) {
		axis = GOG_AXIS (ptr->data);
		type = gog_axis_get_atype (axis);
		if ((type == GOG_AXIS_COLOR || type == GOG_AXIS_PSEUDO_3D)
		    && gog_axis_get_color_scale (axis) == NULL) {
				gog_color_scale_set_axis (GOG_COLOR_SCALE (child), axis);
				for (l = gog_axis_contributors (axis); l; l = l->next)
					gog_object_request_update (GOG_OBJECT (l->data));
				break;
			}
	}
	gog_chart_request_cardinality_update (chart);
}