diff --git a/src/components/workflows/timeline/BaseTimelineDetailedChart.vue b/src/components/workflows/timeline/BaseTimelineDetailedChart.vue index 5dcf5dc..4589c07 100644 --- a/src/components/workflows/timeline/BaseTimelineDetailedChart.vue +++ b/src/components/workflows/timeline/BaseTimelineDetailedChart.vue @@ -16,6 +16,8 @@ interface Props { height?: number, tooltipContent: (d: TimelineChartDataPoint) => string, yAxisTitle?: string, + workflow?: string, + label?: string, higherIsPositive?: boolean } @@ -24,9 +26,26 @@ const props = defineProps() const height = props.height || 60 const marginTop = 10 const marginRight = 10 -const marginBottom = 50 -const marginLeft = 40 +const marginBottom = 90 +const marginLeft = 70 const _width = computed(() => props.width ?? 300) +const yAxisTitle = computed(() => { + let text = '' + if (props.yAxisTitle) { + text = props.yAxisTitle + + if (props.workflow) { + text = `${props.workflow} - ${text}` + } + } + return text +}) + +const yAxisTextHeight = computed(() => { + let value = -(height / 2 + marginTop) + value -= yAxisTitle.value.length ** 1.3 + return Math.round(value) +}) const container = ref() @@ -79,6 +98,14 @@ function render([data, startDate, endDate, maxY]) { svg.select('.x-axis-group .domain').attr('stroke', colors.gray['400']) svg.selectAll('.x-axis-group .tick text').attr('fill', colors.gray['400']) + // Append x-axis title on the bottom + svg + .append('text') + .attr('x', (_width.value / 2) - marginLeft) + .attr('y', height) + .text('Date') + .attr('fill', colors.gray['400']) + // Add the y-axis. svg.append("g") .classed('y-axis-group', true) @@ -94,9 +121,9 @@ function render([data, startDate, endDate, maxY]) { // Append y-axis title on the left svg.append("text") .attr("transform", "rotate(-90)") - .attr("y", marginLeft - 30) - .attr("x", -(height / 2 + marginTop) ) - .text(props.yAxisTitle ?? '') + .attr("y", marginLeft - 55) + .attr("x", yAxisTextHeight.value ) + .text(yAxisTitle.value) .attr('fill', colors.gray['400']) @@ -206,6 +233,7 @@ watch([() => props.data, () => props.startDate, () => props.endDate, () => props diff --git a/src/components/workflows/timeline/MetricAverageChart.vue b/src/components/workflows/timeline/MetricAverageChart.vue index 87bdfb4..0cd682c 100644 --- a/src/components/workflows/timeline/MetricAverageChart.vue +++ b/src/components/workflows/timeline/MetricAverageChart.vue @@ -1,21 +1,25 @@