Class: CycletimeScatterplot
Constant Summary
Constants inherited
from ChartBase
ChartBase::LABEL_POSITIONS
Instance Attribute Summary collapse
Attributes inherited from ChartBase
#aggregated_project, #all_boards, #atlassian_document_format, #board_id, #canvas_height, #canvas_width, #data_quality, #date_range, #file_system, #holiday_dates, #issues, #settings, #time_range, #timezone_offset, #x_axis_title, #y_axis_title
Instance Method Summary
collapse
#group_issues, #grouping_rules, #init_configuration_block
Methods inherited from ChartBase
#aggregated_project?, #before_run, #call_before_run, #canvas, #canvas_responsive?, #chart_format, #collapsible_issues_panel, #color_block, #color_for, #completed_issues_in_range, #current_board, #cycletime, #cycletime_for_issue, #daily_chart_dataset, #date_annotation, #describe_non_working_days, #description_text, #format_integer, #format_status, #header_text, #holidays, #html_directory, #icon_span, #label_days, #label_hours, #label_issues, #link_to_issue, #next_id, #normalize_annotation_datetime, #random_color, #render, #render_axis_title, #render_top_text, #seam_end, #seam_start, #stagger_label_positions, #status_category_color, #working_days_annotation, #wrap_and_render
Constructor Details
Returns a new instance of CycletimeScatterplot.
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 10
def initialize block
super()
'Cycletime Scatterplot'
description_text <<-HTML
<div class="p">
This chart shows only completed work and indicates both what day it completed as well as
how many days it took to get done. Hovering over a dot will show you the ID of the work item.
</div>
<div class="p">
The #{color_block '--cycletime-scatterplot-overall-trendline-color'} line indicates the 85th
percentile (<%= overall_percent_line %> days). 85% of all
items on this chart fall on or below the line and the remaining 15% are above the line. 85%
is a reasonable proxy for "most" so that we can say that based on this data set, we can
predict that most work of this type will complete in <%= overall_percent_line %> days or
less. The other lines reflect the 85% line for that respective type of work.
</div>
#{describe_non_working_days}
HTML
@x_axis_title = 'Date completed'
@y_axis_title = 'Cycletime in days'
init_configuration_block block do
grouping_rules do |issue, rule|
rule.label = issue.type
rule.color = color_for type: issue.type
end
end
@percentage_lines = []
@highest_y_value = 0
end
|
Instance Attribute Details
#possible_statuses ⇒ Object
Returns the value of attribute possible_statuses.
8
9
10
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 8
def possible_statuses
@possible_statuses
end
|
Instance Method Details
#all_items ⇒ Object
43
44
45
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 43
def all_items
completed_issues_in_range include_unstarted: false
end
|
#calculate_percent_line(items) ⇒ Object
143
144
145
146
147
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 143
def calculate_percent_line items
times = items.collect { |item| y_value(item) }
index = times.size * 85 / 100
times.sort[index]
end
|
#create_datasets(items) ⇒ Object
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 74
def create_datasets items
data_sets = []
group_issues(items).each do |rules, completed_items_by_type|
label = rules.label
color = rules.color
percent_line = calculate_percent_line completed_items_by_type
data = completed_items_by_type.filter_map { |issue| data_for_issue(issue) }
data_sets << {
label: "#{label} (85% at #{label_days(percent_line)})",
data: data,
fill: false,
showLine: false,
backgroundColor: color
}
data_sets << trend_line_data_set(label: label, data: data, color: color)
@percentage_lines << [percent_line, color]
end
data_sets
end
|
#data_for_issue(item) ⇒ Object
130
131
132
133
134
135
136
137
138
139
140
141
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 130
def data_for_issue item
cycle_time = y_value(item)
return nil if cycle_time < 1
@highest_y_value = cycle_time if @highest_y_value < cycle_time
{
y: cycle_time,
x: chart_format(x_value(item)),
title: [title_value(item)]
}
end
|
#run ⇒ Object
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 63
def run
items = all_items
data_sets = create_datasets items
overall_percent_line = calculate_percent_line(items)
@percentage_lines << [overall_percent_line, CssVariable['--cycletime-scatterplot-overall-trendline-color']]
return "<h1>#{@header_text}</h1>No data matched the selected criteria. Nothing to show." if data_sets.empty?
wrap_and_render(binding, __FILE__)
end
|
#show_trend_lines ⇒ Object
97
98
99
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 97
def show_trend_lines
@show_trend_lines = true
end
|
#title_value(item) ⇒ Object
55
56
57
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 55
def title_value item
"#{item.key} : #{item.summary} (#{label_days(y_value(item))})"
end
|
#trend_line_data_set(label:, data:, color:) ⇒ Object
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 101
def trend_line_data_set label:, data:, color:
points = data.collect do |hash|
[Time.parse(hash[:x]).to_i, hash[:y]]
end
calculator = TrendLineCalculator.new(points)
data_points = calculator.chart_datapoints(
range: time_range.begin.to_i..time_range.end.to_i,
max_y: @highest_y_value
)
data_points.each do |point_hash|
point_hash[:x] = chart_format Time.at(point_hash[:x])
end
{
type: 'line',
label: "#{label} Trendline",
data: data_points,
fill: false,
borderWidth: 1,
markerType: 'none',
borderColor: color,
borderDash: [6, 3],
pointStyle: 'dash',
hidden: !@show_trend_lines
}
end
|
#x_value(item) ⇒ Object
47
48
49
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 47
def x_value item
item.board.cycletime.started_stopped_times(item).last
end
|
#y_axis_heading ⇒ Object
59
60
61
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 59
def y_axis_heading
'Cycle time in days'
end
|
#y_value(item) ⇒ Object
51
52
53
|
# File 'lib/jirametrics/cycletime_scatterplot.rb', line 51
def y_value item
item.board.cycletime.cycletime(item)
end
|