我在 rails 应用程序中使用带有 twitter bootstrap 的谷歌图表。
在流体布局中,如果跨度宽度减小,图表会溢出其父 div。
谷歌图表宽度可以用百分比给出吗?
请帮忙。
更新
我正在使用google_visualr gem。
这是我的控制器代码。
def home
# Indents
indent_status_table = GoogleVisualr::DataTable.new
indent_status_table.new_column('string', 'STATUS')
indent_status_table.new_column('number', 'COUNT')
indent_status_table.add_rows(1)
indent_status_table.set_cell(0, 0, 'Open')
indent_status_table.set_cell(0, 1, 100)
opts = { :title => 'INDENT STATUS', :is3D => true }
@indent_status_chart = GoogleVisualr::Interactive::PieChart.new(indent_status_table, opts)
end
这是我的 html.erb 代码
<div id='shipment_status_chart' style="width:100%; height:200px"></div>
<%= render_chart @shipment_status_chart, 'shipment_status_chart' %>
并在java脚本代码中。
$(function() {
$(window).resize(function(){
drawChart();
});
});