Commit 8eac1988e4f2d56ef8190ee98a60488bf1f4c679
Committed by
João M. M. da Silva
1 parent
4b8e832d
Exists in
master
and in
29 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,15 +90,15 @@ class MezuroPluginProfileController < ProfileController | ||
| 90 | 90 | ||
| 91 | def filtering_metric_history(metric_name, module_history) | 91 | def filtering_metric_history(metric_name, module_history) |
| 92 | metrics_history = module_history.map do |module_result| | 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 | end | 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 | metric_result.metric.name.delete("() ") == metric_name | 97 | metric_result.metric.name.delete("() ") == metric_name |
| 98 | - end).first | 98 | + end).first, metric_results_with_date.last] |
| 99 | end | 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 | end | 102 | end |
| 103 | end | 103 | end |
| 104 | 104 |
plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb
| @@ -17,14 +17,21 @@ class MezuroPlugin::Helpers::ContentViewerHelper | @@ -17,14 +17,21 @@ class MezuroPlugin::Helpers::ContentViewerHelper | ||
| 17 | formated_options | 17 | formated_options |
| 18 | end | 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 | :title_color => 'FF0000', | 28 | :title_color => 'FF0000', |
| 23 | :size => '600x180', | 29 | :size => '600x180', |
| 24 | :bg => {:color => 'efefef', :type => 'stripes'}, | 30 | :bg => {:color => 'efefef', :type => 'stripes'}, |
| 25 | :line_colors => 'c4a000', | 31 | :line_colors => 'c4a000', |
| 26 | :data => values, | 32 | :data => values, |
| 27 | - :axis_with_labels => 'y', | 33 | + :labels => labels, |
| 34 | + :axis_with_labels => ['y','x'], | ||
| 28 | :max_value => values.max, | 35 | :max_value => values.max, |
| 29 | :min_value => values.min | 36 | :min_value => values.min |
| 30 | ) | 37 | ) |