Changeset 1323


Ignore:
Timestamp:
Jan 16, 2011, 11:08:34 PM (10 years ago)
Author:
Peter Johansson
Message:

fixes #490

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/.release_year

    r1003 r1323  
    1 2010
     12011
  • trunk/lib/Graph.cc

    r1287 r1323  
    220220  unsigned int Graph::tick_spacing(const double range) const
    221221  {
    222     double frac=range/5;
    223     unsigned char characteristic= static_cast<unsigned char>(std::log10(frac));
    224     unsigned int power=static_cast<unsigned int>(std::pow(10.0, characteristic));
    225     unsigned char msn=static_cast<unsigned char>(frac/power);
    226     return power*msn;
     222    // range = msn * 10^characteristic = msn * power
     223    unsigned char characteristic= static_cast<unsigned char>(std::log10(range));
     224    double power = std::pow(10.0, characteristic);
     225    double msn = range/power;
     226    if (msn>=5.0)
     227      return power;
     228    if (msn>=2.0)
     229      return 0.5 * power;
     230    return 0.2 * power;
    227231  }
    228232
Note: See TracChangeset for help on using the changeset viewer.