Dynamic Data From Another Source

Recommended Posts



I am developing a webpage to display some TCPIP modbus data and have the data showing on the page using some javascript.


I am trying to pass the data to the fushionchart and have the following code:-


<script src="../wsapi.js"></script>

<script language="JavaScript" src="FusionCharts.js"></script>




// Set up the address to our value in the Modbus/TCP device


var watts1Adr="Integra1630.Watts.W Phase 2";


function Setup()


// Create a scanlist to use for our cyclic scan points, in this case we name it "CyclicScanList"



// Add the counter register to our cyclic scanlist




// We want the cyclic scanlist to run once every second



// Register our callback function that will be called every time a scan has been completed



// Start reading the scanlists





// This callback function will be called after every scan of the cyclic scanlist

function CyclicCallback()



var tmpPoint;


// Get the value of the counter



// Show the value in the div by setting the innerHTML property




myChart1.setDataXML("<chart lowerLimit='0' upperLimit='5000' lowerLimitDisplay='Good' upperLimitDisplay='Bad' palette='1' numberSuffix='kwH' chartRightMargin='20' chartLeftMargin='20'><colorRange><color minValue='0' maxValue='30' code='8BBA00' label='Good'/><color minValue='30' maxValue='45' code='F6BD0F' label='Moderate'/><color minValue='45' maxValue='50' code='FF654F' label='Bad'/></colorRange><pointers><pointer value='"+tmpPoint.val+"' radius='5'/></pointers></chart>");







I then have the following to show the value and hopefully the chart:-


<body onload="Setup()">


Bike Value

<div id="watts1Div"></div>


<script type="text/javascript">

var myChart1 = new FusionCharts("HLinearGauge.swf", "ChId1", "300", "75", "0", "0");




The problem is when the page loads the graph does not load and in the firefox debug the fushioncharts.js fails at line 250 - (n.innerHTML = this.getSWFHTML(); ) now it looks like the chartobj is not defined. If you continue the fushioncharts.js stops at line 193 (chartObj.setDataXML(strDataXML); ) with the error chartObj is null. I know the value is ok as I can see this in the xmldata in the debug.


In an ideal world I would like to just refresh/upload the value each time rather than the chart but if the chart has to load then I can slow down the cyclic on the modbus side.


Has anyone got any ideas on this?


Thanks Nikki

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