PHPWrapper에서 MySQL/PHP를 사용하여 FusionCharts를 사용하고 있습니다. 2D 열 스택으로 렌더링되도록 데이터를 가져올 수 있었지만 제한이 붙어 있음에도 불구하고 7에서 멈추었습니다.Fusioncharts - 제한된 레코드를 표시하는 2D 열 스택
저는 4 월부터 11 월까지 매월 기록 수를 표시하는 데 사용하고 있지만, ASC에서 매월 데이터를 그룹화하면 5 월부터 첫 번째 스택이 시작됩니다. 흥미로운 점은 이것을 DESC로 변경하면 OCt-Apr (7 레코드)의 데이터가 표시되고 11 월 데이터가 누락된다는 것입니다. 나는 이것을 막을 수있는 한계를 정하지 못했지만, 아직 이것을 작동시킬 수는 있습니다.
MySQL의 데이터 세트 유형은 다음과 같습니다.
acqid - INT
acq_month - DATE
fusioncharts.php는 & 관련 JS가 제대로 파일의 부름.
아무도 도와 줄 수 있습니까?
감사합니다 !!!
다음은 내가 사용하고있는 코드입니다.
<?php
// Form the SQL query that returns the top 10 most populous countries
$strQuery = "SELECT count(acqid), acq_month FROM newacq GROUP BY MONTH(acq_month) ASC";
// Execute the query, or else return the error message.
$result = $conn->query($strQuery) or exit("Error code ({$conn->errno}): {$conn->error}");
$arr=mysqli_fetch_array($result);
//while($arr=mysqli_fetch_array($result)) {
// print_r($arr);
//}
// If the query returns a valid response, prepare the JSON string
if ($result) {
// The `$arrData` array holds the chart attributes and data
$arrData = array(
"chart" => array(
"caption" => "New Acq",
"showValues" => "1",
"theme" => "zune"
)
);
$arrData["data"] = array();
// Push the data into the array
while($row = mysqli_fetch_array($result)) {
array_push($arrData["data"], array(
"label" => date("M-Y", strtotime($row["acq_month"])),
"value" => $row["count(acqid)"],
)
);
}
/*JSON Encode the data to retrieve the string containing the JSON representation of the data in the array. */
$jsonEncodedData = json_encode($arrData);
/*Create an object for the column chart using the FusionCharts PHP class constructor. Syntax for the constructor is ` FusionCharts("type of chart", "unique chart id", width of the chart, height of the chart, "div id to render the chart", "data format", "data source")`. Because we are using JSON data to render the chart, the data format will be `json`. The variable `$jsonEncodeData` holds all the JSON data for the chart, and will be passed as the value for the data source parameter of the constructor.*/
$columnChart = new FusionCharts("column2D", "myFirstChart" , 820, 300, "chart-1", "json", $jsonEncodedData);
// Render the chart
$columnChart->render();
// Close the database connection
$conn->close();
}
?>
<div id="chart-1"><!-- Fusion Charts will render here--></div>
[print_r]을 사용하여 ARRAY에서 수행 된 세부 사항을 가져 오려고했는데 다음과 같은 메시지가 나타납니다.
Array ([0] => 208 [count(acqid)] => 208 [1] => 2017-04-01 [acq_month] => 2017-04-01) Array ([0] => 241 [count(acqid)] => 241 [1] => 2017-05-01 [acq_month] => 2017-05-01) Array ([0] => 243 [count(acqid)] => 243 [1] => 2017-06-01 [acq_month] => 2017-06-01) Array ([0] => 269 [count(acqid)] => 269 [1] => 2017-07-01 [acq_month] => 2017-07-01) Array ([0] => 373 [count(acqid)] => 373 [1] => 2017-08-01 [acq_month] => 2017-08-01) Array ([0] => 370 [count(acqid)] => 370 [1] => 2017-09-01 [acq_month] => 2017-09-01) Array ([0] => 283 [count(acqid)] => 283 [1] => 2017-10-01 [acq_month] => 2017-10-01) Array ([0] => 312 [count(acqid)] => 312 [1] => 2017-11-01 [acq_month] => 2017-11-01)
그것은 4 월 & 십일 포함을 위해 수행 된 정보를 표시한다. 도움이된다면!