From 99cdbaaabb85e430f27311344afba6871d1bf471 Mon Sep 17 00:00:00 2001 From: lpichler Date: Tue, 6 Dec 2016 11:38:38 +0100 Subject: [PATCH 1/3] Use proper name of column in tooltip instead of first one - determine name of column (Header column) from chart column. Name is taken from MiqReport#headers by index. This index is determined from MiqReport#col_order --- app/models/miq_report.rb | 12 ++++++++++++ lib/report_formatter/chart_common.rb | 6 +++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/models/miq_report.rb b/app/models/miq_report.rb index 234dcc995e9..6d2620e7623 100644 --- a/app/models/miq_report.rb +++ b/app/models/miq_report.rb @@ -224,4 +224,16 @@ def remove_loading_relations_for_virtual_custom_attributes vc_attributes = CustomAttributeMixin.select_virtual_custom_attributes(cols).present? include.delete(:custom_attributes) if vc_attributes.present? && include && include[:custom_attributes].blank? end + + # determine name column from headers for x-axis in chart + def chart_header_column + if graph[:column].blank? + _log.error("The column for the chart's x-axis must be defined in the report") + return + end + + chart_column = MiqExpression::Field.parse(graph[:column]).column + column_index = col_order.index { |col| col.include?(chart_column) } + headers[column_index] + end end diff --git a/lib/report_formatter/chart_common.rb b/lib/report_formatter/chart_common.rb index c25a6cd4974..cd334723d29 100644 --- a/lib/report_formatter/chart_common.rb +++ b/lib/report_formatter/chart_common.rb @@ -407,7 +407,7 @@ def build_numeric_chart_simple # Pie charts put categories in legend, else in axis labels add_axis_category_text(categories) - add_series(mri.headers[0], series) + add_series(mri.chart_header_column, series) end def build_numeric_chart_grouped @@ -438,7 +438,7 @@ def build_numeric_chart_grouped # Pie charts put categories in legend, else in axis labels add_axis_category_text(categories) - add_series(mri.headers[0], series) + add_series(mri.chart_header_column, series) end def build_numeric_chart_grouped_2dim @@ -537,7 +537,7 @@ def build_reporting_chart_other # Pie charts put categories in legend, else in axis labels add_axis_category_text(categories) - add_series(mri.headers[0], series) + add_series(mri.chart_header_column, series) end # C&U performance charts (Cluster, Host, VM based) From 97dc73ff7d91fa25a6cb866408c7d300d1d5761f Mon Sep 17 00:00:00 2001 From: lpichler Date: Tue, 6 Dec 2016 13:26:41 +0100 Subject: [PATCH 2/3] Fix specs --- spec/lib/report_formater/c3_formatter_spec.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/spec/lib/report_formater/c3_formatter_spec.rb b/spec/lib/report_formater/c3_formatter_spec.rb index 2f3842f1638..cc56c407bae 100644 --- a/spec/lib/report_formater/c3_formatter_spec.rb +++ b/spec/lib/report_formater/c3_formatter_spec.rb @@ -46,9 +46,8 @@ it "handle long strings" do render_report(long_report) - expect(long_report.chart[:miq][:category_table][2]).to eq(long_category) - expect(long_report.chart[:miq][:name_table]['1']).to eq(long_header) + expect(long_report.chart[:miq][:name_table]['1']).to eq('RAM Size (MB)') end end From f00285611977dc89b186f7e1fa9b2b21827fc017 Mon Sep 17 00:00:00 2001 From: lpichler Date: Thu, 8 Dec 2016 12:59:39 +0100 Subject: [PATCH 3/3] Fix specs - [:label] is not used on Pie chart with counts --- spec/lib/report_formater/jqplot_formater_charting_counts_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/lib/report_formater/jqplot_formater_charting_counts_spec.rb b/spec/lib/report_formater/jqplot_formater_charting_counts_spec.rb index ab560ff1fd4..74a9b588da4 100644 --- a/spec/lib/report_formater/jqplot_formater_charting_counts_spec.rb +++ b/spec/lib/report_formater/jqplot_formater_charting_counts_spec.rb @@ -71,7 +71,6 @@ render_report(report) expect(report.chart[:data][0]).to eq([["linux_esx: 3", 3], ["widloze: 1", 1]]) expect(report.chart[:options][:seriesDefaults][:renderer]).to eq("jQuery.jqplot.PieRenderer") - expect(report.chart[:options][:series][0][:label]).to eq("OS Name") expect(report.chart[:options][:highlighter]).to be_truthy end end