Skip to content

Commit

Permalink
Merge pull request ManageIQ#13011 from lpichler/use_proper_name_for_t…
Browse files Browse the repository at this point in the history
…ooltip_in_charts

Use proper name of column in tooltip in charts
  • Loading branch information
mzazrivec authored Dec 13, 2016
2 parents f5bb6b7 + f002856 commit d6b146f
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 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
3 changes: 1 addition & 2 deletions spec/lib/report_formater/c3_formatter_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d6b146f

Please sign in to comment.