From f9adf66a482072b48ba48b05692db21e2987d0c9 Mon Sep 17 00:00:00 2001 From: João M. M. da Silva + Rafael Manzo + Diego Araújo Date: Tue, 28 Aug 2012 18:00:11 -0300 Subject: [PATCH] [Mezuro] Draft to insert the x axis on grade history charts. --- plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb | 12 ++++++------ plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb | 13 ++++++++++--- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb index 84a140a..d19fcbe 100644 --- a/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb +++ b/plugins/mezuro/controllers/mezuro_plugin_profile_controller.rb @@ -90,15 +90,15 @@ class MezuroPluginProfileController < ProfileController def filtering_metric_history(metric_name, module_history) metrics_history = module_history.map do |module_result| - module_result.metric_results + [module_result.metric_results, module_result.date.to_s[0..9]] end - metric_history = metrics_history.map do |array_of_metric_result| - (array_of_metric_result.select do |metric_result| + metric_history = metrics_history.map do |metric_results_with_date| + [(metric_results_with_date.first.select do |metric_result| metric_result.metric.name.delete("() ") == metric_name - end).first + end).first, metric_results_with_date.last] end - metric_history.map do |metric_result| - metric_result.value + metric_history.map do |metric_result_with_date| + [metric_result_with_date.first.value, metric_result_with_date.last] end end diff --git a/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb b/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb index 0a0af0c..4529edd 100644 --- a/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb +++ b/plugins/mezuro/lib/mezuro_plugin/helpers/content_viewer_helper.rb @@ -17,14 +17,21 @@ class MezuroPlugin::Helpers::ContentViewerHelper formated_options end - def self.generate_chart(values) - Gchart.line( + def self.generate_chart(score_history) + values = [] + labels = [] + score_history.each do |score_data| + values << score_data.first + labels << score_data.last + end + Gchart.line( :title_color => 'FF0000', :size => '600x180', :bg => {:color => 'efefef', :type => 'stripes'}, :line_colors => 'c4a000', :data => values, - :axis_with_labels => 'y', + :labels => labels, + :axis_with_labels => ['y','x'], :max_value => values.max, :min_value => values.min ) -- libgit2 0.21.2