pep*_*dip 10 html javascript google-visualization
我正在使用Google图表.定位让我望而却步.我没有在文档中找到该部分.我只想在div中创建一个Google图表,左上角位于div中的(x,y).有关控制尺寸的额外帮助.
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['2004', 1000, 400],
['2005', 1170, 460],
['2006', 660, 1120],
['2007', 1030, 540]
]);
var options = {
title: 'Company Performance',
hAxis: {title: 'Year', titleTextStyle: {color: 'red'}}
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
如果我使用像firebug这样的工具查看'运行时'中的html,我看到:
rect x="161" y="96" width="579" height="309"
Run Code Online (Sandbox Code Playgroud)
但我没有选择任何这些价值观.
Mar*_*zzi 13
例如,要将图表定位在DIV中的(0,0),请添加到图表选项:
var options = {
...,
chartArea:{left:0,top:0,width:"50%",height:"50%"}
}
Run Code Online (Sandbox Code Playgroud)
并根据需要调整宽度和高度; 完整的选择在这里.
| 归档时间: |
|
| 查看次数: |
11182 次 |
| 最近记录: |