Skip to content

Commit 89e5be7

Browse files
committed
Add Observation logging for Work Item Age chart
1 parent b7d6a42 commit 89e5be7

1 file changed

Lines changed: 54 additions & 0 deletions

File tree

src/graphs/work-item-age/WorkItemAgeRenderer.js

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ class WorkItemAgeRenderer extends Renderer {
1919
this.states = states.filter((d) => d !== 'delivered');
2020
this.data = this.groupData(filteredData);
2121
this.workTicketsURL = workTicketsURL;
22+
this.chartType = 'WORK_ITEM_AGE';
23+
}
24+
25+
setupEventBus(eventBus) {
26+
this.eventBus = eventBus;
2227
}
2328

2429
groupData(data) {
@@ -248,12 +253,22 @@ class WorkItemAgeRenderer extends Renderer {
248253
}
249254

250255
handleMouseClickEvent(event, d) {
256+
const observationsData = [];
257+
d.items.forEach((item) => {
258+
const obs = this.observations?.data?.find((o) => item.ticketId === o.work_item && o.chart_type === this.chartType);
259+
if (obs) {
260+
observationsData.push(obs);
261+
}
262+
});
263+
251264
let data = {
252265
...d,
253266
tooltipLeft: event.pageX,
254267
tooltipTop: event.pageY,
268+
observations: observationsData,
255269
};
256270

271+
this.eventBus?.emitEvents(`work-item-age-click`, data);
257272
this.showTooltip(data);
258273
}
259274

@@ -264,6 +279,45 @@ class WorkItemAgeRenderer extends Renderer {
264279
}
265280
});
266281
}
282+
283+
setupObservationLogging(observations) {
284+
if (observations?.data?.length > 0) {
285+
this.displayObservationMarkers(observations);
286+
}
287+
}
288+
289+
displayObservationMarkers(observations) {
290+
if (observations?.data) {
291+
this.observations = observations;
292+
this.#removeObservationMarkers();
293+
this.#createObservationMarkers();
294+
}
295+
}
296+
297+
#removeObservationMarkers() {
298+
this.svg?.selectAll('.ring')?.remove();
299+
}
300+
301+
#createObservationMarkers() {
302+
this.svg
303+
.selectAll('ring')
304+
.data(
305+
this.data.filter((d) =>
306+
this.observations?.data?.some(
307+
(o) => d.items.find((i) => i.ticketId === o.work_item.toString()) && o.chart_type === this.chartType
308+
)
309+
)
310+
)
311+
.enter()
312+
.append('circle')
313+
.attr('class', 'ring')
314+
.attr('cx', (d) => d.xJitter)
315+
.attr('cy', (d) => this.y(d.age))
316+
.attr('r', 10)
317+
.attr('fill', 'none')
318+
.attr('stroke', 'black')
319+
.attr('stroke-width', '2px');
320+
}
267321
}
268322

269323
export default WorkItemAgeRenderer;

0 commit comments

Comments
 (0)