allow charts to have auto width and height
This commit is contained in:
parent
34ff4d7dc4
commit
07f0e6a3a5
@ -40,9 +40,11 @@ class ChartsController < ApplicationController
|
||||
# allow these parameters when creating feed querystring
|
||||
feed_params = ['key','days','start','end','round','timescale','average','median','sum','results','location','status']
|
||||
|
||||
# default chart size
|
||||
@width = Chart.default_width
|
||||
@height = Chart.default_height
|
||||
# set chart size
|
||||
width = params[:width].present? ? params[:width] : Chart.default_width
|
||||
@width_style = (width == 'auto') ? '' : "width: #{width.to_i - 25}px;"
|
||||
height = params[:height].present? ? params[:height] : Chart.default_height
|
||||
@height_style = (height == 'auto') ? '' : "height: #{height.to_i - 25}px;"
|
||||
|
||||
# add extra parameters to querystring
|
||||
@qs = ''
|
||||
|
@ -1,5 +1,5 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<html style="height: 100%;">
|
||||
<head>
|
||||
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||
<%= javascript_include_tag 'application' %>
|
||||
@ -183,9 +183,9 @@
|
||||
|
||||
</script>
|
||||
</head>
|
||||
<body style='background-color: <%= params[:bgcolor] ? params[:bgcolor] : 'white' %>;'>
|
||||
<div id="chart-container" style="width: <%= params[:width] ? params[:width].to_i - 25 : @width.to_i - 25 %>px; height: <%= params[:height] ? params[:height].to_i - 25 : @height.to_i - 25 %>px; display: table-cell; vertical-align: middle;">
|
||||
<%= image_tag 'ajax-loader.gif', :style => "margin: auto; display: block;" %>
|
||||
<body style='background-color: <%= params[:bgcolor] ? params[:bgcolor] : 'white' %>; height: 100%; margin: 0; padding: 0;'>
|
||||
<div id="chart-container" style="<%= @width_style %> <%= @height_style %> display: block; position:absolute; bottom:0; top:0; left:0; right:0; margin: 5px 15px 15px 0;">
|
||||
<%= image_tag 'ajax-loader.gif', :style => "position: absolute; margin: auto; top: 0; left: 0; right: 0; bottom: 0;" %>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
Loading…
Reference in New Issue
Block a user