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 21 opts = {
22 22 bezierCurve: false,
23 23 scaleOverride: true,
24   - scaleStartValue: (min_value - 2),
  24 + scaleStartValue: (min_value - 30),
25 25 scaleSteps: 3,
26 26 scaleStepWidth: 1
27 27 }
... ...
app/views/modules/_metric_result.html.erb
... ... @@ -15,7 +15,9 @@
15 15 </tr>
16 16 <tr id="container<%= metric_result.id %>" style="display: none">
17 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 21 </td>
20 22 </tr>
21 23 <% end %>
22 24 \ No newline at end of file
... ...
app/views/modules/metric_history.js.erb
1 1 var dates = [];
2 2 var values = [];
  3 +
3 4 <% @metric_history.keys.each do |date| %>
4 5 dates.push("<%= date %>");
5 6 values.push(<%= @metric_history[date] %>);
6 7 <% end %>
7 8  
8   -Module.Graphic.display(dates, values, '<%= @container %>');
9 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 18 \ No newline at end of file
... ...