Reputation: 121
I am using trendlines for my line chart. But it is not visible in my browser.Can anyone tell me the reason for this. Below i am giving code:
<?php
include("Includes/FusionCharts.php");
include("Includes/DBconn.php");
include("Includes/FC_Colors.php");
?>
<html>
<title> Blood Pressure</title>
<head>
<script language="javascript" src="FusionCharts/FusionChart.js"></script>
</head>
<body>
<center>
<?php
//connect to the DB
$link= connectToDB();
$query = "select * from patient_health order by ondate";
$result=mysql_query($query)or die(mysql_error());
//echo $result;
$strXML = "<graph caption='Blood Pressure Reading' subCaption='Month wise' xaxisname='Current Month' yaxisname='Blood Pressure(Systolic/diastole)' yAxisMaxValue='400'
animation='1' rotatenames='1'>";
$categories = "<categories>";
$systolic = "<dataset seriesName='systole'>";
$diaolic = "<dataset seriesName='diastole'>";
while ($row = mysql_fetch_array($result)) {
$categories .= "<category name='" . $row["ondate"] . "' />";
$systolic .= "<set color='AFD8F8' value='" . $row["systole_reading"] . "' hoverText='systolic' />";
$diaolic .= "<set value='" . $row["diastole_reading"] . "' color='FEDCBC' hoverText='diastolic'/>";
}
$strXML .= $categories . "</categories>" . $systolic . "</dataset>" . $diaolic . "</dataset>" . "</graph>";
**$strXML .=" <trendlines>
<line startValue='140' color='91C728' displayValue='Target' showOnTop='1'/>
</trendlines>";**
//$strXML now has the complete XML required to render the multi-series chart.
//Create the chart - Pie 3D Chart with data from $strXML
echo renderChartHTML("FusionCharts/FCF_MSLine.swf", "", $strXML, "BloodPressure", 850, 450,false);
//echo renderChartHTML("FusionCharts/FCF_MSBar2D.swf", "", $strXML, "BloodPressure", 850, 450,false);
?>
</center>
</body>
</html>
Did i place the code correctly or i have to change it . Can anyone please give me solution
Thank you in advance Ramsai
Upvotes: 0
Views: 956
Reputation: 3512
It seems that in your code, you are closing the <graph>
tag before adding <trendlines>
!
Correct code would be:
$strXML .= $categories . "</categories>" . $systolic . "</dataset>" . $diaolic . "</dataset>";
$strXML .=" <trendlines>
<line startValue='140' color='91C728' displayValue='Target' showOnTop='1'/>
</trendlines>" . "</graph>";
Upvotes: 1
Reputation: 12447
The code for the trend lines should come before you close the graph element, i.e., before
</graph>
.
As I've illustrated below:
}
**$strXML .=" <trendlines>
<line startValue='140' color='91C728' displayValue='Target' showOnTop='1'/>
</trendlines>";**
$strXML .= $categories . "</categories>" . $systolic . "</dataset>" . $diaolic . "</dataset>" . "</graph>";
This should show your trend lines.
Upvotes: 1