From 33cd912b90c7021eedabbed25f07988e71ccf21c Mon Sep 17 00:00:00 2001 From: Adriel Santiago Date: Wed, 23 Jan 2019 18:42:31 -0500 Subject: Use ECharts for metrics dashboard Update metrics dashboard to support GitLab UI area chart changes --- .../monitoring/components/charts/area.vue | 21 +++++++++++---------- .../monitoring/stores/monitoring_store.js | 10 +++++----- app/assets/stylesheets/pages/environments.scss | 12 +----------- 3 files changed, 17 insertions(+), 26 deletions(-) diff --git a/app/assets/javascripts/monitoring/components/charts/area.vue b/app/assets/javascripts/monitoring/components/charts/area.vue index e2cffe0b4b4..5ca561259b6 100644 --- a/app/assets/javascripts/monitoring/components/charts/area.vue +++ b/app/assets/javascripts/monitoring/components/charts/area.vue @@ -35,13 +35,7 @@ export default { computed: { chartData() { return this.graphData.queries.reduce((accumulator, query) => { - const xLabel = `${query.unit}`; - accumulator[xLabel] = {}; - query.result.forEach(res => - res.values.forEach(v => { - accumulator[xLabel][v.time.toISOString()] = v.value; - }), - ); + accumulator[query.unit] = query.result.reduce((acc, res) => acc.concat(res.values), []); return accumulator; }, {}); }, @@ -51,14 +45,17 @@ export default { name: 'Time', type: 'time', axisLabel: { - formatter: date => dateFormat(date, 'h:MMtt'), + formatter: date => dateFormat(date, 'h:MM TT'), + }, + axisPointer: { + snap: true, }, nameTextStyle: { padding: [18, 0, 0, 0], }, }, yAxis: { - name: this.graphData.y_label, + name: this.yAxisLabel, axisLabel: { formatter: value => value.toFixed(3), }, @@ -74,6 +71,10 @@ export default { xAxisLabel() { return this.graphData.queries.map(query => query.label).join(', '); }, + yAxisLabel() { + const [query] = this.graphData.queries; + return `${this.graphData.y_label} (${query.unit})`; + }, }, methods: { formatTooltipText(params) { @@ -85,7 +86,7 @@ export default {