diff --git a/app/controllers/application_controller/performance.rb b/app/controllers/application_controller/performance.rb index 2ab1c1cb2110..df87e559be8e 100644 --- a/app/controllers/application_controller/performance.rb +++ b/app/controllers/application_controller/performance.rb @@ -824,7 +824,7 @@ def prepare_perf_tag_chart(chart, rpt, cat_desc) # Grab the first (and should be only) chart column col = chart[:columns].first # Create the new chart columns for each tag - chart[:columns] ||= rpt.extras[:group_by_tags].collect { |t| col + "_" + t } + chart[:columns] = rpt.extras[:group_by_tags].collect { |t| col + "_" + t } end def gen_perf_chart(chart, rpt, idx, zoom_action) diff --git a/lib/report_formatter/c3.rb b/lib/report_formatter/c3.rb index 75fe9ce5fdb2..57b6c9040404 100644 --- a/lib/report_formatter/c3.rb +++ b/lib/report_formatter/c3.rb @@ -92,7 +92,6 @@ def build_document_header mri.chart[:legend] = {:position => 'bottom'} end - binding.pry column = is_grouped_by_tag_category? ? mri.graph[:columns][0].split(/_+/)[0..-2].join('_') : mri.graph[:columns][0] format, options = javascript_format(column, nil) return unless format diff --git a/lib/report_formatter/chart_common.rb b/lib/report_formatter/chart_common.rb index cd334723d290..7d62845c5cd3 100644 --- a/lib/report_formatter/chart_common.rb +++ b/lib/report_formatter/chart_common.rb @@ -353,7 +353,6 @@ def extract_column_names # 'Vm-num_cpu:total' gives 'num_cpu' and 'num_cpu__total' # "Vm::Providers::InfraManager::Vm-num_cpu:total" # gives 'Vm::Providers::InfraManager::Vm' and 'num_cpu__total' - stage1, aggreg = mri.graph[:column].split(/(? :performance }}) + end + + it "has right data" do + expect(report.chart[:data][:columns][0].count).to eq(report.table.data.count + 1) + expect(report.chart[:data][:columns][0]).to eq(["x", "8/19", "8/20"]) + expect(report.chart[:data][:columns][1]).to eq(["1", 19986.0, 205632.0]) + expect(report.chart[:data][:columns][2]).to eq(["2", 41584.0, 41584.0]) + end + + it "has right type" do + expect(report.chart[:axis][:x][:type]).to eq("timeseries") + end + + it 'has right formatting functions' do + expect(report.chart[:axis][:y][:tick][:format][:function]).to eq("mhz_to_human_size") + expect(report.chart[:miq][:format][:function]).to eq("mhz_to_human_size") + end + it 'has right tabels' do + expect(report.chart[:miq][:name_table]).to eq({"1"=>"Avg Used", "2"=>"Max Available"}) + expect(report.chart[:miq][:category_table]).to eq(["8/19", "8/20"]) + end + end + + context '#C&U charts with grouping' do + let(:report) { cu_chart_with_grouping } + before(:each) do + render_report(report, &Proc.new{ |e| e.options.graph_options = { :chart_type => :performance }}) + end + + it "has right data" do + expect(report.chart[:data][:columns][0].count).to eq(report.table.data.count + 1) + expect(report.chart[:data][:columns][0]).to eq(["x", "8/19", "8/20"]) + expect(report.chart[:data][:columns][1]).to eq(["1", 19986.0, 205632.0]) + expect(report.chart[:data][:columns][2]).to eq(["2", 41584.0, 41584.0]) + end + + it "has right type" do + expect(report.chart[:axis][:x][:type]).to eq("timeseries") + end + + it 'has right formatting functions' do + expect(report.chart[:axis][:y][:tick][:format][:function]).to eq("mhz_to_human_size") + expect(report.chart[:miq][:format][:function]).to eq("mhz_to_human_size") + end + it 'has right tabels' do + expect(report.chart[:miq][:name_table]).to eq({"1"=>"Avg Used", "2"=>"Max Available"}) + expect(report.chart[:miq][:category_table]).to eq(["8/19", "8/20"]) + end + end end