gpt4 book ai didi

javascript - 谷歌条形图动画

转载 作者:行者123 更新时间:2023-11-30 00:28:40 25 4
gpt4 key购买 nike

我正在尝试制作此条形图的动画,但它似乎不起作用。此条形图代表实时数据并每 2-3 秒更新一次。我想添加缓动,以便它看起来很好。如果有人能帮我修复动画那就太好了。谢谢

图表看起来像这样; Bar Chart

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<html>
<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>MindStream Visual Chart</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">

google.load("visualization", "1.1", {packages:["bar"]});


google.setOnLoadCallback(drawChart);

function drawChart() {


var data2 = google.visualization.arrayToDataTable([
['EEG Power', 'High Gamma', 'Low Gamma', 'Theta', 'High Alpha', 'Low Alpha', 'Low Beta', 'High Beta','Delta'],
['Real Time Data', 0, 0, 0, 0, 0, 0, 0, 0]
]);


var chart2 = new google.charts.Bar(document.getElementById('chart_div2'));


var bli;
var att;
var med;

var highGamma;
var lowGamma;
var theta;
var lowAlpha;
var highAlpha;
var lowBeta;
var highBeta;
var delta;


// ajax
setInterval(function() {
$.ajax({
type : 'get',
url : 'jsonProvider',
data : '',
dataType : 'json',
encode : true
}).done(function( data ) {

console.log(data);
// console.log(data['eSense'].attention+" "+data['eSense'].meditation+" "+data['eSense'].blinkStrength);

att=data['eSense'].attention;
med=data['eSense'].meditation;
bli = data['eSense'].blinkStrength;
highGamma = (data['eegPower'].highGamma != null) ? data['eegPower'].highGamma : 0 ;
lowGamma = ( data['eegPower'].lowGamma != null) ? data['eegPower'].lowGamma : 0 ;
theta = (data['eegPower'].theta != null) ? data['eegPower'].theta : 0 ;
lowAlpha = (data['eegPower'].lowAlpha != null) ? data['eegPower'].lowAlpha : 0 ;
highAlpha = (data['eegPower'].highAlpha != null) ? data['eegPower'].highAlpha : 0 ;
lowBeta = (data['eegPower'].lowBeta != null) ? data['eegPower'].lowBeta : 0 ;
highBeta = (data['eegPower'].highBeta != null) ? data['eegPower'].highBeta : 0 ;
delta = (data['eegPower'].delta != null) ? data['eegPower'].delta : 0 ;

});




data2 = google.visualization.arrayToDataTable([
['EEG Power', 'High Gamma', 'Low Gamma', 'Theta', 'High Alpha', 'Low Alpha', 'Low Beta', 'High Beta','Delta'],
['Real Time Data', highGamma, lowGamma, theta, highAlpha, lowAlpha, lowBeta, highBeta, delta]
]);

var options2 = {
chart: {
title: 'EEG Power',
subtitle: 'High Gamma, Low Gamma, Theta, High Alpha, Low Alpha, Low Beta, High Beta, Delta'},
animation: {duration: 1000, easing: 'out'}
};


chart2.draw(data2, options2);

});




}
</script>



</head>
<body>


<table>
<tr>
<td class="container">
<div id="chart_div2" style="width: 800px; height: 700px;float: left;"></div>
</td>

</table>


</body>
</html>

最佳答案

尝试将 startup: true 添加到您的选项中,这样它看起来像:

动画:{duration: 1000, easing: 'out', startup:true}

关于javascript - 谷歌条形图动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30449357/

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