Skip to content

Commit bda2e04

Browse files
committed
Update codebase:
- CFDGraph.js - CFDRenderer.js - ScatterplotGraph.js - UIControlsRenderer.js
1 parent 0aa6ab6 commit bda2e04

File tree

3 files changed

+37
-14
lines changed

3 files changed

+37
-14
lines changed

src/graphs/UIControlsRenderer.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,24 +127,25 @@ export default class UIControlsRenderer extends Renderer {
127127
* @returns {d3.Axis} - The configured D3 axis for the x-axis.
128128
*/
129129
createXAxis(x, timeInterval = this.timeInterval) {
130+
console.log("time interval", this.timeInterval)
130131
let axis;
131132
switch (timeInterval) {
132-
case 'days':
133+
case "days":
133134
axis = d3
134135
.axisBottom(x)
135136
.ticks(d3.timeDay.every(1)) // label every 2 days
136137
.tickFormat((d, i) => {
137138
return i % 2 === 0 ? d3.timeFormat("%b %d")(d) : "";
138139
});
139140
break;
140-
case 'weeks':
141+
case "weeks":
141142
axis = d3.axisBottom(x).ticks(d3.timeWeek);
142143
break;
143-
case 'months':
144+
case "months":
144145
axis = d3.axisBottom(x).ticks(d3.timeMonth);
145146
break;
146147
default:
147-
axis = d3.axisBottom(x);
148+
return d3.axisBottom(x);
148149
}
149150
return axis;
150151
}
@@ -155,6 +156,8 @@ export default class UIControlsRenderer extends Renderer {
155156
* and then redraws the x-axis based on the selected time range.
156157
*/
157158
changeTimeInterval(isManualUpdate, chart) {
159+
// console.log("this.timeInterval", this.timeInterval)
160+
158161
if (isManualUpdate) {
159162
switch (this.timeInterval) {
160163
case 'weeks':
@@ -176,6 +179,7 @@ export default class UIControlsRenderer extends Renderer {
176179
}
177180

178181
determineTheAppropriateAxisLabels() {
182+
// console.log("this.reportingRangeDays", this.reportingRangeDays)
179183
if (this.reportingRangeDays <= 31) {
180184
return "days";
181185
}

src/graphs/cfd/CFDRenderer.js

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class CFDRenderer extends UIControlsRenderer {
4949
* }
5050
* ];
5151
*/
52-
constructor(data, states = ['analysis_active', 'analysis_done', 'in_progress', 'dev_complete', 'verification_start', 'delivered']) {
52+
constructor(data, states) {
5353
super(data);
5454
this.states = states;
5555
this.#statesColors = d3.scaleOrdinal().domain(this.states).range(this.#colorPalette);
@@ -142,7 +142,8 @@ class CFDRenderer extends UIControlsRenderer {
142142
this.reportingRangeDays = calculateDaysBetweenDates(domain[0], domain[1])
143143
this.currentXScale = this.x.copy().domain(domain);
144144
this.currentYScale = this.y.copy().domain([0, maxY]).nice();
145-
this.drawXAxis(this.gx, this.currentXScale, this.height);
145+
this.changeTimeInterval(false, "cfd");
146+
this.drawXAxis(this.gx, this.currentXScale, this.height,true);
146147
this.drawYAxis(this.gy, this.currentYScale);
147148

148149
this.chartArea
@@ -178,7 +179,7 @@ class CFDRenderer extends UIControlsRenderer {
178179
*/
179180
#drawArea() {
180181
this.chartArea = this.addClipPath(this.svg, 'cfd-clip');
181-
// this.chartArea.append('rect').attr('width', '100%').attr('height', '100%').attr('id', 'cfd-area').attr('fill', 'transparent');
182+
this.chartArea.append('rect').attr('width', '100%').attr('height', '100%').attr('id', 'cfd-area').attr('fill', 'transparent');
182183
const areaGenerator = this.#createAreaGenerator(this.x, this.y);
183184
this.#drawStackedAreaChart(this.chartArea, this.#stackedData, areaGenerator);
184185
this.#drawLegend();
@@ -323,7 +324,7 @@ class CFDRenderer extends UIControlsRenderer {
323324
* @param isGraph
324325
*/
325326
drawXAxis(g, x, height = this.height, isGraph = false) {
326-
const axis = this.createXAxis(x);
327+
let axis;
327328
const clipId = 'cfd-x-axis-clip';
328329
this.svg
329330
.append('clipPath')
@@ -334,6 +335,7 @@ class CFDRenderer extends UIControlsRenderer {
334335
.attr('width', this.width)
335336
.attr('height', this.height);
336337
if (isGraph) {
338+
axis = this.createXAxis(x);
337339
const axisGroup = g.call(axis).attr('transform', `translate(0, ${height})`);
338340
const axisPath = axisGroup
339341
.selectAll('path')
@@ -353,6 +355,7 @@ class CFDRenderer extends UIControlsRenderer {
353355
g.selectAll('text').attr('y', 30).style('fill', 'black');
354356
g.attr('clip-path', `url(#${clipId})`);
355357
} else {
358+
axis = this.createXAxis(x, "months");
356359
g.call(axis).attr('transform', `translate(0, ${height})`);
357360
}
358361
}
@@ -554,10 +557,25 @@ class CFDRenderer extends UIControlsRenderer {
554557
#handleMouseEvent(event, eventName) {
555558
if (this.#areMetricsEnabled) {
556559
this.#removeMetricsLines();
557-
const coords = d3.pointer(event, d3.select('#cfd-area').node()); // Get the mouse x-position
560+
const coords = d3.pointer(event, d3.select('#cfd-area').node());
558561
const xPosition = coords[0];
559562
const yPosition = coords[1];
563+
564+
// Debug logs
565+
// console.log("coords:", coords);
566+
// console.log("xPosition:", xPosition, "yPosition:", yPosition);
567+
// console.log("currentXScale domain:", this.currentXScale.domain());
568+
// console.log("currentXScale range:", this.currentXScale.range());
569+
570+
// Ensure xPosition is within the chart's range
571+
if (xPosition < 0 || xPosition > this.width) {
572+
console.log("xPosition out of bounds:", xPosition);
573+
return;
574+
}
575+
560576
const date = this.currentXScale.invert(xPosition);
577+
// console.log("pointer", date, event, coords);
578+
561579
const cumulativeCountOfWorkItems = this.currentYScale.invert(yPosition);
562580
const excludeCycleTime = eventName === 'scatterplot-mousemove';
563581

@@ -597,7 +615,7 @@ class CFDRenderer extends UIControlsRenderer {
597615
*/
598616
computeMetrics(currentDate, currentCumulativeCount, excludeCycleTime = false) {
599617
currentDate = new Date(currentDate);
600-
currentDate.setUTCHours(0, 0, 0, 0);
618+
// currentDate.setUTCHours(0, 0, 0, 0);
601619
const currentDataEntry = this.data.find((d) => areDatesEqual(new Date(d.date), currentDate));
602620
if (currentDataEntry) {
603621
const filteredData = this.data.filter((d) => d.date <= currentDate).reverse();

src/graphs/scatterplot/ScatterplotGraph.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class ScatterplotGraph {
3737
* }
3838
* ];
3939
*/
40-
constructor(data) {
41-
this.data = data;
40+
constructor(data, states = ["analysis_active", "analysis_done", "in_progress", "dev_complete", "verification_start", "delivered"]) {
41+
this.data = data;
42+
this.states = states;
4243
}
43-
4444
/**
4545
* Computes the dataSet for the Scatterplot and Histogram graphs.
4646
*
@@ -65,12 +65,13 @@ class ScatterplotGraph {
6565
this.data.forEach((ticket) => {
6666
if (ticket.delivered) {
6767
const deliveredDate = new Date(ticket.delivered * 1000);
68-
deliveredDate.setUTCHours(0, 0, 0, 0);
68+
deliveredDate.setHours(0, 0, 0, 0);
6969
const scatterplotTicket = {
7070
deliveredDate: deliveredDate,
7171
leadTime: 0,
7272
ticketId: ticket.work_id,
7373
};
74+
console.log(scatterplotTicket)
7475
for (const state of this.states) {
7576
if (ticket[state]) {
7677
scatterplotTicket.leadTime = calculateDaysBetweenDates(ticket[state], ticket.delivered);

0 commit comments

Comments
 (0)