有没有办法在点击时制作Google Chart全屏?
我已经玩了好几个小时了
JS -
$('#chart_div').on('click', function(e) {
$(this).css({
width: "100%",
height: "100%",
margin: "0",
border: "none"
});
});
CSS -
#chart_div {
width: 100 px;
height: 100 px;
margin: 20 px;
background - color: red;
border: 1 px solid black;
}
body, html {
height: 100 % ;
}
HTML - 您可以根据条款自由复制和使用此样本 Apache许可证(http://www.apache.org/licenses/LICENSE-2.0.html)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>
Google Visualization API Sample
</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1', {
packages: ['corechart']
});
</script>
<script type="text/javascript">
google.load("visualization", "1", {
packages: ["corechart"]
});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Year', 'Sales', 'Expenses'],
['November', 1000, 400],
['December', 1170, 460],
['January', 660, 1120],
['February', 690, 1120],
['March', 780, 1120],
['April', 820, 1120],
['May', 660, 1120],
['June', 1030, 540]
]);
var options = {
title: '',
backgroundColor: 'none',
legend: {
position: 'none'
},
hAxis: {
title: 'Year',
titleTextStyle: {
color: 'grey'
}
},
chartArea: {
left: 40,
top: 10,
width: 900,
height: 350
}
};
var chart = new google.visualization.AreaChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
$('#chart_div').on('click', function(e) {
$(this).css({
width: "100%",
height: "100%",
margin: "0",
border: "none"
});
});
</script>
</head>
<body style="font-family: Arial;border: 0 none;">
<div id="chart_div"></div>
</body>
</html>
非常感谢任何帮助。
答案 0 :(得分:7)
你不能再次调用drawChart吗?
$('#chart_div').on('click',function(e){
$(this).css({
width:"100%",
height:"100%",
margin:"0",
border:"none"
});
drawChart();
});
请参阅here