Created
January 30, 2009 18:57
-
-
Save c3mediagroup/55207 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def advisor | |
@license = 'LTAM663SPJLO.945CWK-2XOI1X0-7L' | |
advisor = Advisor.find(params[:id]) | |
category = params[:category] | |
case category | |
when 'fixed' | |
chart_years = advisor.fixed_product_years.find_all_by_year(@year_num) | |
when 'combined' | |
chart_years = advisor.categorical_years.find_all_by_year(@year_num) | |
else | |
chart_years = advisor.categorical_years.find(:all, :conditions => ['categories.name = ? AND years.year = ?', category, @year_num]) | |
end | |
chart = Ziya::Charts::Mixed.new(LICENSE, "company_runrate") | |
if category.name == 'combined' | |
chart.add :chart_types, %w[area area area area area line line line line line line column] | |
else | |
chart.add :chart_types, %w[line line line line line line line] | |
end | |
chart.add( :axis_category_text, [''] + MONTHS ) | |
chart.add :theme , "statusroom" | |
if chart_years.blank? | |
chart.add(:series, [0]*13) | |
else | |
if category.name == 'combined' | |
chart.add(:series, PERFORMANCE_METRIC_4[:label], [PERFORMANCE_METRIC_4[:label] *13]) | |
chart.add(:series, PERFORMANCE_METRIC_3[:label], [PERFORMANCE_METRIC_3[:label] *13]) | |
chart.add(:series, PERFORMANCE_METRIC_2[:label], [PERFORMANCE_METRIC_2[:label] *13]) | |
chart.add(:series, PERFORMANCE_METRIC_1[:label], [PERFORMANCE_METRIC_2[:label] *13]) | |
chart.add(:series, PERFORMANCE_METRIC_0[:label], [PERFORMANCE_METRIC_0[:label] *13]) | |
end | |
chart_data = Chart.new(chart_years) | |
chart.add(:series, 'Min Target', [chart_data.report[:'Annual Minimum' ].first] * 13) | |
chart.add(:series, 'Min Target Cum.', [0] + chart_data.report[:'Minimum Target Cum.']) | |
chart.add(:series, 'Annual Target', [chart_data.report[:'Annual Target'].first] * 13) | |
chart.add(:series, 'Target Cum.', [0] + chart_data.report[:'Target Cumulative']) | |
chart.add(:series, 'Fixed Products', [0] + chart_data.report[:'Actual']) | |
chart.add(:series, 'Runrate', [0] + chart_data.report[:'Run Rate']) | |
chart.add(:series, 'Actual Cum.', [0] + chart_data.report[:'Actual Cumulative']) | |
end | |
respond_to do |wants| | |
wants.xml { render :text => chart.to_xml and return } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment