eljamz

Vtrendlines Not Working With Datetime Value From Mysql In Zoomline.

Recommended Posts

I cant get the vTrendlines to work with datetime value from MySQL in ZoomLine, i really need help i have tryed all the things...

 

heres my example code:

 

 

<vTrendLines>
	   <line startValue='2011-01-09-00:17:06' endValue='2011-01-10-00:17:06' alpha='5' color='00FF00' />
</vTrendLines>

 

 

I really hope some one can help me or maybe give me some idea to fix this problem... everything else its working, also de vline's... any idea?

 

thanks in advance...

Share this post


Link to post
Share on other sites
Guest Angie

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

Could you please send us the entire XML code to look into the issue?

 

Awaiting for your reply.

Share this post


Link to post
Share on other sites

Hi,

 

Welcome to FusionCharts Forum!smile.gif

 

Could you please send us the entire XML code to look into the issue?

 

Awaiting for your reply.

 

Sure, heres all my php code, it also gets data from mysql for all the other things and it works perfetc, thats the only think i cant get it to work...

 

 


<?php
//We've included FusionCharts.php API
include("FusionCharts.php");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
   <head>
       <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
       <title>ESM Industries - Reporteador</title>
       <link rel="stylesheet" href="stylesheet/reporter.css" type="text/css" />
	<link rel="stylesheet" href="stylesheet/thickbox.css" type="text/css" media="screen" />
	<script type="text/javascript" src="javascript/calendarDateInput.js"></script>
       <script type="text/javascript" SRC="javascript/FusionCharts.js"></script>
	<script type="text/javascript" src="javascript/jquery.js"></script>
	<script type="text/javascript" src="javascript/thickbox.js"></script>

   </head>
   <body>
