Commit 95684109d26ba7233e428a39b40147e36ae5aa03
Committed by
fllsouto
1 parent
4a893dda
Exists in
colab
and in
4 other branches
Improved metric history graphic usability
Signed-of By: Guilherme Rojas V. de Lima <guilhermehrojas@gmail.com>
Showing
3 changed files
with
13 additions
and
3 deletions
Show diff stats
app/assets/javascripts/module/graphic.js.coffee
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 | ... | ... |