Beispiel #1
0
function xt_showchart($params)
{
    $width = 700;
    $height = 530;
    $chartPreview = "";
    if ($params["chartPreview"]) {
        $chartPreview = "&chartPreview=true";
    }
    if (isset($params["custom1"])) {
        $width = $params["custom1"];
    }
    if (isset($params["custom2"])) {
        $height = $params["custom2"];
    }
    if ($params["dashResize"]) {
        if ($params["dashWidth"] && $params["dashHeight"]) {
            $width = $params["dashWidth"];
            $height = $params["dashHeight"];
        } elseif ($params["dashWidth"]) {
            $height = round($height * $params["dashWidth"] / $width);
            $width = $params["dashWidth"];
        } elseif ($params["dashHeight"]) {
            $width = round($width * $params["dashHeight"] / $height);
            $height = $params["dashHeight"];
        }
        // adjust the chart size to fit it in the dash cell
        $width *= 0.95;
        $height *= 0.95;
    } elseif ($params["resize"]) {
        $maxWidth = 400;
        $maxHeight = 280;
        $r = $maxWidth / $maxHeight;
        $r2 = $width / $height;
        if ($width > $maxWidth || $height > $maxHeight) {
            if ($r2 >= $r) {
                // width
                $height = round($height * $maxWidth / $width);
                $width = $maxWidth;
            } else {
                $width = round($width * $maxHeight / $height);
                $height = $maxHeight;
            }
        }
    }
    $showDetails = isset($params["showDetails"]) ? $params["showDetails"] : true;
    $settings = new ProjectSettings(GetTableByShort($params["chartname"]));
    $refresh = $settings->getChartRefreshTime() * 1000;
    if ($_SERVER["SERVER_PORT"] == 443) {
        $http = "https";
    } else {
        $http = "http";
    }
    ?>
<div id='<?php 
    echo $params["chartname"] . $params["id"];
    ?>
' style="width:<?php 
    echo $width;
    ?>
px;height:<?php 
    echo $height;
    ?>
px">
<?php 
    if (!$params["singlePage"]) {
        ?>
<script type="text/javascript" language="javascript" src="libs/js/AnyChart.js"></script>
<script type="text/javascript" language="javascript" src="libs/js/AnyChartHTML5.js"></script>
<script type="text/javascript">
<?php 
        global $useFlashChartLibrary;
        if (!$useFlashChartLibrary) {
            ?>
var	svgSupported = !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect;
	AnyChart.renderingType = svgSupported ? anychart.RenderingType.SVG_PREFERRED : anychart.RenderingType.FLASH_PREFERRED;
<?php 
        } else {
            ?>
	AnyChart.renderingType = anychart.RenderingType.FLASH_PREFERRED;
<?php 
        }
        ?>
</script>

<script type="text/javascript" language="javascript">
	//<![CDATA[
	var chart = new AnyChart('libs/swf/AnyChart.swf','libs/swf/Preloader.swf');
	
	chart.width = '<?php 
        echo $width;
        ?>
';
	chart.height = '<?php 
        echo $height;
        ?>
';
	chart.wMode='opaque';
	chart.id = 'chart_' + '<?php 
        echo $params["chartname"];
        ?>
';
	
	var xmlFile = '<?php 
        echo GetTableLink("dchartdata");
        ?>
?chartname=<?php 
        echo jsreplace($params["chartname"]) . $chartPreview;
        ?>
';
	xmlFile += '&ctype=<?php 
        echo $params["ctype"];
        ?>
';
	xmlFile += '&showDetails=<?php 
        echo $showDetails;
        ?>
';
	xmlFile += '&hasFlash=' + AnyChart.platform.hasRequiredVersion;

<?php 
        if (isset($params["dash"]) && $params["dash"]) {
            ?>
	xmlFile += '&dashChart=<?php 
            echo $params["dash"];
            ?>
';
<?php 
        }
        ?>
	
<?php 
        if (isset($params["dashTName"]) && $params["dashTName"]) {
            ?>
	xmlFile += '&dashTName=<?php 
            echo $params["dashTName"];
            ?>
';
	xmlFile += '&dashElName=<?php 
            echo $params["dashElementName"];
            ?>
';
	xmlFile += '&pageId=<?php 
            echo $params["id"];
            ?>
';
	$.ajax( {
		type: "GET",
		url: xmlFile,
		dataType: "xml",
		success: function( xml ) {
			var $xml = $( xml );
			Runner.updateDetailsForDashboardChart( $xml.find( "detail_master_keys" ).text(), $xml.find( "detail_page_id" ).text() );
		}
	});
<?php 
        }
        ?>
	chart.setXMLFile(xmlFile);
	chart.write('<?php 
        echo $params["chartname"] . $params["id"];
        ?>
');
	<?php 
        $chartname = jsreplace($params["chartname"]);
        if ($params["ctype"] == "Gauge") {
            $refrFunction = "Runner.updateGaugeChart(\\'" . $chartname . "\\')";
        } else {
            $refrFunction = "Runner.updateChart(\\'" . $chartname . "\\', " . ($showDetails ? "true" : "false") . ", " . ($params["dash"] ? "true" : "false") . ")";
        }
        if (!$useFlashChartLibrary && ($params["ctype"] == "2DPie" || $params["ctype"] == "2DDoughnut" || $params["ctype"] == "Funnel" || $params["ctype"] == "OHLC" || $params["ctype"] == "Candle")) {
            $refresh = "0";
        }
        if ($refresh != "0" && !isMobile()) {
            echo "setInterval('" . $refrFunction . "'," . $refresh . ");";
        }
        ?>
	//]]>
</script>
<?php 
    }
    ?>
</div>
<?php 
}
Beispiel #2
0
function xt_showchart($params)
{
    $width = 700;
    $height = 530;
    if (isset($params["custom1"])) {
        $width = $params["custom1"];
    }
    if (isset($params["custom2"])) {
        $height = $params["custom2"];
    }
    $settings = new ProjectSettings(GetTableByShort($params["chartname"]));
    $refresh = $settings->getChartRefreshTime() * 60000;
    if ($_SERVER["SERVER_PORT"] == 443) {
        $http = "https";
    } else {
        $http = "http";
    }
    ?>
<div id='<?php 
    echo $params["chartname"];
    ?>
' style="width:<?php 
    echo $width;
    ?>
px;height:<?php 
    echo $height;
    ?>
px">
<noscript>
	<object id="'.htmlspecialchars(postvalue('cname')).'" 
		name="'.htmlspecialchars(postvalue('cname')).'" 
		classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
		width="100%" 
		height="100%" 
		codebase="http://fpdownload.macromedia.com/get/flashplayer/current/swflash.cab">
		<param name="movie" value="libs/swf/Preloader.swf" />
		<param name="bgcolor" value="#FFFFFF" />

		<param name="allowScriptAccess" value="always" />
		<param name="flashvars" value="swfFile=dchartdata.php%3Fcname%3D'.htmlspecialchars(postvalue('cname')).'%26ctype%3D'.$chrt_array['chart_type']['type'].'" />
		
		<embed type="application/x-shockwave-flash" 
			   pluginspage="http://www.adobe.com/go/getflashplayer" 
			   src="libs/swf/Preloader.swf" 
			   width="100%" 
			   height="100%" 
			   id="'.htmlspecialchars(postvalue('cname')).'" 
			   name="'.htmlspecialchars(postvalue('cname')).'" 
			   bgColor="#FFFFFF" 
			   allowScriptAccess="always" 
			   flashvars="swfFile=dchartdata.php%3Fcname%3D'.htmlspecialchars(postvalue('cname')).'%26ctype%3D'.$chrt_array['chart_type']['type'].'" />
	</object>				
</noscript>
<script type="text/javascript" language="javascript" src="libs/js/AnyChart.js"></script>
<script type="text/javascript" language="javascript" src="libs/js/AnyChartHTML5.js"></script>
<script type="text/javascript">
AnyChart.renderingType = anychart.RenderingType.FLASH_PREFERRED;
var svgSupported = window.SVGAngle != undefined;
if (!svgSupported)
{
 	//<![CDATA[
	document.write('<center>');
	document.write("You need to have Adobe Flash Player 9 (or above) to view the chart.<br /><br />");
	document.write("<a href=\"<?php 
    echo $http;
    ?>
://www.adobe.com/go/getflashplayer\"><img border=\"0\" src=\"<?php 
    echo $http;
    ?>
://www.adobe.com/images/shared/download_buttons/get_flash_player.gif\" /></a><br />");
	document.write('</center>');
	//]]>
}	
</script>

<script type="text/javascript" language="javascript">
	//<![CDATA[
	var chart = new AnyChart('libs/swf/AnyChart.swf','libs/swf/Preloader.swf');
	chart.width = '<?php 
    echo $width;
    ?>
';
	chart.height = '<?php 
    echo $height;
    ?>
';
	chart.wMode='opaque';
	chart.id = 'chart_' + '<?php 
    echo $params["chartname"];
    ?>
';
	var xmlFile = 'dchartdata.php?chartname=<?php 
    echo jsreplace($params["chartname"]);
    ?>
';
	xmlFile += '&ctype=<?php 
    echo $params["ctype"];
    ?>
';
	chart.setXMLFile(xmlFile);
	chart.write('<?php 
    echo $params["chartname"];
    ?>
');
	if("<?php 
    echo $refresh;
    ?>
"!="0" && "<?php 
    echo isMobile();
    ?>
"=="false")
		setInterval('refreshChart()',<?php 
    echo $refresh;
    ?>
);
	function refreshChart()
	{
		page='dchartdata.php?chartname=<?php 
    echo jsreplace($params["chartname"]);
    ?>
';
		params={
				action:'refresh',
				rndval:Math.random()
				};
		$.get(page,params,function(xml)
			{
				var arr = new Array();
				arr=xml.split("\n");
				for(i=0; i<arr.length;i+=2)
				{
					chart.removeSeries(arr[i]);
					chart.addSeries(arr[i+1]);
					chart.updatePointData(arr[i]+"_gauge",arr[i]+"_point",{value: arr[i+1]});
				}
				chart.refresh();
			});

	}
	//]]>
</script>
</div>
<?php 
}
function xt_showchart($params)
{
	$width=700;
	$height=530;
	$chartPreview = "";
	if($params["chartPreview"])
		$chartPreview = "&chartPreview=true";
	if(isset($params["custom1"]))
		$width=$params["custom1"];
	if(isset($params["custom2"]))
		$height=$params["custom2"];
	if ($params["resize"])
	{
		$maxWidth = 400;
		$maxHeight = 280;
		$r = $maxWidth / $maxHeight;
		$r2 = $width / $height;
		if (($width > $maxWidth) || ($height > $maxHeight))
		{
			if ($r2 >= $r)
			{ // width
				$height = round( $height * $maxWidth / $width );
				$width = $maxWidth;
			}
			else
			{
				$width = round ( $width * $maxHeight / $height );
				$height = $maxHeight;
			}
		}
	}

	$showDetails = isset( $params["showDetails"] ) ? $params["showDetails"] :  true;

	$settings = new ProjectSettings(GetTableByShort($params["chartname"]));
	$refresh = $settings->getChartRefreshTime()*60000;
	if ($_SERVER["SERVER_PORT"]==443)
		$http = "https";
	else
		$http="http";	
?>
<div id='<?php echo $params["chartname"].$params["id"] ?>' style="width:<?php echo $width; ?>px;height:<?php echo $height; ?>px">
<?php if (!$params["singlePage"]) { ?>
<script type="text/javascript" language="javascript" src="libs/js/AnyChart.js"></script>
<script type="text/javascript" language="javascript" src="libs/js/AnyChartHTML5.js"></script>
<script type="text/javascript">
<?php global $useFlashChartLibrary; if (!$useFlashChartLibrary) { ?>
var	svgSupported = !!document.createElementNS && !!document.createElementNS('http://www.w3.org/2000/svg', 'svg').createSVGRect;
	AnyChart.renderingType = svgSupported ? anychart.RenderingType.SVG_PREFERRED : anychart.RenderingType.FLASH_PREFERRED;
<?php } else { ?>
	AnyChart.renderingType = anychart.RenderingType.FLASH_PREFERRED;
<?php } ?>
</script>

<script type="text/javascript" language="javascript">
	//<![CDATA[
	var chart = new AnyChart('libs/swf/AnyChart.swf','libs/swf/Preloader.swf');
	
	chart.width = '<?php echo $width; ?>';
	chart.height = '<?php echo $height; ?>';
	chart.wMode='opaque';
	chart.id = 'chart_' + '<?php echo $params["chartname"];?>';
	
	var xmlFile = '<?php echo GetTableLink("dchartdata")?>?chartname=<?php echo jsreplace($params["chartname"]).$chartPreview;?>';
	xmlFile += '&ctype=<?php echo $params["ctype"];?>';
	xmlFile += '&showDetails=<?php echo $showDetails;?>';
	xmlFile += '&hasFlash=' + AnyChart.platform.hasRequiredVersion;
	
	chart.setXMLFile(xmlFile);
	chart.write('<?php echo $params["chartname"].$params["id"];?>');
	<?php
	
	$chartname = jsreplace($params["chartname"]);
	if($params["ctype"]=="Gauge")
		$refrFunction="Runner.updateGaugeChart(\'".$chartname."\')";
	else
		$refrFunction="Runner.updateChart(\'".$chartname."\', ".($showDetails ? "true" : "false").")";
	
	if(!$useFlashChartLibrary && ( $params["ctype"]=="2DPie" || $params["ctype"]=="2DDoughnut" || $params["ctype"]=="Funnel" || $params["ctype"]=="OHLC" || $params["ctype"]=="Candle" ))
		$refresh="0";
	if($refresh!="0" && !isMobile())
		echo "setInterval('".$refrFunction."',".$refresh.");";
	?>
	//]]>
</script>
<?php } ?>
</div>
<?php
}