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
|
# allow these parameters when creating feed querystring
|
||||||
feed_params = ['key','days','start','end','round','timescale','average','median','sum','results','location','status']
|
feed_params = ['key','days','start','end','round','timescale','average','median','sum','results','location','status']
|
||||||
|
|
||||||
# default chart size
|
# set chart size
|
||||||
@width = Chart.default_width
|
width = params[:width].present? ? params[:width] : Chart.default_width
|
||||||
@height = Chart.default_height
|
@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
|
# add extra parameters to querystring
|
||||||
@qs = ''
|
@qs = ''
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html>
|
<html style="height: 100%;">
|
||||||
<head>
|
<head>
|
||||||
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
|
||||||
<%= javascript_include_tag 'application' %>
|
<%= javascript_include_tag 'application' %>
|
||||||
@ -183,9 +183,9 @@
|
|||||||
|
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body style='background-color: <%= params[:bgcolor] ? params[:bgcolor] : 'white' %>;'>
|
<body style='background-color: <%= params[:bgcolor] ? params[:bgcolor] : 'white' %>; height: 100%; margin: 0; padding: 0;'>
|
||||||
<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;">
|
<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 => "margin: auto; display: block;" %>
|
<%= image_tag 'ajax-loader.gif', :style => "position: absolute; margin: auto; top: 0; left: 0; right: 0; bottom: 0;" %>
|
||||||
</div>
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
Loading…
Reference in New Issue
Block a user