<?php
       //Get data from post
	$dataPost = $_POST["data"];
	$datesValid = $_POST["dateFrom"];

	if ($datesValid == "") {
		$dateFrom = "";
		$dateTo = "";
	} else {
		$dateFrom = $_POST["dateFrom"] . " 00:00:01";
		$dateTo = $_POST["dateTo"] . " 23:59:59";
	}


	if ($dateFrom == "") {
		$xAxisNamearr = "Datos de Hoy";
	} else {
		$xAxisNamearr = "Informacion desde el " . $dateFrom . " hasta el " . $dateTo;
	}

	//Generate a default value for post if its blank
	if ($dataPost == "") {
		$dataPost = "Voltaje";
	}

	//Switch function for all the app
	switch  ($dataPost) {
		case ($dataPost == "Voltaje"):
			$dataPostarr = "tensao1, tensao2, tensao3";
			$fase1 = "tensao1";
			$fase2 = "tensao2";
			$fase3 = "tensao3";
			$caption = "Voltaje";
			$xAxisName = $xAxisNamearr;
			$yAxisName = "Voltaje";
		break;
		case ($dataPost == "Corriente"):
			$dataPostarr = "corren1, corren2, corren3";
			$fase1 = "corren1";
			$fase2 = "corren2";
			$fase3 = "corren3";
			$caption = "Amperaje";
			$xAxisName = $xAxisNamearr;
			$yAxisName = "Amperaje";
		break;
		case ($dataPost == "KwTrifasicos"):
			$dataPostarr = "ativatri";
			$caption = "Kw Trifasicos";
			$xAxisName = $xAxisNamearr;
			$yAxisName = "Medicion en Kw";
		break;
		case ($dataPost == "KvarTrifasicos"):
			$dataPostarr = "reativatri";
			$caption = "Kvar Trifasicos";
			$xAxisName = $xAxisNamearr;
			$yAxisName = "Medicion en Kvar";
		break;
		case ($dataPost == "KvaTrifasicos"):
			$dataPostarr = "aparentetri";
			$caption = "Kva Trifasicos";
			$xAxisName = $xAxisNamearr;
			$yAxisName = "Medicion en Kva";
		break;
		case ($dataPost == "FactordePotencia"):
			$dataPostarr = "fatpottri";
			$caption = "Factor de Potencia";
			$xAxisName = $xAxisNamearr;
			$yAxisName = "Medicion en Kw";
		break;
	}

	//Make connection to the Data Base
		$con = mysql_connect(*******************************************************);
			if (!$con)
		  	{
		  	die('No se pudo conectar: ' . mysql_error());
		  	}
		mysql_select_db("esmindustries", $con);

	// Generate the Query's for both data and date
	if ($dateFrom == "") {
		$dataqry = mysql_query("SELECT $dataPostarr FROM controladores WHERE DATE(date) = DATE(NOW())") or die ("select died: " . mysql_error());
		$dateqry = mysql_query("SELECT date FROM controladores WHERE DATE(date) = DATE(NOW())") or die ("select died: " . mysql_error());
	} else {
		$dataqry = mysql_query("SELECT $dataPostarr FROM controladores where date BETWEEN '$dateFrom' and '$dateTo'") or die ("select died: " . mysql_error());
		$dateqry = mysql_query("SELECT date FROM controladores where date BETWEEN '$dateFrom' and '$dateTo'") or die ("select died: " . mysql_error());
	}

	// Get total of records
		$tr_dataqry = mysql_num_rows($dataqry);
		$tr_dateqry = mysql_num_rows($dateqry);

	// Run the loop fo the results
		for($i = 0; $i < $tr_dataqry; $i++) 
		$arrData[$i] = mysql_fetch_array($dataqry);
		for($i = 0; $i < $tr_dateqry; $i++) 
		$dateData[$i] = mysql_fetch_array($dateqry);
		//print_r ($arrData);
		//echo $dataPost;


  //Now, we need to convert this data into multi-series XML. 
  //We convert using string concatenation.
  // $strXML - Stores the entire XML
  // $strDates - Stores XML for the <categories> and child <category> elements
  // $strDataTri and $strDataFases - For the data

      	//Initialize <chart> element
       $strXML = "<chart labelStep='5' btnResetChartTitle='Estado Original' btnSwitchToPinModeTitle='Modo de Seleccion' btnSwitchToZoomModeTooltext='Modo de Zoom' btnSwitchToPinModeTooltext='Modo de Seleccion' numberPrefix='' caption='". $caption ."' subCaption='Ginequito' xAxisName='". $xAxisName ."' yAxisName='". $yAxisName ."'>";

      	//Initialize <categories> element - necessary to generate a multi-series chart
      	$strDates = "<categories>";

      	//Initiate <dataset> elements
       if ($dataPost == "Voltaje" || $dataPost == "Corriente") {
			$strDataFase1 = "<dataset seriesName='Fase 1'>";
			$strDataFase2 = "<dataset seriesName='Fase 2'>";
			$strDataFase3 = "<dataset seriesName='Fase 3'>";
       } else {
			$strDataTri = "<dataset seriesName='Trifasico'>";
       }

      	//Iterate through the data
      	foreach ($dateData as $dateSubData) {

      	//Append <category name='...' /> to strDates
      	$strDates .= "<category name='" . $dateSubData[date] . "' />";
       }

      	//Add <set value='...' /> tothe datasest
	       foreach ($arrData as $arSubData) {
		       if ($dataPost == "Voltaje") {
				       $strDataFase1 .= "<set value='" . ($arSubData[$fase1] / 10) . "' />";
				       $strDataFase2 .= "<set value='" . ($arSubData[$fase2] / 10) . "' />";
				       $strDataFase3 .= "<set value='" . ($arSubData[$fase3] / 10) . "' />";
		       } elseif ($dataPost == "Corriente") {
				       $strDataFase1 .= "<set value='" . ($arSubData[$fase1] / 1000) . "' />";
				       $strDataFase2 .= "<set value='" . ($arSubData[$fase2] / 1000) . "' />";
				       $strDataFase3 .= "<set value='" . ($arSubData[$fase3] / 1000) . "' />";
		       } elseif ($dataPost == "KwTrifasicos") {     
				       $strDataTri .= "<set value='" . ($arSubData[$dataPostarr] / 1000) . "' />";
		       } elseif ($dataPost == "KvaTrifasicos") {     
				       $strDataTri .= "<set value='" . ($arSubData[$dataPostarr] / 1000) . "' />";
		       } else {
				       $strDataTri .= "<set value='" . ($arSubData[$dataPostarr] / 100) . "' />";
		       }
	       }

      	//Close <categories> element
      	$strDates .= "</categories>";

       $strZones .= "
       <vTrendLines>
       <line startValue='2011-01-09-00:17:06' endValue='2011-01-10-00:17:06' alpha='30' color='00FF00' />
       </vTrendLines>
       <trendLines><line startValue='30' color='FF0000' displayValue='Promedio' valueOnRight='1' /></trendLines>";
       //

       //Close <dataset> elements
       if ($dataPost == "Voltaje" || $dataPost == "Corriente") {
			$strDataFase1 .= "</dataset>";
			$strDataFase2 .= "</dataset>";
			$strDataFase3 .= "</dataset>";
       } else {
	    	$strDataTri .= "</dataset>";
       }

      	//Assemble the entire XML now
       if ($dataPost == "Voltaje" || $dataPost == "Corriente") {
			$strXML .= $strDates . $strZones . $strDataFase1 . $strDataFase2 . $strDataFase3 . "</chart>";
       } else {
	    	$strXML .= $strDates . $strDataTri . "</chart>";
       }


       ?>
	<div id="wrapper">

           <div class="content-area">
               <div id="content-area-inner-main">
			<center>
			<br />
			<img src="/esm_logob.png" /> <br /><br />Reporteador<br /><br /><br />
			<table width="900" cellspacing="0" cellpadding="0" border="0">
			<tr>
			<form method="post">
				<td>Desde </td>
				<td><script>DateInput('dateFrom', true, 'YYYY-MM-DD')</script></td> 
				<td>Hasta </td>
				<td><script>DateInput('dateTo', true, 'YYYY-MM-DD')</script></td>

			<td width="450">
			<div align="right">
					<select name="data" onchange='this.form.submit()'>
				  	<option value="Voltaje"<?php if ($dataPost == "Voltaje") echo " selected"; ?>>Voltaje</option>
				  	<option value="Corriente"<?php if ($dataPost == "Corriente") echo " selected"; ?>>Corriente</option>
				  	<option value="KwTrifasicos"<?php if ($dataPost == "KwTrifasicos") echo " selected"; ?>>Kw Trifasicos</option>
				  	<option value="KvarTrifasicos"<?php if ($dataPost == "KvarTrifasicos") echo " selected"; ?>>Kvar Trifasicos</option>
				  	<option value="KvaTrifasicos"<?php if ($dataPost == "KvaTrifasicos") echo " selected"; ?>>Kva Trifasicos</option>
				  	<option value="FactordePotencia"<?php if ($dataPost == "FactordePotencia") echo " selected"; ?>>Factor de Potencia</option>
					</select>
				</form>
			</div>
			</td>
			</tr>
			</table>

	<div class="chart-disp-block" style="width:900px;margin:0 auto">
	<?php
      	echo renderChart("swf/ZoomLine.swf", "", $strXML, "ESMReporter", 900, 400, false, true);
       ?>
       </div>
                   </div>
                   <div class="clear"></div>
                   <p> </p>

       </div>
	</center>
	<center>
	<table width="900" cellspacing="0" cellpadding="0" border="0">
	<tr><td>
		<?php 
			$today = date('Y-m-d'); 

			if ($datesValid == "") {
				$dateFrom = $today . " 00:00:01";
				$dateTo = $today . " 23:59:59";
			}


		?>
		<div align="right"><a href="reporte.php?height=480&width=900<?php echo "&dataPost=" . $dataPost . "&dateFrom=" . $dateFrom . "&dateTo=" . $dateTo; ?>" title="Reporte de <?php echo $xAxisNamearr; ?>" class="thickbox">Generar Reporte</a></div>

	</td></tr>
	</table>
	</center>
   </body>
