def ticks(m=nil) # :args: (number_of_ticks=nil)
      start = @d.first
      _end = @d.last
      return [start] if start==_end
      reverse = _end < start
      min = reverse ? _end : start
      max = reverse ? start : _end
      span = max - min
      # Special case: empty, invalid or infinite span.
      if (!span or (span.is_a? Float and span.infinite?)) 
        @tick_format= Rubyvis.Format.date("%x") if (@type == newDate) 
        return [type(min)];
      end
      
      #/* Special case: dates. */
      if (@type == :time) 
      #/* Floor the date d given the precision p. */
      precision, format, increment, step = 1,1,1,1
      if (span >= 3 * 31536e6 / 1000.0) 
        precision = 31536e6
        format = "%Y"
        increment = lambda {|d|  Time.at(d.to_f+(step*365*24*60*60)) }
      elsif (span >= 3 * 2592e6 / 1000.0) 
        precision = 2592e6;
        format = "%m/%Y";
        increment = lambda {|d| Time.at(d.to_f+(step*30*24*60*60)) }
      elsif (span >= 3 * 6048e5 / 1000.0) 
        precision = 6048e5;
        format = "%m/%d";
        increment = lambda {|d| Time.at(d.to_f+(step*7*24*60*60)) }
      elsif (span >= 3 * 864e5 / 1000.0) 
        precision = 864e5;
        format = "%m/%d";
        increment = lambda {|d| Time.at(d.to_f+(step*24*60*60)) }
      elsif (span >= 3 * 36e5 / 1000.0) 
        precision = 36e5;
        format = "%I:%M %p";
        increment = lambda {|d| Time.at(d.to_f+(step*60*60)) }
      elsif (span >= 3 * 6e4 / 1000.0 ) 
        precision = 6e4;
        format = "%I:%M %p";
        increment = lambda {|d| Time.at(d.to_f+(step*60)) }
      elsif (span >= 3 * 1e3 / 1000.0) 
        precision = 1e3;
        format = "%I:%M:%S";
        increment = lambda {|d|  Time.at(d.to_f+(step)) }
      else 
        precision = 1;
        format = "%S.%Qs";
        increment = lambda {|d|  Time.at(d.to_f+(step/1000.0)) }
      end
      @tick_format = Rubyvis.Format.date(format);
      date = Time.at(min.to_f)
      dates = []
      date = ticks_floor(date,precision)
      # If we'd generate too many ticks, skip some!.
      n = span / (precision/1000.0)
      # FIX FROM HERE
      if (n > 10) 
        case (precision) 
        when 36e5
          step = (n > 20) ? 6 : 3;
          date.setHours(Math.floor(date.getHours() / step) * step);
        when 2592e6
          step = 3; # seasons
          ar=date.to_a
          ar[4]=(date.month/step.to_f).floor*step
          date=to_date(ar)
        when 6e4
          step = (n > 30) ? 15 : ((n > 15) ? 10 : 5);
          date.setMinutes(Math.floor(date.getMinutes() / step) * step);
        when 1e3
          step = (n > 90) ? 15 : ((n > 60) ? 10 : 5);
          date.setSeconds(Math.floor(date.getSeconds() / step) * step);
        when 1
          step = (n > 1000) ? 250 : ((n > 200) ? 100 : ((n > 100) ? 50 : ((n > 50) ? 25 : 5)));
          date.setMilliseconds(Math.floor(date.getMilliseconds() / step) * step);
        else
          step = Rubyvis.log_ceil(n / 15, 10);
          if (n / step < 2) 
            step =step.quo(5)
          elsif (n / step < 5)
            step = step.quo(2)
          end
          date.setFullYear((date.getFullYear().quo(step)).floor * step);
        end
      end
      # END FIX
        while (true)
          date=increment.call(date)
          break if (date.to_f > max.to_f)
          dates.push(date)
        end
        return reverse ? dates.reverse() : dates;
      end
      
      # Normal case: numbers. 
      m||= 10
      
      step = Rubyvis.log_floor(span.quo(m), 10)
      err = m.quo(span.quo(step))
      if (err <= 0.15)
        step = step*10
      elsif (err <= 0.35)
        step = step*5
      elsif (err <= 0.75)
        step = step*2
      end
      start = (min.quo(step)).ceil * step
      _end = (max.quo(step)).floor * step
      
      @tick_format= Rubyvis.Format.number.fraction_digits([0, -(Rubyvis.log(step, 10) + 0.01).floor].max).to_proc
      
      ticks = Rubyvis.range(start, _end + step, step)
      
      return reverse ? ticks.reverse() : ticks;
    end
