Adding issue status flow graph
This commit is contained in:
parent
33d61cc17c
commit
c450774bee
|
@ -10,6 +10,23 @@ class GraphsController < ApplicationController
|
|||
|
||||
helper IssuesHelper
|
||||
|
||||
def issue_status_flow
|
||||
# Get the top visible projects by issue count
|
||||
sql = " select is1.id as old_status, is2.id as new_status, count(*) as changes_count"
|
||||
sql << " from journals as j"
|
||||
sql << " left join journal_details as jd on j.id = jd.journal_id"
|
||||
sql << " left join issue_statuses as is1 on jd.old_value = is1.id"
|
||||
sql << " left join issue_statuses as is2 on jd.value = is2.id"
|
||||
sql << " where journalized_type = 'issue' and prop_key = 'status_id' and DATE_SUB(CURRENT_TIMESTAMP, INTERVAL 10 DAY) <= created_on"
|
||||
sql << " group by old_value, value"
|
||||
sql << " order by is1.position, is2.position"
|
||||
@status_changes = ActiveRecord::Base.connection.select_all(sql)
|
||||
@issue_statuses = IssueStatus.find(:all).sort { |a,b| a.position<=>b.position }
|
||||
|
||||
headers["Content-Type"] = "image/svg+xml"
|
||||
render :layout => false
|
||||
end
|
||||
|
||||
def issue_growth
|
||||
end
|
||||
|
||||
|
|
37
app/views/graphs/issue_status_flow.html.erb
Normal file
37
app/views/graphs/issue_status_flow.html.erb
Normal file
|
@ -0,0 +1,37 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
|
||||
<%
|
||||
issue_statuses_by_id = @issue_statuses.index_by { |issue_status| issue_status.id }
|
||||
|
||||
points = Hash.new
|
||||
i = -1
|
||||
@issue_statuses.each do |issue_status|
|
||||
points[issue_status.id] = {"x" => Math.sin(2*Math::PI*i/@issue_statuses.size)*100 + 150, "y" => Math.cos(2*Math::PI*i/@issue_statuses.size)*100 + 150}
|
||||
i -= 1
|
||||
end
|
||||
%>
|
||||
|
||||
<svg xmlns="http://www.w3.org/2000/svg" version="1.0" width="400" height="744">
|
||||
<g stroke="black" stroke-width="10">
|
||||
<% @status_changes.each do |status_change| %>
|
||||
<line
|
||||
y2="<%= points[status_change["old_status"].to_i]["y"] %>"
|
||||
x2="<%= points[status_change["old_status"].to_i]["x"] %>"
|
||||
y1="<%= points[status_change["new_status"].to_i]["y"] %>"
|
||||
x1="<%= points[status_change["new_status"].to_i]["x"] %>"
|
||||
stroke-width="<%= status_change["changes_count"].to_i %>"
|
||||
/>
|
||||
<% end %>
|
||||
</g>
|
||||
<g fill="white" stroke="black" stroke-width="3.5">
|
||||
<% points.each do |status_id, point| %>
|
||||
<circle cx="<%= point["x"] %>" cy="<%= point["y"] %>" r="40" />
|
||||
<% end %>
|
||||
</g>
|
||||
<g font-family="Arial" font-size="13" font-weight="700" text-anchor="middle">
|
||||
<% points.each do |status_id, point| %>
|
||||
<text x="<%= point["x"] %>" y="<%= point["y"] %>"><%= issue_statuses_by_id[status_id] %></text>
|
||||
<% end %>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 1.5 KiB |
7
assets/stylesheets/issue_status_flow.css
Executable file
7
assets/stylesheets/issue_status_flow.css
Executable file
|
@ -0,0 +1,7 @@
|
|||
.line1 { stroke: #666666 !important; } .fill1 { fill: #666666 !important; } .key1 { fill: #666666 !important; }
|
||||
.line2 { stroke: #507AAA !important; } .fill2 { fill: #BACCE0 !important; } .key2 { fill: #507AAA !important; }
|
||||
|
||||
.fill1, .fill2 { fill-opacity: 0.6 !important; }
|
||||
.line1, .line2 { stroke-width: 2px !important; }
|
||||
|
||||
.guideLines { stroke-opacity: 0.2 !important; }
|
Loading…
Reference in New Issue
Block a user