Commit 6fbd7fd6 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

Merge branch '268224-mlunoe-instance-analytics-pipeline-chart-follow-up' into 'master'

Refactor(Instance Analytics): use diff months util

See merge request gitlab-org/gitlab!45535
parents 7c60a340 fa567685
...@@ -4,7 +4,11 @@ import { GlAlert } from '@gitlab/ui'; ...@@ -4,7 +4,11 @@ import { GlAlert } from '@gitlab/ui';
import { mapKeys, mapValues, pick, some, sum } from 'lodash'; import { mapKeys, mapValues, pick, some, sum } from 'lodash';
import ChartSkeletonLoader from '~/vue_shared/components/resizable_chart/skeleton_loader.vue'; import ChartSkeletonLoader from '~/vue_shared/components/resizable_chart/skeleton_loader.vue';
import { s__ } from '~/locale'; import { s__ } from '~/locale';
import { formatDateAsMonth, getDayDifference } from '~/lib/utils/datetime_utility'; import {
differenceInMonths,
formatDateAsMonth,
getDayDifference,
} from '~/lib/utils/datetime_utility';
import { getAverageByMonth, sortByDate, extractValues } from '../utils'; import { getAverageByMonth, sortByDate, extractValues } from '../utils';
import pipelineStatsQuery from '../graphql/queries/pipeline_stats.query.graphql'; import pipelineStatsQuery from '../graphql/queries/pipeline_stats.query.graphql';
import { TODAY, START_DATE } from '../constants'; import { TODAY, START_DATE } from '../constants';
...@@ -150,19 +154,14 @@ export default { ...@@ -150,19 +154,14 @@ export default {
max: this.$options.endDate, max: this.$options.endDate,
}; };
}, },
differenceInMonths() {
const yearDiff = this.$options.endDate.getYear() - this.$options.startDate.getYear();
const monthDiff = this.$options.endDate.getMonth() - this.$options.startDate.getMonth();
return monthDiff + 12 * yearDiff;
},
chartOptions() { chartOptions() {
const { endDate, startDate, i18n } = this.$options;
return { return {
xAxis: { xAxis: {
...this.range, ...this.range,
name: this.$options.i18n.xAxisTitle, name: i18n.xAxisTitle,
type: 'time', type: 'time',
splitNumber: this.differenceInMonths + 1, splitNumber: differenceInMonths(startDate, endDate) + 1,
axisLabel: { axisLabel: {
interval: 0, interval: 0,
showMinLabel: false, showMinLabel: false,
...@@ -172,7 +171,7 @@ export default { ...@@ -172,7 +171,7 @@ export default {
}, },
}, },
yAxis: { yAxis: {
name: this.$options.i18n.yAxisTitle, name: i18n.yAxisTitle,
}, },
}; };
}, },
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment