From d745876e23e48e7fdf1b569c7e10dd4e2ca2734a Mon Sep 17 00:00:00 2001 From: Jose Ivan Vargas Date: Wed, 29 Mar 2017 10:10:30 -0600 Subject: Code corrections with a helper and a variable --- app/assets/javascripts/monitoring/prometheus_graph.js | 18 +++++++++--------- app/views/projects/environments/metrics.html.haml | 3 +-- 2 files changed, 10 insertions(+), 11 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/monitoring/prometheus_graph.js b/app/assets/javascripts/monitoring/prometheus_graph.js index eb9e93dba09..a7608468a97 100644 --- a/app/assets/javascripts/monitoring/prometheus_graph.js +++ b/app/assets/javascripts/monitoring/prometheus_graph.js @@ -50,19 +50,19 @@ class PrometheusGraph { } plotValues(key) { + const graphSpecifics = this.graphSpecificProperties[key]; + const x = d3.time.scale() .range([0, this.width]); const y = d3.scale.linear() .range([this.height, 0]); - this.graphSpecificProperties[key].xScale = x; - this.graphSpecificProperties[key].yScale = y; + graphSpecifics.xScale = x; + graphSpecifics.yScale = y; const prometheusGraphContainer = `${prometheusGraphsContainer}[graph-type=${key}]`; - const graphSpecifics = this.graphSpecificProperties[key]; - const chart = d3.select(prometheusGraphContainer) .attr('width', this.width + this.margin.left + this.margin.right) .attr('height', this.height + this.margin.bottom + this.margin.top) @@ -142,9 +142,9 @@ class PrometheusGraph { .attr('stroke-width', '1') .attr({ x1: 10, - y1: this.originalHeight - 80, + y1: this.originalHeight - this.margin.top, x2: (this.originalWidth - this.margin.right) + 10, - y2: this.originalHeight - 80, + y2: this.originalHeight - this.margin.top, }); axisLabelContainer.append('line') @@ -155,7 +155,7 @@ class PrometheusGraph { x1: 10, y1: 0, x2: 10, - y2: this.originalHeight - 80, + y2: this.originalHeight - this.margin.top, }); axisLabelContainer.append('rect') .attr('class', 'rect-axis-text') @@ -167,7 +167,7 @@ class PrometheusGraph { axisLabelContainer.append('text') .attr('class', 'label-axis-text') .attr('text-anchor', 'middle') - .attr('transform', `translate(15, ${(this.originalHeight - 80) / 2}) rotate(-90)`) + .attr('transform', `translate(15, ${(this.originalHeight - this.margin.top) / 2}) rotate(-90)`) .text(graphSpecifics.graph_legend_title); axisLabelContainer.append('rect') @@ -180,7 +180,7 @@ class PrometheusGraph { axisLabelContainer.append('text') .attr('class', 'label-axis-text') .attr('x', (this.originalWidth / 2) - this.margin.right) - .attr('y', this.originalHeight - 80) + .attr('y', this.originalHeight - this.margin.top) .attr('dy', '.35em') .text('Time'); diff --git a/app/views/projects/environments/metrics.html.haml b/app/views/projects/environments/metrics.html.haml index 5627192c36c..92dc58cd38d 100644 --- a/app/views/projects/environments/metrics.html.haml +++ b/app/views/projects/environments/metrics.html.haml @@ -11,8 +11,7 @@ .col-sm-6 %h3.page-title Environment: - = link_to environment_path(@environment) do - = @environment.name + = link_to @environment.name, environment_path(@environment) .col-sm-6 .nav-controls -- cgit v1.2.1