New Ticket     Tickets     Wiki     Browse Source     Timeline     Roadmap     Ticket Reports     Search

Changeset 82900


Ignore:
Timestamp:
08/21/11 15:57:52 (4 years ago)
Author:
derek@…
Message:

Added options

  • Views can now pass in the following
  • charts: collection of names of charts that should be drawn

Default: empty hash table

  • chart_height, chart_width - width and height of charts.

defaults: height:400, width:600

  • drawtables - draw a table along with each chart

default: true

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/gsoc11-statistics/stats-server/app/views/partials/_chart_draw.html.erb

    r82851 r82900  
     1<%# Set Defaults %> 
     2<% drawtables_default = true %> 
     3<% chart_width_default = 600 %> 
     4<% chart_height_default = 400 %> 
     5 
     6<%# Check if locals have been passed to this partial %> 
     7<%# Use them if available, otherwise use defaults %> 
     8 
     9<%# Avoid nil objects  %> 
     10<% if (defined? charts).nil? %>   
     11  <% charts = Hash.new %> 
     12<% end %> 
     13 
     14<%# Draw tables as well as visualizations? %> 
     15<% if (defined? drawtables).nil? %> 
     16  <% drawtables = drawtables_default %> 
     17<% end %> 
     18 
     19<%# Get chart width %> 
     20<% if (defined? chart_width).nil? %> 
     21  <% chart_width = chart_width_default %> 
     22<% end %> 
     23 
     24<%# Get chart height %> 
     25<% if (defined? chart_height).nil? %> 
     26  <% chart_height = chart_height_default %> 
     27<% end %> 
     28 
     29<%# Set visualization options %> 
     30<% vis_options = {:width => chart_width,  
     31                  :height => chart_height,  
     32                  :html => {:class => "graph_chart"}}  
     33%> 
     34 
     35<%# Set table options %> 
     36<% table_options = {:width => 600,  
     37                    :html => {:class => "graph_chart"}}  
     38%> 
     39 
     40 
    141<%# Draw charts %> 
    242<% charts.each do |chart| %> 
    343  <% title = controller.chart_title chart %> 
    4   <%# Set visualization options %> 
    5   <% vis_options = {:width => 600, :height => 400, :html => {:class => "graph_chart"}} %> 
     44  <% type = controller.chart_type chart %> 
     45 
     46  <%# Set titles %> 
    647  <% vis_options[:title] = title %> 
    7  
    8   <%# Set table options %> 
    9   <% table_options = {:width => 600, :html => {:class => "graph_chart"}} %> 
    1048  <% table_options[:title] = title %> 
    11    
    12   <% type = controller.chart_type chart %> 
    1349 
    1450  <%# Anchor %> 
     
    2460    <% end %> 
    2561     
    26     <%# Draw table %> 
    27     <% table = chart.to_s + "_table" %> 
    28     <% visualization table, "Table", table_options do |visualization| %> 
    29       <% controller.populate_chart chart, visualization %> 
     62    <% if drawtables %> 
     63      <%# Draw table %> 
     64      <% table = chart.to_s + "_table" %> 
     65      <% visualization table, "Table", table_options do |visualization| %> 
     66        <% controller.populate_chart chart, visualization %> 
     67        <% end %> 
    3068    <% end %> 
    3169     
Note: See TracChangeset for help on using the changeset viewer.