From 99cdbaaabb85e430f27311344afba6871d1bf471 Mon Sep 17 00:00:00 2001 From: lpichler Date: Tue, 6 Dec 2016 11:38:38 +0100 Subject: [PATCH] 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)