这是工作融合图演示代码:
<?php
include("FusionCharts/FusionCharts.php");
?>
<HTML>
<HEAD>
<TITLE>
FusionCharts - Array Example using Single Series Column 3D Chart
</TITLE>
<SCRIPT LANGUAGE="Javascript" SRC="FusionCharts/FusionCharts.js"></SCRIPT>
<script type="text/javascript" language="JavaScript" src="FusionCharts/FusionChartsExportComponent.js"></script>
<script type="text/javascript" LANGUAGE="Javascript" SRC="FusionCharts/jquery.min.js"></script>
<script type="text/javascript" LANGUAGE="Javascript" SRC="FusionCharts/lib.js"></script>
<link href="FusionCharts/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript">
function ExportMyChart() {
var chartObject = getChartFromId('Results');
if( chartObject.hasRendered() ) chartObject.exportChart();
}
</script>
<style type="text/css">
<!--
body {
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
}
-->
</style>
</HEAD>
<BODY>
<CENTER>
<h2>FusionCharts Examples</h2>
<h4>Plotting single series chart from data contained in Array.</h4>
<?php
include("db_connect.php");
//In this example, we plot a single series chart from data contained
//in an array. The array will have two columns - first one for data label
//and the next one for data values.
//Let's store the sales data for 6 products in our array). We also store
//the name of products.
//Store Name of grades for x axis
$arrData[0][1] = "A";
//send + char to xml file////
$arrData[1][2] = str_replace('+', '%2B', 'A+');
$arrData[2][3] = "A-";
$arrData[3][4] = "B";
$arrData[4][5] = str_replace('+', '%2B', 'B+');
$arrData[5][6] = "B-";
$arrData[6][7] = "C";
$arrData[7][8] = str_replace('+', '%2B', 'C+');
$arrData[8][9] = "C-";
$arrData[9][10] = "D";
$arrData[10][11] = str_replace('+', '%2B', 'D+');
$arrData[11][12] = "E";
$arrData[12][13] = "AB";
$arrData[13][14] = "NE";
$arrData[14][15] = "MC";
//Store db data
// Fetch all records
$sql = "SELECT grade, COUNT(*) 'No_Of_grades' FROM std_results WHERE course_code ='CSC1113' GROUP BY grade ORDER BY grade ASC";
$result = mysql_query($sql) or die(mysql_error());
while($ors = mysql_fetch_array($result)) {
$grd=$ors['grade'];
switch ($grd)
{
case "A":
$arrData[0][16]=$ors['No_Of_grades'];
break;
case "A+":
$arrData[1][17]=$ors['No_Of_grades'];
break;
case "A-":
$arrData[2][18]=$ors['No_Of_grades'];
break;
case "B":
$arrData[3][19]=$ors['No_Of_grades'];
break;
case "B+":
$arrData[4][20]=$ors['No_Of_grades'];
break;
case "B-":
$arrData[5][21]=$ors['No_Of_grades'];
break;
case "C":
$arrData[6][22]=$ors['No_Of_grades'];
break;
case "C+":
$arrData[7][23]=$ors['No_Of_grades'];
break;
case "C-":
$arrData[8][24]=$ors['No_Of_grades'];
break;
case "D":
$arrData[9][25]=$ors['No_Of_grades'];
break;
case "D+":
$arrData[10][26]=$ors['No_Of_grades'];
break;
case "E":
$arrData[11][27]=$ors['No_Of_grades'];
break;
case "AB":
$arrData[12][28]=$ors['No_Of_grades'];
break;
case "NE":
$arrData[13][29]=$ors['No_Of_grades'];
break;
default:
$arrData[14][30]=$ors['No_Of_grades'];
}
}
//set vlaue zero for othe grades..
for($i=0;$i<15;$i++){
if(!isset($arrData[$i][31])){
$arrData[$i][32]=0;
}
}
//Now, we need to convert this data into XML. We convert using string concatenation.
//Initialize <chart> element
$strXML = "<chart caption='Exam result for CSC113A ' numberPrefix='' formatNumberScale='10' xAxisName='Grades' yAxisName='No Of Students' bgColor='995699,FEEFFF' exportEnabled='1' exportAtClient='0' exportAction='download' exportTargetWindow='_blank' exportHandler='http://www.fusioncharts.com/ExportHandlers/PHP/FCExporter.php' id='myChart'>";
//Convert data to XML and append
foreach ($arrData as $arSubData)
$strXML .= "<set label='" . $arSubData[1] . "' value='" . $arSubData[2] . "' />";
//Close <chart> element
$strXML .= "</chart>";
//Create the chart - Column 3D Chart with data contained in strXML
echo renderChart("FusionCharts/Column3D.swf", "", $strXML, "Results", 600, 300, false, false);
?>
<BR><BR>
<input type="button" value="Export My Chart" onclick="ExportMyChart()" />
</CENTER>
</BODY>
</HTML>
这段代码的输出是:!
然后我尝试编辑上面的代码以添加下载按钮以将这些图表导出为 imges/PDF 格式..但是这个下载按钮仍然没有显示给我。需要的下载按钮是:
然后我需要像这样得到最终输出:
我想将此下载按钮添加到我的图表中...我该怎么做???请帮助我...