gpt4 book ai didi

javascript - 谷歌图表点击全屏

转载 作者:行者123 更新时间:2023-12-01 02:32:02 25 4
gpt4 key购买 nike

有没有办法让 Google 图表在点击时全屏显示?

我已经研究这个好几个小时了

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>

http://jsfiddle.net/FbKEL/5/

非常感谢任何帮助。

最佳答案

你不能再调用一次drawChart吗?

$('#chart_div').on('click',function(e){
$(this).css({
width:"100%",
height:"100%",
margin:"0",
border:"none"
});
drawChart();
});

参见here

关于javascript - 谷歌图表点击全屏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14202553/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com