Commit 95684109d26ba7233e428a39b40147e36ae5aa03

Authored by Fellipe Souto Sampaio
Committed by fllsouto
1 parent 4a893dda

Improved metric history graphic usability

Signed-of By: Guilherme Rojas V. de Lima <guilhermehrojas@gmail.com>
app/assets/javascripts/module/graphic.js.coffee
@@ -21,7 +21,7 @@ class Module.Graphic @@ -21,7 +21,7 @@ class Module.Graphic
21 opts = { 21 opts = {
22 bezierCurve: false, 22 bezierCurve: false,
23 scaleOverride: true, 23 scaleOverride: true,
24 - scaleStartValue: (min_value - 2), 24 + scaleStartValue: (min_value - 30),
25 scaleSteps: 3, 25 scaleSteps: 3,
26 scaleStepWidth: 1 26 scaleStepWidth: 1
27 } 27 }
app/views/modules/_metric_result.html.erb
@@ -15,7 +15,9 @@ @@ -15,7 +15,9 @@
15 </tr> 15 </tr>
16 <tr id="container<%= metric_result.id %>" style="display: none"> 16 <tr id="container<%= metric_result.id %>" style="display: none">
17 <td colspan="4"> 17 <td colspan="4">
18 - <canvas id="container<%= metric_result.id %>" class="graphic_container"><%= image_tag 'loader.gif' %> Loading data. Please, wait.</canvas> 18 + <span id="loader_container<%= metric_result.id %>"><%= image_tag 'loader.gif' %> Loading data. Please, wait.</span>
  19 + <canvas id="container<%= metric_result.id %>" class="graphic_container" style="display: none"></canvas>
  20 + <span id="container<%= metric_result.id %>" style="display: none">There is just a point and it should not be printed into a chart.</span>
19 </td> 21 </td>
20 </tr> 22 </tr>
21 <% end %> 23 <% end %>
22 \ No newline at end of file 24 \ No newline at end of file
app/views/modules/metric_history.js.erb
1 var dates = []; 1 var dates = [];
2 var values = []; 2 var values = [];
  3 +
3 <% @metric_history.keys.each do |date| %> 4 <% @metric_history.keys.each do |date| %>
4 dates.push("<%= date %>"); 5 dates.push("<%= date %>");
5 values.push(<%= @metric_history[date] %>); 6 values.push(<%= @metric_history[date] %>);
6 <% end %> 7 <% end %>
7 8
8 -Module.Graphic.display(dates, values, '<%= @container %>');  
9 \ No newline at end of file 9 \ No newline at end of file
  10 +$("#loader_<%= @container %>").hide()
  11 +if (dates.length > 1) {
  12 + $("canvas#<%= @container %>").show()
  13 + Module.Graphic.display(dates, values, '<%= @container %>');
  14 +}
  15 +else {
  16 + $('span#<%= @container %>').show()
  17 +}
10 \ No newline at end of file 18 \ No newline at end of file