Change the start date of gantt chart

Added by Alice Etchegaray almost 6 years ago

Hello,

Is anyone can tell me how to change the default start date of gantt chart ?
By default, the value is the current month, but I wish it was the start date of the project...

Thank in advance for your help,

Cheers,

Alice.

Replies (6)

RE: Change the start date of gantt chart - Added by Martin Denizet (redmine.org team member) almost 6 years ago

Hi Alice,
I think you would have to do a plugin.
It seems the date is set by retrieve_query in source:trunk/app/controllers/gantts_controller.rb
I don't have my IDE available right now so I'm not able to tell where is the definition of retrieve_query.
I guess you would have to wrap retrieve_query such as, if the date is not specified, you use the project's start date.
Make plugins rather than editing Redmine's code otherwise you won't be able to update to newer releases. Actually plugins can also break with updates but it's still far better.
Cheer,

RE: Change the start date of gantt chart - Added by Alice Etchegaray almost 6 years ago

I found the definition of retrieve_query, but I don't know if it's the method for the start date...

# Retrieve query from session or build a new query
def retrieve_query
if !params[:query_id].blank?
cond = "project_id IS NULL"
cond << " OR project_id = #{@project.id}" if @project
@query = IssueQuery.where(cond).find(params[:query_id])
raise ::Unauthorized unless @query.visible?
@query.project = @project
session[:query] = {:id => @query.id, :project_id => @query.project_id}
sort_clear
elsif api_request? || params[:set_filter] || session[:query].nil? || session[:query][:project_id] != (@project ? @project.id : nil) # Give it a name, required to be valid
@query = IssueQuery.new(:name => "_")
@query.project = @project
@query.build_from_params(params)
session[:query] = {:project_id => @query.project_id, :filters => @query.filters, :group_by => @query.group_by, :column_names => @query.column_names}
else # retrieve from session
@query = nil
@query = IssueQuery.find_by_id(session[:query][:id]) if session[:query][:id]
@query ||= IssueQuery.new(:name => "_", :filters => session[:query][:filters], :group_by => session[:query][:group_by], :column_names => session[:query][:column_names])
@query.project = @project
end
end

RE: Change the start date of gantt chart - Added by Alice Etchegaray almost 6 years ago

I have found the method for this (it's in lib\redmine\helpers\gantt.rb) :

@month_from ||= Project.start_date.month
@year_from ||= Date.today.year

But with this, I have this error :

NoMethodError (undefined method `start_date' for #<Class:0x2b6b0a8>):
lib/redmine/helpers/gantt.rb:59:in `initialize'
app/controllers/gantts_controller.rb:34:in `new'
app/controllers/gantts_controller.rb:34:in `show'

Can you help me please ?

RE: Change the start date of gantt chart - Added by Martin Denizet (redmine.org team member) almost 6 years ago

Is there a way I can see your entire code? Maybe you have it on Github?
Cheers,

RE: Change the start date of gantt chart - Added by Alice Etchegaray almost 6 years ago

Hi,

Finally, I didn't wrote the plugin.
I just tried to change @month_from ||= Date.today.month (in lib/redmine/helpers/gantt.rb) by project.start_date but it didn't work.
So, I give up..

RE: Change the start date of gantt chart - Added by Markus Boremski 6 months ago

Looking for a similar thing.
In Gantt-Diagramm I'd like to see minimum one month in the past to review open issues.
Anyone able to give a hint?

(1-6/6)