Google visualization 改变谷歌图表定位
当我使用谷歌图表时,它使用一个位置:绝对在它的一个div内。那把布局搞砸了 在HTML上,我放了:Google visualization 改变谷歌图表定位,google-visualization,Google Visualization,当我使用谷歌图表时,它使用一个位置:绝对在它的一个div内。那把布局搞砸了 在HTML上,我放了: <div id="chart-1-year" /> 还有Javascript: google.load("visualization", "1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { // Create and populate the
<div id="chart-1-year" />
还有Javascript:
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['x', 'Performance'],
<%= CurrentData.first.chart_1_year%>
]);
// Create and draw the visualization.
new google.visualization.LineChart(document.getElementById('chart-1-year')).
draw(data, {curveType: "function",
width: 500, height: 400, title: "Performance 1 Year"
}
);
}
google.load(“可视化”,“1”,“{packages:[“corechart”]});
setOnLoadCallback(drawChart);
函数绘图图(){
//创建并填充数据表。
var data=google.visualization.arrayToDataTable([
['x','性能'],
]);
//创建并绘制可视化。
新的google.visualization.LineChart(document.getElementById('chart-1-year'))。
绘制(数据,{curveType:“函数”,
宽度:500,高度:400,标题:“性能1年”
}
);
}
我在浏览器上获得以下信息(使用Firebug):
演出
如果我从内部div中删除“position:absolute;”,它就可以正常工作
如何更改该位置设置?您不能创建一个“OnLoad”事件,使用javascript更改位置吗?类似于
document.getElementById('chart-1-year')。position='fixed'代码>?它更改了外部div,内部div仍然具有绝对位置。您可以尝试document.getElementById('chart-1-year')。div.position='fixed'代码>(设置1年期div图表中div的位置)?
<div class="row">
<div id="chart-1-year" style="position: relative;">
<div style="position: relative; width: 500px; height: 400px;" dir="ltr">
<div style="position: absolute; left: 0px; top: 0px; width: 100%; height: 100%;">
</div>
<div style="display: none; position: absolute; top: 410px; left: 510px; white-space: nowrap; font-family: Arial; font-size: 12px;">Performance</div>
</div>
</div>