def ticks(m=nil) # :args: (number_of_ticks=nil)
      start = @d.first
      _end = @d.last
      return [start] if start==_end
      reverse = _end < start
      min = reverse ? _end : start
      max = reverse ? start : _end
      span = max - min
      # Special case: empty, invalid or infinite span.
      if (!span or (span.is_a? Float and span.infinite?)) 
        @tick_format= Rubyvis.Format.date("%x") if (@type == newDate) 
        return [type(min)];
      end
      
      #/* Special case: dates. */
      if (@type == :time) 
      #/* Floor the date d given the precision p. */
      precision, format, increment, step = 1,1,1,1
      if (span >= 3 * 31536e6 / 1000.0) 
        precision = 31536e6
        format = "%Y"
        increment = lambda {|d|  Time.at(d.to_f+(step*365*24*60*60)) }
      elsif (span >= 3 * 2592e6 / 1000.0) 
        precision = 2592e6;
        format = "%m/%Y";
        increment = lambda {|d| Time.at(d.to_f+(step*30*24*60*60)) }
      elsif (span >= 3 * 6048e5 / 1000.0) 
        precision = 6048e5;
        format = "%m/%d";
        increment = lambda {|d| Time.at(d.to_f+(step*7*24*60*60)) }
      elsif (span >= 3 * 864e5 / 1000.0) 
        precision = 864e5;
        format = "%m/%d";
        increment = lambda {|d| Time.at(d.to_f+(step*24*60*60)) }
      elsif (span >= 3 * 36e5 / 1000.0) 
        precision = 36e5;
        format = "%I:%M %p";
        increment = lambda {|d| Time.at(d.to_f+(step*60*60)) }
      elsif (span >= 3 * 6e4 / 1000.0 ) 
        precision = 6e4;
        format = "%I:%M %p";
        increment = lambda {|d| Time.at(d.to_f+(step*60)) }
      elsif (span >= 3 * 1e3 / 1000.0) 
        precision = 1e3;
        format = "%I:%M:%S";
        increment = lambda {|d|  Time.at(d.to_f+(step)) }
      else 
        precision = 1;
        format = "%S.%Qs";
        increment = lambda {|d|  Time.at(d.to_f+(step/1000.0)) }
      end
      @tick_format = Rubyvis.Format.date(format);
      date = Time.at(min.to_f)
      dates = []
      date = ticks_floor(date,precision)
      # If we'd generate too many ticks, skip some!.
      n = span / (precision/1000.0)
      # FIX FROM HERE
      if (n > 10) 
        case (precision) 
        when 36e5
          step = (n > 20) ? 6 : 3;
          date.setHours(Math.floor(date.getHours() / step) * step);
        when 2592e6
          step = 3; # seasons
          ar=date.to_a
          ar[4]=(date.month/step.to_f).floor*step
          date=to_date(ar)
        when 6e4
          step = (n > 30) ? 15 : ((n > 15) ? 10 : 5);
          date.setMinutes(Math.floor(date.getMinutes() / step) * step);
        when 1e3
          step = (n > 90) ? 15 : ((n > 60) ? 10 : 5);
          date.setSeconds(Math.floor(date.getSeconds() / step) * step);
        when 1
          step = (n > 1000) ? 250 : ((n > 200) ? 100 : ((n > 100) ? 50 : ((n > 50) ? 25 : 5)));
          date.setMilliseconds(Math.floor(date.getMilliseconds() / step) * step);
        else
          step = Rubyvis.log_ceil(n / 15, 10);
          if (n / step < 2) 
            step =step.quo(5)
          elsif (n / step < 5)
            step = step.quo(2)
          end
          date.setFullYear((date.getFullYear().quo(step)).floor * step);
        end
      end
      # END FIX
        while (true)
          date=increment.call(date)
          break if (date.to_f > max.to_f)
          dates.push(date)
        end
        return reverse ? dates.reverse() : dates;
      end
      
      # Normal case: numbers. 
      m||= 10
      
      step = Rubyvis.log_floor(span.quo(m), 10)
      err = m.quo(span.quo(step))
      if (err <= 0.15)
        step = step*10
      elsif (err <= 0.35)
        step = step*5
      elsif (err <= 0.75)
        step = step*2
      end
      start = (min.quo(step)).ceil * step
      _end = (max.quo(step)).floor * step
      
      @tick_format= Rubyvis.Format.number.fraction_digits([0, -(Rubyvis.log(step, 10) + 0.01).floor].max).to_proc
      
      ticks = Rubyvis.range(start, _end + step, step)
      
      return reverse ? ticks.reverse() : ticks;
    end
Returns an array of evenly-spaced, suitably-rounded values in the input
 domain. This method attempts to return between 5 and 10 tick values. These
 values are frequently used in conjunction with Rule to display
 tick marks or grid lines.

 If start and end of domain are the same, returns only one tick value
 @todo: fix for dates and n>10