diff --git a/app/views/gantts/show.html.erb b/app/views/gantts/show.html.erb
--- a/app/views/gantts/show.html.erb
+++ b/app/views/gantts/show.html.erb
@@ -1,6 +1,10 @@
 <% @gantt.view = self %>
 <h2><%= @query.new_record? ? l(:label_gantt) : h(@query.name) %></h2>
 
+<% if @query.valid? %>
+  <%- @gantt.setup_dates %>
+<% end %>
+
 <%= form_tag({:controller => 'gantts', :action => 'show',
              :project_id => @project, :month => params[:month],
              :year => params[:year], :months => params[:months]},
diff --git a/lib/redmine/helpers/gantt.rb b/lib/redmine/helpers/gantt.rb
index 04a9c1f..28a8b30 100644
--- a/lib/redmine/helpers/gantt.rb
+++ b/lib/redmine/helpers/gantt.rb
@@ -42,27 +42,42 @@ module Redmine
 
       def initialize(options={})
         options = options.dup
-        if options[:year] && options[:year].to_i >0
+
+        if options[:year] && options[:year].to_i > 0
           @year_from = options[:year].to_i
-          if options[:month] && options[:month].to_i >=1 && options[:month].to_i <= 12
+          if options[:month] && options[:month].to_i >= 1 && options[:month].to_i <= 12
             @month_from = options[:month].to_i
           else
             @month_from = 1
           end
         else
-          @month_from ||= Date.today.month
+          @month_from ||= Date.today.month - 1
           @year_from ||= Date.today.year
+          @calculate_date_range = true
+        end
+
+        if @month_from <= 0
+          @month_from = 12
+          @year_from -= 1
+        end
+        if @month_from > 12
+          @month_from = 1
+          @year_from += 1
         end
+        
+        months = (options[:months] || User.current.pref[:gantt_months]).to_i
+        @months = (months > 0 && months < 48) ? months : 48
+        
         zoom = (options[:zoom] || User.current.pref[:gantt_zoom]).to_i
         @zoom = (zoom > 0 && zoom < 5) ? zoom : 2
-        months = (options[:months] || User.current.pref[:gantt_months]).to_i
-        @months = (months > 0 && months < 25) ? months : 6
+
         # Save gantt parameters as user preference (zoom and months count)
         if (User.current.logged? && (@zoom != User.current.pref[:gantt_zoom] ||
               @months != User.current.pref[:gantt_months]))
           User.current.pref[:gantt_zoom], User.current.pref[:gantt_months] = @zoom, @months
           User.current.preference.save
         end
+
         @date_from = Date.civil(@year_from, @month_from, 1)
         @date_to = (@date_from >> @months) - 1
         @subjects = ''
@@ -70,6 +85,7 @@ module Redmine
         @number_of_rows = nil
         @issue_ancestors = []
         @truncated = false
+
         if options.has_key?(:max_rows)
           @max_rows = options[:max_rows]
         else
@@ -77,6 +93,27 @@ module Redmine
         end
       end
 
+      def setup_dates
+        if @calculate_date_range
+          dates = issues_date_range
+
+          @date_from = dates[0]
+          if @date_from.day < 10
+            @date_from = dates[0] << 1
+          end
+          @date_to = dates[1]
+          if @date_to.day > 20
+            @date_to = dates[1] >> 1
+          end
+          @year_from = @date_from.year
+          @month_from = @date_from.month
+          months = (@date_to.year*12+@date_to.month) - (@date_from.year*12+@date_from.month) + 1
+          @months = months > 48 ? 48 : months
+          @date_from = Date.civil(@year_from, @month_from, 1)
+          @date_to = (@date_from >> @months) - 1
+        end
+      end
+
       def common_params
         { :controller => 'gantts', :action => 'show', :project_id => @project }
       end
@@ -674,6 +711,36 @@ module Redmine
           @truncated = true
         end
       end
+      
+      def issues_date_range
+        min = nil
+        max = nil
+        projects.each do |p|
+          all_issues = project_issues(p)
+
+          all_issues.each do |i|
+            if min == nil || (i.start_date != nil && min > i.start_date)
+              min = i.start_date
+            end
+            if min == nil || (i.due_before != nil && min > i.due_before)
+              min = i.due_before
+            end
+            if max == nil || (i.start_date != nil && max < i.start_date)
+              max = i.start_date
+            end
+            if max == nil || (i.due_before != nil && max < i.due_before)
+              max = i.due_before
+            end
+          end
+        end
+
+        if min == nil && max == nil
+          min = Date.today
+          max = Date.today
+        end
+
+        [min, max]
+      end
 
       def pdf_new_page?(options)
         if options[:top] > 180