Logo Search packages:      
Sourcecode: ygraph version File versions  Download package

gint axis_calc_tick_sep ( Plot plot,
Axis axis,
guint  i 
)

Determine a measure of inter-tick spacing.

This function calculate the separation between the first and second tick marks as a measure of the inter-tick spacing. The result of this calculation is used to estimate whether any pair of labels along an axis will have their text write over one another. Seems to work well enough.

Parameters:
plot The Plot on which the axis is to be displayed.
axis The axis in question.
i The index of an tick, measured is the spacing between this and the next tick
Returns:
The estimate of tick spacing.

Definition at line 382 of file axis.c.

References _Plot::i_origin, _Plot::j_origin, _Axis::orientation, _Axis::ticks, X_AXIS, _Plot::x_range, x_to_i(), _Plot::y_range, and y_to_j().

Referenced by axis_draw_y_text().

{
  gdouble x0;
  gdouble x1;

  /* prevent values out of range */
  if (i >= axis->ticks->len-1)
    i = axis->ticks->len-2;

  if (axis->ticks->len > 1)
    {
      x0 = g_array_index(axis->ticks, Tick*, i  )->val;
      x1 = g_array_index(axis->ticks, Tick*, i+1)->val;
    }
  else
    {
      if (axis->orientation == X_AXIS)
        {
          x0 = plot->x_range[0];
          x1 = plot->x_range[1];
        }
      else
        {
          x0 = plot->y_range[0];
          x1 = plot->y_range[1];
        }
    }

  x0=axis_transformation(x0, axis);
  x1=axis_transformation(x1, axis);

  if (axis->orientation == X_AXIS)
    return (2*plot->i_origin + x_to_i(plot, x1) - x_to_i(plot, x0)) || 1 ;
  else
    return (2*plot->j_origin + y_to_j(plot, x0) - y_to_j(plot, x1)) || 1;
}


Generated by  Doxygen 1.6.0   Back to index