Correct project coverage graph dates on x axis
What does this MR do and why?
This MR changes the way we format data that is passed to the coverage graph on the project repository analytics page so that the date labels will be proportionately spaced across the horizontal axis of the graph:
- it changes the chartOptions.xAxis.type from
category
totime
and keeps the dates in YYYY-MM-DD format so that the chart handles the dates as dates and spaces them apart correctly over time (rather than treating them as evenly spaced data points no matter what date they represent) - it uses
formatDate(value, 'mmm dd')
for the axis labels and tooltip to be consistent with the group coverage graph
Screenshots or screen recordings
scenario | test data from instructions below |
---|---|
before | |
with this MR |
How to set up and validate locally
git checkout 332981-evenly-spaced-coverage-graph-dates
- find/create a project that generates a test coverage report or parses a test coverage percentage
(or clone this test project and run pipelines with theCOVERAGE
variable defined to mock a coverage percentage) - navigate to
Analytics
=>Repository
in the project sidebar - observe the
Code coverage statistics for...
section with graph - (optional) insert mock data in this format here to see how the graph would behave:
diff --git a/app/assets/javascripts/pages/projects/graphs/components/code_coverage.vue b/app/assets/javascripts/pages/projects/graphs/components/code_coverage.vue
index 92ae8128285..81036ec160a 100644
--- a/app/assets/javascripts/pages/projects/graphs/components/code_coverage.vue
+++ b/app/assets/javascripts/pages/projects/graphs/components/code_coverage.vue
@@ -84,7 +84,11 @@ export default {
{
// The default string 'data' will get shown in the legend if we fail to fetch the data
name: this.canShowData ? this.selectedDailyCoverageName : __('data'),
- data: this.formattedData,
+ data: [
+ ['2022-04-01', 40],
+ ['2022-04-02', 80],
+ ['2022-05-02', 60],
+ ],
type: 'line',
smooth: true,
},
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Related to #332981 (closed)
Edited by Miranda Fluharty