Results 1 to 7 of 7

Hybrid View

  1. #1
    Member
    Join Date
    Apr 2008
    Location
    Amersfoort
    Posts
    3

    Solution found

    I found the solution for this problem myself and thought it can probably help others.

    Turns out that the Google Visualization creates an iframe in the chart div. To let the Lightstreamer code communicate with the chart, and thus the iframe, the domain of the document in the iframe needs, also, to be set to the same domain used in the Pushpage.context.setDomain() call. If created a simple function to this: function setVisualizationDomain(el, domain) which needs to be called after the first draw of the visualization/chart. In the first draw(), the iframe is created.

    Here is the updated page:

    HTML Code:
    <!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 runat="server">
    		<title>Lightstreamer Demo</title>
    		<script type="text/javascript" language="JavaScript" src="content/js/LS/lscommons.js"></script>
    		<script type="text/javascript" language="JavaScript" src="content/js/LS/lspushpage.js"></script>
    		<script src="http://www.google.com/jsapi?key=ABQIAAAABMEsCWm7ArCHaJ7EfNHyjRRfA77vZl8sU-2EUdQXl-flLnD-IBS9DtkAJQKD_YN4JmjL49vaqBS4eQ" type="text/javascript"></script>
    		<script type="text/javascript">
    			
    			function drawChart(chart, data, opt) {
    				opt = opt || {};
    				chart.draw(data, {width: 800, height: 400, is3D: true, title: 'Stock data'});
    				if( opt.redrawTime ) {
    					setInterval(function() {
    						drawChart(chart, data, opt);
    					}, opt.redrawTime);
    					delete(opt.redrawTime);
    				}
    			}
    
    			function setVisualizationDomain(el, domain) {
    				var frames = el.getElementsByTagName('iframe');
    				if( frames.length > 0 ) {
    					window.frames[frames[0].id].document.domain = domain;
    				}
    			}
    
    			function initApp() {
    				var schema = "stock_name last_price min max";
    
    				var	groupArray = new Array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10);
    				var groupString = "";
    				for (var st = 1; st <= groupArray.length; st++) {
    					groupString += "item" + groupArray[st-1] + " ";
    				}
    
    				var data = new google.visualization.DataTable();
    				data.addColumn('string', 'Stockname');
    				data.addColumn('number', 'Last price');
    				data.addColumn('number', 'Min price');
    				data.addColumn('number', 'Max price');
    				data.addRows(groupArray.length);
    
    				var chartEl = document.getElementById('chart_div')
    				var chart = new google.visualization.BarChart(chartEl);
    				drawChart(chart, data, { redrawTime: 1000 });
    				setVisualizationDomain(chartEl, 'woutm6300.nl');
    
    				var page = new PushPage();
    				page.context.setDomain("woutm6300.nl");
    				page.onEngineCreation = function(engine) {
    					engine.connection.setLSHost("push.woutm6300.nl");
    					engine.connection.setLSPort("8081");
    					engine.connection.setAdapterName("DEMO");
    					engine.changeStatus("STREAMING");
    				}
    				page.bind();
    				page.createEngine("LightstreamerTest", "content/js/LS", "SHARE_SESSION");
    
    				var pushtable = new NonVisualTable(groupString,schema,"MERGE");
    				pushtable.setDataAdapter("QUOTE_ADAPTER");
    				pushtable.setSnapshotRequired(true);
    				
    				pushtable.onItemUpdate = function(itemPos, updateInfo, itemName) {
    					data.setValue(itemPos - 1, 0, updateInfo.getNewValue(1));
    					data.setValue(itemPos - 1, 1, parseFloat(updateInfo.getNewValue(2)));
    					data.setValue(itemPos - 1, 2, parseFloat(updateInfo.getNewValue(3)));
    					data.setValue(itemPos - 1, 3, parseFloat(updateInfo.getNewValue(4)));
    				}
    
    				page.addTable(pushtable, "1");
    			}
    
    			google.load("visualization", "1", {
    				packages:["barchart"]
    			});
    
    			google.setOnLoadCallback( initApp );
    		</script>
    	</head>
    	<body>
    		<div id="chart_div" style="width: 800px; height: 400px"></div>
    	</body>
    </html>

  2. #2
    Administrator
    Join Date
    Jul 2006
    Location
    Milan, Italy
    Posts
    521
    Hi Wout,

    Thanks! This is really helpful

    Cheers,

    Alessandro

  3. #3
    Member
    Join Date
    Aug 2010
    Location
    Beverly Hills
    Posts
    1
    Is there any obvious reason this fix wouldn't work with IE 8 too?

    David
    Last edited by DavidMorgan; June 3rd, 2015 at 08:36 PM.
    Cheers,
    David

  4. #4
    Power Member
    Join Date
    Jul 2006
    Location
    Cesano Maderno, Italy
    Posts
    784
    Hi,

    not at all,
    which domain and hosts are you using?

 

 

Similar Threads

  1. Internet Explorer --> domain and opener issue
    By Mone in forum Client SDKs
    Replies: 0
    Last Post: September 21st, 2009, 02:38 PM
  2. Internet Explorer --> Security zones issue
    By Mone in forum Client SDKs
    Replies: 0
    Last Post: July 30th, 2009, 09:09 AM
  3. Replies: 2
    Last Post: October 17th, 2008, 09:22 AM
  4. Internet Explorer --> Proxy issue
    By Mone in forum Client SDKs
    Replies: 0
    Last Post: October 22nd, 2007, 10:20 AM
  5. Running Lightstreamer Web Client : Permission Denied
    By cbradbury in forum Client SDKs
    Replies: 1
    Last Post: February 5th, 2007, 06:32 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 11:38 PM.