Skip to content

Commit

Permalink
Use proper name of column in tooltip instead of first one
Browse files Browse the repository at this point in the history
- 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
  • Loading branch information
lpichler committed Dec 9, 2016
1 parent c34468f commit 99cdbaa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
12 changes: 12 additions & 0 deletions app/models/miq_report.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
6 changes: 3 additions & 3 deletions lib/report_formatter/chart_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 99cdbaa

Please sign in to comment.