diff options
author | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-09-06 02:30:08 +0300 |
---|---|---|
committer | Jose Ivan Vargas <jvargas@gitlab.com> | 2017-09-07 17:19:13 +0300 |
commit | 93ba3fdd1e756168ba9ca12e60a53a98969ccdec (patch) | |
tree | c0d7b333cd89c1cd5f0c36d24e9121d4d3495a16 /app/assets/javascripts/monitoring | |
parent | 75b8f64ac331ac344dd0b4afa49ca4ad9e3de977 (diff) |
small fixes to code and specs
Diffstat (limited to 'app/assets/javascripts/monitoring')
-rw-r--r-- | app/assets/javascripts/monitoring/utils/multiple_time_series.js | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/app/assets/javascripts/monitoring/utils/multiple_time_series.js b/app/assets/javascripts/monitoring/utils/multiple_time_series.js index 164157a72b7..eca79587a49 100644 --- a/app/assets/javascripts/monitoring/utils/multiple_time_series.js +++ b/app/assets/javascripts/monitoring/utils/multiple_time_series.js @@ -2,8 +2,8 @@ import d3 from 'd3'; import _ from 'underscore'; function pickColorFromNameNumber(colorName, colorNumber) { - let lineColor = '#1f78d1'; - let areaColor = '#8fbce8'; + let lineColor = ''; + let areaColor = ''; const color = colorName != null ? colorName : colorNumber; switch (color) { case 'blue': @@ -55,13 +55,9 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra const maxValueFromSeries = _.max(maxValues, val => val.maxValue); let timeSeriesNumber = 1; - let lineColor = '#1f78d1'; - let areaColor = '#8fbce8'; - const lineColors = ['#1f78d1', '#fc9403', '#db3b21', '#1aaa55', '#6666c4']; - const areaColors = ['#8fbce8', '#feca81', '#ed9d90', '#8dd5aa', '#d1d1f0']; return queryData.result.map((timeSeries, index) => { - let metricTag = 'series'; + let metricTag = ''; let pathColors = null; const timeSeriesScaleX = d3.time.scale() .range([0, graphWidth - 70]); @@ -84,29 +80,27 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra .y0(graphHeight - graphHeightOffset) .y1(d => timeSeriesScaleY(d.value)); - lineColor = lineColors[timeSeriesNumber - 1]; - areaColor = areaColors[timeSeriesNumber - 1]; - if (queryData.series != null) { const seriesCustomizationData = queryData.series[index]; - metricTag = timeSeries.metric[Object.keys(timeSeries.metric)[0]] || ''; + const timeSeriesMetricLabel = timeSeries.metric[Object.keys(timeSeries.metric)[0]]; if (seriesCustomizationData != null) { - if ( - seriesCustomizationData.value === metricTag && - seriesCustomizationData.color != null - ) { + metricTag = seriesCustomizationData.value || timeSeriesMetricLabel; + if (seriesCustomizationData.color != null) { pathColors = pickColorFromNameNumber(seriesCustomizationData.color.toLowerCase(), null); } + } else { + metricTag = timeSeriesMetricLabel || `series ${timeSeriesNumber}`; } } if (pathColors == null) { pathColors = pickColorFromNameNumber(null, timeSeriesNumber); - if (timeSeriesNumber <= 5) { - timeSeriesNumber = timeSeriesNumber += 1; - } else { - timeSeriesNumber = 1; - } + } + + if (timeSeriesNumber <= 5) { + timeSeriesNumber = timeSeriesNumber += 1; + } else { + timeSeriesNumber = 1; } return { |