고맙습니다. 두 번째 그래프를 볼 수 있지만 두 번째 그래프에는 데이터가 없으므로 빈 차트에 불과합니다. 이것은 내 PHP 코드입니다. 내가 도대체 뭘 잘못하고있는 겁니까? 내 코드 :ZingCharts를 MySQL에 연결하십시오 (라인 차트 작성)
<?php
/* Open connection to "zing_db" MySQL database. */
$mysqli = new mysqli("localhost", "root", "database123", "productno");
/* Check the connection. */
if (mysqli_connect_errno()) {
printf("Connect failed: %s\n", mysqli_connect_error());
exit();
}
?>
<script>
/* First line chart */
var myData=[<?php
$data=mysqli_query($mysqli,"SELECT * FROM records");
while($info=mysqli_fetch_array($data))
echo '["'.$info['Date'].'",'.$info['Alibaba'].'],'; /* Data is formatted here, using the . concatenation operator */
echo '[]'; /* We'll end up with a trailing comma, so we add an empty element here to pop off later*/
?>];
//--------- Second Line Chart ---------------
var myData1=[<?php
$data1=mysqli_query($mysqli,"SELECT * FROM records");
while($info1=mysqli_fetch_array($data1))
echo '["'.$info1['Date'].'",'.$info1['Lelong'].'],'; /* Data is formatted here, using the . concatenation operator */
echo '[]'; /* We'll end up with a trailing comma, so we add an empty element here to pop off later*/
?>];
<?php
/* Close the connection */
$mysqli->close();
?>
myData.pop(); /* Pop off the final, empty element from the myData array */
//Display first line chart
window.onload=function(){
zingchart.render({
id:"AlibabaChart",
width:"100%",
height:300,
data:{
"type":"line",
"title":{
"text":"Alibaba"
},
"series":[
{
"values":myData
}
]
}
});
//Display second line chart
zingchart.render({
id:"LelongChart",
width:"100%",
height:300,
data:{
"type":"line",
"title":{
"text":"Lelong"
},
"series":[
{
"values":myData1
}
]
}
});
};
</script>
FYI 데이터가 동일한 테이블을 x 값 및 데이터베이스하지만 다른 컬럼 (Y 값)로한다. 감사!
내 게시물을 수정했습니다. 조금 도와 드릴까요? 감사합니다 – Cael
안녕 Cael, 나는 내 대답을 편집했습니다, 그것을 확인하십시오! – Stalfos
고마워요.하지만 여전히 문제가 있습니다. (내 게시물 참조) – Cael