Sign in to follow this  
malli08

Adding Historical Data In Jsp

Recommended Posts

Hi, I am using this jar file to generate a live demo which will show the current data and data hitoric data. i worked on basic example but it is not showing historic data. my code is

Index.jsp

--------------------------------

 

<div id="chartContainer">FusionCharts will load here!</div>

<script type="text/javascript"><!--

     var myChart =  new FusionCharts("FusionChart/RealTimeLine.swf","myChartId", "400", "300","0","1","#bbbe6");
     myChart.setXMLUrl("Data.xml");
     myChart.render("chartContainer");
   -->
   </script>

 

 

 

StockPrice.jsp

-----------------------------------------------------

 

<%
       int lowerLimit = 30;
       int upperLimit = 35;
       double randomValue = Math.random()*100*(upperLimit-lowerLimit)/100+lowerLimit;
       long factor = (long)Math.pow(10,2);
       randomValue = randomValue * factor;
       long tmp = Math.round(randomValue);
       double roundedRandomValue=(double)randomValue / factor;
       Calendar cal = Calendar.getInstance();
       SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
       String timeLabel = sdf.format(cal.getTime());
       String dataParameters = "&label=" +timeLabel+ "&value=" +roundedRandomValue+"&";
       System.out.println(dataParameters);
       out.print(dataParameters);
 %>

 

 

Data.xml

--------------------------------------------------------

 

<?xml version="1.0" encoding="windows-1252" ?>
<chart caption="Stock Price Monitor" subCaption="NIBM" dataStreamURL="StockPrice.jsp" 
   refreshInterval="3" numberPrefix="$" setAdaptiveYMin="1" xAxisName="Time" showRealTimeValue="1" labelDisplay="Rotate" slantLabels="1" canvasLeftMargin="50" numDisplaySets="20">
<categories>
 <categories label="15 Senods before"/>
 <categories label="12 Senods before"/>
 <categories label="9 Senods before"/>
 <categories label="6 Senods before"/>
 <categories label="3 Senods before"/>
</categories>
 <dataset seriesName="ForEx" showValues="0" color='FF8000'>
   <set value="32.34"/>
   <set value="32.34"/>
   <set value="34.75"/>
   <set value="33.34"/>
   <set value="33.65"/>
 </dataset>
 <styles>
   <definition>
     <style type="font" name="captionFont" size="14"/>
   </definition>
   <application>
     <apply toObject="Realtimevalue" styles="captionFont"/>
   </application>
 </styles>
</chart>

 

 

It is showing only current data, it is not showing historic data...

thanks in advance

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi, I am using this jar file to generate a live demo which will show the current data and data hitoric data. i worked on basic example but it is not showing historic data. my code is

Index.jsp

--------------------------------

 

<div id="chartContainer">FusionCharts will load here!</div>

<script type="text/javascript"><!--

     var myChart =  new FusionCharts("FusionChart/RealTimeLine.swf","myChartId", "400", "300","0","1","#bbbe6");
     myChart.setXMLUrl("Data.xml");
     myChart.render("chartContainer");
   -->
   </script>

 

 

 

StockPrice.jsp

-----------------------------------------------------

 

<%
       int lowerLimit = 30;
       int upperLimit = 35;
       double randomValue = Math.random()*100*(upperLimit-lowerLimit)/100+lowerLimit;
       long factor = (long)Math.pow(10,2);
       randomValue = randomValue * factor;
       long tmp = Math.round(randomValue);
       double roundedRandomValue=(double)randomValue / factor;
       Calendar cal = Calendar.getInstance();
       SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
       String timeLabel = sdf.format(cal.getTime());
       String dataParameters = "&label=" +timeLabel+ "&value=" +roundedRandomValue+"&";
       System.out.println(dataParameters);
       out.print(dataParameters);
 %>

 

 

Data.xml

--------------------------------------------------------

 

<?xml version="1.0" encoding="windows-1252" ?>
<chart caption="Stock Price Monitor" subCaption="NIBM" dataStreamURL="StockPrice.jsp" 
   refreshInterval="3" numberPrefix="{:content:}quot; setAdaptiveYMin="1" xAxisName="Time" showRealTimeValue="1" labelDisplay="Rotate" slantLabels="1" canvasLeftMargin="50" numDisplaySets="20">
<categories>
 <categories label="15 Senods before"/>
 <categories label="12 Senods before"/>
 <categories label="9 Senods before"/>
 <categories label="6 Senods before"/>
 <categories label="3 Senods before"/>
</categories>
 <dataset seriesName="ForEx" showValues="0" color='FF8000'>
   <set value="32.34"/>
   <set value="32.34"/>
   <set value="34.75"/>
   <set value="33.34"/>
   <set value="33.65"/>
 </dataset>
 <styles>
   <definition>
     <style type="font" name="captionFont" size="14"/>
   </definition>
   <application>
     <apply toObject="Realtimevalue" styles="captionFont"/>
   </application>
 </styles>
</chart>

 

 

It is showing only current data, it is not showing historic data...

thanks in advance

 

Hi,

 

Can you please share the screen shot of the same?

Share this post


Link to post
Share on other sites
Guest Bindhu

Hi,

 

Please modify the XML data as below,

 

<chart caption="Stock Price Monitor" subCaption="NIBM" dataStreamURL="StockPrice.jsp" 
refreshInterval="3" numberPrefix="$" setAdaptiveYMin="1" xAxisName="Time" showRealTimeValue="1" labelDisplay="Rotate" slantLabels="1" canvasLeftMargin="50" numDisplaySets="20">
<categories>
 <category label="15 Senods before"/>
 <category label="12 Senods before"/>
 <category label="9 Senods before"/>
 <category label="6 Senods before"/>
 <category label="3 Senods before"/>
</categories>
 <dataset seriesName="ForEx" showValues="1" color='FF8000'>
<set value="32.34"/>
<set value="32.34"/>
<set value="34.75"/>
<set value="33.34"/>
<set value="33.65"/>
 </dataset>
 <styles>
<definition>
 	<style type="font" name="captionFont" size="14"/>
</definition>
<application>
 	<apply toObject="Realtimevalue" styles="captionFont"/>
</application>
 </styles>
</chart>

 

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
Sign in to follow this