Commit f9adf66a482072b48ba48b05692db21e2987d0c9
Committed by
João M. M. da Silva
1 parent
60e11e2c
Exists in
master
and in
23 other branches
[Mezuro] Draft to insert the x axis on grade history charts.
Showing
2 changed files
with
16 additions
and
9 deletions
Show diff stats
plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb
| ... | ... | @@ -90,15 +90,15 @@ class MezuroPluginProfileController < ProfileController |
| 90 | 90 | |
| 91 | 91 | def filtering_metric_history(metric_name, module_history) |
| 92 | 92 | metrics_history = module_history.map do |module_result| |
| 93 | - module_result.metric_results | |
| 93 | + [module_result.metric_results, module_result.date.to_s[0..9]] | |
| 94 | 94 | end |
| 95 | - metric_history = metrics_history.map do |array_of_metric_result| | |
| 96 | - (array_of_metric_result.select do |metric_result| | |
| 95 | + metric_history = metrics_history.map do |metric_results_with_date| | |
| 96 | + [(metric_results_with_date.first.select do |metric_result| | |
| 97 | 97 | metric_result.metric.name.delete("() ") == metric_name |
| 98 | - end).first | |
| 98 | + end).first, metric_results_with_date.last] | |
| 99 | 99 | end |
| 100 | - metric_history.map do |metric_result| | |
| 101 | - metric_result.value | |
| 100 | + metric_history.map do |metric_result_with_date| | |
| 101 | + [metric_result_with_date.first.value, metric_result_with_date.last] | |
| 102 | 102 | end |
| 103 | 103 | end |
| 104 | 104 | ... | ... |
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
| ... | ... | @@ -17,14 +17,21 @@ class MezuroPlugin::Helpers::ContentViewerHelper |
| 17 | 17 | formated_options |
| 18 | 18 | end |
| 19 | 19 | |
| 20 | - def self.generate_chart(values) | |
| 21 | - Gchart.line( | |
| 20 | + def self.generate_chart(score_history) | |
| 21 | + values = [] | |
| 22 | + labels = [] | |
| 23 | + score_history.each do |score_data| | |
| 24 | + values << score_data.first | |
| 25 | + labels << score_data.last | |
| 26 | + end | |
| 27 | + Gchart.line( | |
| 22 | 28 | :title_color => 'FF0000', |
| 23 | 29 | :size => '600x180', |
| 24 | 30 | :bg => {:color => 'efefef', :type => 'stripes'}, |
| 25 | 31 | :line_colors => 'c4a000', |
| 26 | 32 | :data => values, |
| 27 | - :axis_with_labels => 'y', | |
| 33 | + :labels => labels, | |
| 34 | + :axis_with_labels => ['y','x'], | |
| 28 | 35 | :max_value => values.max, |
| 29 | 36 | :min_value => values.min |
| 30 | 37 | ) | ... | ... |