0
我製作了融合圖表,我添加了3個鏈接來顯示圖表,但我想一次顯示一張圖表,我如何做到這一點?我製作融合圖表,並添加3個鏈接以顯示圖表,但我想要顯示一張圖表?一時間,我怎麼做到這一點,這裏是我的代碼:如何使用多個圖表數據來顯示fusionchart?
<?php
$title='Product Management';
include("merchantheader.php");
include("DBConn.php");
include("FusionCharts.php");
$link = connectToDB();
$strQuery="select Distinct DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y') as transaction_date,sum(amount)as Amount from transactions group by DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y')";
$result = mysql_query($strQuery) or die(mysql_error());
$strXML = "<chart caption='Reports of transactions' showValues='0' useRoundEdges='1' palette='3'>";
while($ors = mysql_fetch_assoc($result)){
//Generate <set label='..' value='..' />
$strXML .= "<set label='" .$ors['transaction_date'] ."' value='" . $ors['Amount'] ."' />";
}
//free the result set
//mysql_free_result($result);
//mysql_close($link);
//Finally, close <chart> element
$strXML .= "</chart>";
//date_default_timezone_set($_SESSION['timezone']);
?>
<?php
$query="SELECT Min(transaction_date) as start,Max(transaction_date) as end from transactions";
$result1= mysql_query($query) or die(mysql_error());
$ors1=mysql_fetch_array($result1);
$startdate= $ors1['start'];
$enddate=$ors1['end'];
?>
<?php
function past7days(){
$strQuery="select Distinct DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y') as transaction_date,sum(amount)as Amount from transactions where transaction_date BETWEEN current_date()-7 AND current_date() group by DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y')";
$result = mysql_query($strQuery1) or die(mysql_error());
$strXML = "<chart caption='Reports of transactions' showValues='0' useRoundEdges='1' palette='3'>";
while($ors = mysql_fetch_assoc($result)){
//Generate <set label='..' value='..' />
$strXML .= "<set label='" .$ors['transaction_date'] ."' value='" . $ors['Amount'] ."' />";
}
//free the result set
//mysql_free_result($result);
//mysql_close($link);
//Finally, close <chart> element
$strXML .= "</chart>";
//date_default_timezone_set($_SESSION['timezone']);
}
function past14days(){
$strQuery="select Distinct DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y') as transaction_date,sum(amount)as Amount from transactions where transaction_date BETWEEN current_date()-14 AND current_date() group by DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y')";
$result = mysql_query($strQuery1) or die(mysql_error());
$strXML = "<chart caption='Reports of transactions' showValues='0' useRoundEdges='1' palette='3'>";
while($ors = mysql_fetch_assoc($result)){
//Generate <set label='..' value='..' />
$strXML .= "<set label='" .$ors['transaction_date'] ."' value='" . $ors['Amount'] ."' />";
}
//free the result set
//mysql_free_result($result);
//mysql_close($link);
//Finally, close <chart> element
$strXML .= "</chart>";
//date_default_timezone_set($_SESSION['timezone']);
}
function past30days(){
$strQuery="select Distinct DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y') as transaction_date,sum(amount)as Amount from transactions where transaction_date BETWEEN current_date()-30 AND current_date() group by DATE_FORMAT(transactions.transaction_date,'%c-%d-%Y')";
$result = mysql_query($strQuery1) or die(mysql_error());
$strXML = "<chart caption='Reports of transactions' showValues='0' useRoundEdges='1' palette='3'>";
while($ors = mysql_fetch_assoc($result)){
//Generate <set label='..' value='..' />
$strXML .= "<set label='" .$ors['transaction_date'] ."' value='" . $ors['Amount'] ."' />";
}
//free the result set
//mysql_free_result($result);
//mysql_close($link);
//Finally, close <chart> element
$strXML .= "</chart>";
//date_default_timezone_set($_SESSION['timezone']);
}
?>
<!-- Include FusionCharts.js to provide client-side interactivity -->
<script type="text/javascript" src="<?=MURL?>/Charts/FusionCharts.js"></script>
<link href="<?=MURL?>/assets/ui/css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?=MURL?>/assets/ui/js/jquery.min.js"></script>
<script type="text/javascript" src="<?=MURL?>/assets/ui/js/lib.js"></script>
<h1 style="margin-top:24px;"><?=ucfirst($_GET['page5'])?><? if($_POST['mode']=='test' || $_GET['mode']=='test') { print " (Test Mode)"; } ?></h1>
<p class="right_align">
<!--<a href="/merchant/products/1/manage/transactions?cmd=search&mode=<?=$_GET['mode']?>" class="blink search">Search</a>
<a href="javascript:void(0)" class="blink refresh" onclick="location.reload();">Refresh</a>-->
<a href="/merchant/products/1/manage/reports?cmd=compare&mode=<?=$_GET['mode']?>" class="blink chart" >Compare Events</a>
</p>
<p align="left" style="color:#000"><?php echo date('M dS Y' ,strtotime($startdate)); ?> to <?php echo date('M dS Y' ,strtotime($enddate)); ?><a href="#" style="color:#00F; margin-left:15px; text-decoration:underline">Past 7 Days</a><a href="#" style="color:#00F; margin-left:15px; text-decoration:underline">Past 14 Days</a><a href="#" style="color:#00F; margin-left:15px; text-decoration:underline">Past 30 Days</a><a href="#" style="color:#00F; margin-left:15px; text-decoration:underline">Set A Custom Data Range</a><span class="right_float links">
MODE
<select id="mode" name="mode">
<option value="live">Live</option>
<option value="test">Test</option>
</select>
</span></p>
<div id="chartContainer">
<?php
FC_SetRenderer('javascript');
echo renderChart('Charts/Line.swf', // Path to chart type
'', // Empty string when using Data String Method
$strXML, // Variable that contains XML string
'Tracking', // Unique chart ID
'850', '400', // Width and height in pixels
false, // Disable debug mode
true // Enable 'Register with JavaScript' (Recommended)
);
?>
</div>