OpenProject is the leading open source project management software.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
openproject/app/helpers/burndown_charts_helper.rb

34 lines
1.3 KiB

module BurndownChartsHelper
def yaxis_labels(burndown)
max = [burndown.max[:hours], burndown.max[:points]].max
mvalue = (max / 25) + 1
labels = (0..mvalue).collect{ |i| "[#{i*25}, #{i*25}]"}
mvalue = mvalue + 1 if mvalue == 1 || ((max % 25) == 0)
labels << "[#{(mvalue) * 25}, '<span class=\"axislabel\">#{l('backlogs.hours')}/<br>#{l('backlogs.points')}</span>']"
result = labels.join(', ')
result.html_safe
end
def xaxis_labels(burndown)
burndown.days.enum_for(:each_with_index).collect{|d,i| "[#{i+1}, '#{escape_javascript(::I18n.t('date.abbr_day_names')[d.wday % 7])}']"}.join(',').html_safe +
", [#{burndown.days.length + 1}, '<span class=\"axislabel\">#{I18n.t('backlogs.date')}</span>']".html_safe
end
def dataseries(burndown)
burndown.series.collect{|s| "#{s.first.to_s}: {label: '#{l('backlogs.' + s.first.to_s)}', data: [#{s.last.enum_for(:each_with_index).collect{|s, i| "[#{i+1}, #{s}] "}.join(', ')}]} "}.join(', ').html_safe
end
def burndown_series_checkboxes(burndown)
boxes = ""
burndown.series(:all).collect{|s| s.first.to_s }.sort.each do |series|
boxes += "<input class=\"series_enabled\" type=\"checkbox\" id=\"#{series}\" name=\"#{series}\" value=\"#{series}\" checked>#{l('backlogs.' + series.to_s)}<br/>"
end
boxes.html_safe
end
end