googlecarts API로 그려진 촛대 차트가 있습니다. 하지만 라이브 업데이트를 할 수 없습니다.
다음 코드는 내 차트 시각화의 html 부분입니다.
<script type='text/javascript'>
function drawV(){
var a = $.ajax({
url: "_ajax3.php",
dataType:"html",
async: false
}).responseText;
console.log(a);
var data = google.visualization.arrayToDataTable([a],true);
options = {
chartArea:{
left: 55,
top: 40,
width: 760,
height: 210
},
candlestick:{
fallingColor:{
fill: "#41a6ef",
stroke: "#41a6ef",
strokeWidth: 1
},
risingColor:{
fill: "#f01717",
stroke: "#f01717",
strokeWidth: 1
},
hollowIsRising: true
},
series: {0: {type: "candlesticks"}, 1: {type: "line", targetAxisIndex:1, color:"#91d6ff"}},
legend:"none"
};
chart = new google.visualization.ComboChart(document.getElementById("chart_div"));
chart.draw(data, options);
}
google.setOnLoadCallback(drawV);
setInterval(function(){
drawV();
}, 10000);
</script>
<div id='chart_div'></div>
나는 ajax dataType에서 확실하지 않지만 어쨌든 작동하는 경우 'var data = ...'줄은 다음과 같습니다.
var data = google.visualization.arrayToDataTable([["18:26",20.79102,20.79102,20.79102,20.79102,20.79102],["18:27",20.79102,20.85,20.79102,20.85,20.82051],["18:28",20.85,20.8583,20.85,20.8583,20.85415],
["18:26",20.79102,20.79102,20.79102,20.79102,20.79102]],true);
그리고 ajax는 동일한 데이터를 반환합니다 (고수준 []없이).
["18:26",20.79102,20.79102,20.79102,20.79102,20.79102],["18:27",20.79102,20.85,20.79102,20.85,20.82051],["18:28",20.85,20.8583,20.85,20.8583,20.85415],
["18:26",20.79102,20.79102,20.79102,20.79102,20.79102]
어떻게 작동시킬 수 있습니까? 편집 : 이제 다음 Java 오류가 발생합니다.Uncaught Error: Not a valid 2D array.
AJAX 호출이 유효한 JSON이 아닌 문자열을 반환하는 것 같습니다. 추가 서버 코드를 수정 [
하고 ]
문자열의 끝으로, 다음의 DataTable을 만들려면이를 사용 :
var data = google.visualization.arrayToDataTable(JSON.parse(a),true);
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다