Skip to content

Commit

Permalink
I *think* I'm just committing a minor fix to remove the old-style cha…
Browse files Browse the repository at this point in the history
…rt, but I"m not sure :(
  • Loading branch information
Ciaran authored and Ciaran committed Feb 28, 2009
1 parent d201302 commit b3f169d
Show file tree
Hide file tree
Showing 9 changed files with 3,479 additions and 21 deletions.
17 changes: 2 additions & 15 deletions app/models/burndown_chart.rb
Original file line number Diff line number Diff line change
@@ -1,33 +1,20 @@
class BurndownChart
attr_accessor :dates, :version, :start_date

delegate :to_s, :to => :chart

def initialize(version)
self.version = version

self.start_date = version.created_on.to_date
end_date = version.effective_date.to_date
self.dates = (start_date..end_date).inject([]) { |accum, date| accum << date }
end

def chart
Gchart.line(
:size => '750x400',
:data => data,
:axis_with_labels => 'x,y',
:axis_labels => [dates.map {|d| d.strftime("%m-%d") }],
:custom => "chxr=1,0,#{sprint_data.max}",
:line_colors => "DDDDDD,FF0000"
)
@dates = (start_date..end_date).inject([]) { |accum, date| accum << date }
end

def data
[ideal_data, sprint_data]
end

def sprint_data
@sprint_data ||= dates.map do |date|
@sprint_data ||= @dates.map do |date|
issues = all_issues.select {|issue| issue.created_on.to_date <= date }
issues.inject(0) do |total_hours_left, issue|
done_ratio_details = issue.journals.map(&:details).flatten.select {|detail| 'done_ratio' == detail.prop_key }
Expand Down
49 changes: 48 additions & 1 deletion app/views/burndowns/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,53 @@
<h2><%= @version.name %> <%= l(:burndown) %></h2>

<p><%= image_tag(@chart.to_s) %></p>
<p><div id="placeholder" style="width:750px;height:400px"></div></p>
<script id="source" language="javascript" type="text/javascript">



jQuery(function () {
// helper for returning the weekends in a period
function weekendAreas(axes) {
var markings = [];
var d = new Date(axes.xaxis.min);
// go to the first Saturday
d.setUTCDate(d.getUTCDate() - ((d.getUTCDay() + 1) % 7))
d.setUTCSeconds(0);
d.setUTCMinutes(0);
d.setUTCHours(0);
var i = d.getTime();
do {
// when we don't set yaxis the rectangle automatically
// extends to infinity upwards and downwards
markings.push({ xaxis: { from: i, to: i + 2 * 24 * 60 * 60 * 1000 } });
i += 7 * 24 * 60 * 60 * 1000;
} while (i < axes.xaxis.max);

return markings;
}
var data= [];
var remaining_work = [<%=@chart.sprint_data.join(',')%>];
var dates = [<%=@chart.dates.map {|d| d.to_time.to_i*1000 }.join(',')%>];
for( var i=0;i< dates.length;i++) {
data.push([dates[i], remaining_work[i]])
}

var ideal_data=[[dates[0],<%=@chart.ideal_data[0]%>],[dates[dates.length-1],<%=@chart.ideal_data[1]%>]];
jQuery.plot(jQuery("#placeholder"), [{
label:"Est. Remaining Time",
data: data
}, {
label:"Ideal Burn-down",
data:ideal_data
}]
, { xaxis: { mode: "time" },
lines: { show: true },
points: { show: true },
grid: { markings: weekendAreas }
}
);
});
</script>

<% content_for :sidebar do -%>
<h3><%= l(:label_version_plural) %></h3>
Expand Down
3 changes: 3 additions & 0 deletions assets/javascripts/burndowns.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<script language='JavaScript' type='text/javascript'>
jQuery.noConflict();
</script>
1 change: 1 addition & 0 deletions assets/javascripts/excanvas.pack.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions assets/javascripts/jquery.flot.pack.js

Large diffs are not rendered by default.

Loading

0 comments on commit b3f169d

Please sign in to comment.