</html>

Edited by eljamz

Share this post


Link to post
Share on other sites
Guest Angie

Hi,

 

Could you please send us the generated XML code to look into the issue?

 

Awaiting for your reply.

Share this post


Link to post
Share on other sites

Hi,

 

Could you please send us the generated XML code to look into the issue?

 

Awaiting for your reply.

 

 

Heres the file as an attach...

 

 

also you can see it live in ( http://www.esmindust...om/reporteador/ )

Just choose in the date junary 9 to junary 11 of 2011 and also choose "voltaje" from the right popup menu...

 

any other date will not work, thats just a test before go live...

rendered-text.zip

Edited by eljamz

Share this post


Link to post
Share on other sites

Ok, i just do a simple XML like the one I'm using and still not working... heres my simple XML. and im working with ZoomLine.swf

 

I just change the datetime for simple values... still not working :S

 


<chart labelStep='1' btnResetChartTitle='Estado Original' btnSwitchToPinModeTitle='Modo de Seleccion' btnSwitchToZoomModeTooltext='Modo de Zoom' btnSwitchToPinModeTooltext='Modo de Seleccion' numberPrefix='' caption='Factor de Potencia' subCaption='Ginequito' xAxisName='Datos de Hoy' yAxisName='Medicion en Kw'>

  <categories verticalLineColor='666666' verticalLineThickness='1'>
     <category label='20' x='20' showVerticalLine='1'/>
     <category label='30' x='30' showVerticalLine='1'/>
     <category label='40' x='40' showVerticalLine='1'/>
     <category label='50' x='50' showVerticalLine='1'/>
     <category label='60' x='60' showVerticalLine='1'/>
     <category label='70' x='70' showVerticalLine='1'/>
     <category label='80' x='80' showVerticalLine='1'/>
     <category label='90' x='90' showVerticalLine='1'/>
     <category label='100' x='100' showVerticalLine='0'/>
  </categories>

  <dataset seriesName='Trifasico' color='009900'>
     <set value='131.7' />
     <set value='129' />
     <set value='130.7' />
     <set value='128' />
     <set value='131.7' />
     <set value='129' />
     <set value='129.5' />
     <set value='131' />
     <set value='130' />
     <set value='130.5' />
     <set value='129' />
     <set value='129.9' />

  </dataset>


  <vTrendlines>
     <line startValue='20' endValue='65' alpha='5' color='00FF00' />
     <line startValue='65' endValue='75' alpha='15' color='FFFF00' />
     <line startValue='75' endValue='100' alpha='15' color='FF0000' />
  </vTrendlines>

  <trendlines>
     <line startValue='131' displayValue='Promedio' lineThickness='2' color='FF0000' valueOnRight='1' dashed='1' dashGap='5'/>
  </trendlines>

</chart>

Edited by eljamz

Share this post


Link to post
Share on other sites

Hi,

 

Please note that the XML format you have mentioned here partially resembles the XML format of Scatter chart. This is not the ZoomLine chart's XML. :)

 

For the correct ZoomLine chart XML format and <vTrendLines> element, please refer to the following link and re-check with the attributes supported.

http://www.fusioncha...S/ZoomLine.html

http://www.fusioncharts.com/docs/ChartSS/ZoomLine.html#Anchor17

 

Hope this helps. :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now