Commit 851ada82 authored by Jose Ivan Vargas's avatar Jose Ivan Vargas

addressed code quality observations

parent a2d10937
...@@ -41,12 +41,10 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra ...@@ -41,12 +41,10 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
const maxValueFromSeries = _.max(maxValues, val => val.maxValue); const maxValueFromSeries = _.max(maxValues, val => val.maxValue);
let timeSeriesNumber = 1; return queryData.result.map((timeSeries, timeSeriesNumber) => {
return queryData.result.map((timeSeries) => {
let metricTag = ''; let metricTag = '';
let lineColor = '#1f78d1'; let lineColor = '';
let areaColor = '#8fbce8'; let areaColor = '';
const timeSeriesScaleX = d3.time.scale() const timeSeriesScaleX = d3.time.scale()
.range([0, graphWidth - 70]); .range([0, graphWidth - 70]);
...@@ -69,28 +67,17 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra ...@@ -69,28 +67,17 @@ export default function createTimeSeries(queryData, graphWidth, graphHeight, gra
.y0(graphHeight - graphHeightOffset) .y0(graphHeight - graphHeightOffset)
.y1(d => timeSeriesScaleY(d.value)); .y1(d => timeSeriesScaleY(d.value));
if (queryData.series != null) {
const timeSeriesMetricLabel = timeSeries.metric[Object.keys(timeSeries.metric)[0]]; const timeSeriesMetricLabel = timeSeries.metric[Object.keys(timeSeries.metric)[0]];
const seriesCustomizationData = _.findWhere(queryData.series[0].series, const seriesCustomizationData = queryData.series != null &&
_.findWhere(queryData.series[0].series,
{ value: timeSeriesMetricLabel }); { value: timeSeriesMetricLabel });
if (seriesCustomizationData != null) { if (seriesCustomizationData != null) {
metricTag = seriesCustomizationData.value || timeSeriesMetricLabel; metricTag = seriesCustomizationData.value || timeSeriesMetricLabel;
if (seriesCustomizationData.color != null) {
[lineColor, areaColor] = pickColor(seriesCustomizationData.color); [lineColor, areaColor] = pickColor(seriesCustomizationData.color);
} else { } else {
metricTag = timeSeriesMetricLabel || `series ${timeSeriesNumber + 1}`;
[lineColor, areaColor] = pickColor(); [lineColor, areaColor] = pickColor();
} }
} else {
metricTag = timeSeriesMetricLabel || `series ${timeSeriesNumber}`;
[lineColor, areaColor] = pickColor();
}
}
if (timeSeriesNumber <= 5) {
timeSeriesNumber = timeSeriesNumber += 1;
} else {
timeSeriesNumber = 1;
}
return { return {
linePath: lineFunction(timeSeries.values), linePath: lineFunction(timeSeries.values),
......
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