This project is read-only.

Cannot html render chart

Jun 20, 2012 at 9:33 PM
Edited Jun 20, 2012 at 9:44 PM

I have created a master report with several subreports, some of which are charts.

The html renders everything OK, except the charts which are rendered with a 

"RED X".

I am using the following shared connection object

<?xml version="1.0" encoding="utf-8"?><RptDataSource xmlns:xsi="" xmlns:xsd="" Name="ManagementReport2">  <ConnectionProperties>    <Extension>SQL</Extension>    <ConnectString>Data Source=10.X.X.X;Initial Catalog=nxdb_XXX</ConnectString>    <IntegratedSecurity>true</IntegratedSecurity>  </ConnectionProperties>  <DataSourceID>a88c47c2-6cc6-4826-8dd4-f134fe4d467X</DataSourceID></RptDataSource>

I have replaced the actual IP address and Catalog name for security purposes in the above code.

My chart code looks like this.


<DataSource Name="ManagementReport2">      <DataSourceReference>ManagementReport2</DataSourceReference>      <rd:SecurityType>Integrated</rd:SecurityType>     

<rd:DataSourceID>a88c47c2-6cc6-4826-8dd4-f134fe4d467e</rd:DataSourceID>    </DataSource> 


Is there an easy fix for this?

P.S. Everything is working OK in SSRS ReportServer mode.


Jun 20, 2012 at 9:44 PM

P.S. Everything is working perfectly in SSRS ReportServer mode.

Jun 20, 2012 at 10:33 PM
Edited Jun 20, 2012 at 10:34 PM

I haven't had to figure out the images part of it in a year or so.  I'd check the images URL versus where the image is saved on your end.  If the path exists and the images are saving there, they should show up unless you have permissions issues.  My guess is you're not running through the foreach streamids part or have an issue with that segment.

Below is the example of my code, it's not exactly plug n play, but may give you something you missed?  It's not exactly "stock" either, but I don't think I left anything out from my source relating to images.


Might help?  Just look at the foreach($StreamIds as $StreamId){ segment in the documentation, I think that's all you'd need.

Good Luck.


		$renderAsHTML = new RenderAsHTML();
		$renderAsHTML->ReplacementRoot = $rs->getPageURL();
		$renderAsHTML->StreamRoot = $baseurl."reports/images/";		
		$result_html = $rs->Render2($renderAsHTML,
		$rand="-".substr(md5(mt_rand()), 0, 8);
		foreach($StreamIds as $StreamId){
		    $renderAsHTML->StreamRoot = null;
		    $result_png = $rs->RenderStream($renderAsHTML,
		$result_png = $result_png.".jpg";
		$StreamId = $StreamId.".jpg";
		$result_png = str_replace(".jpg.jpg",".jpg",$result_png);
		$StreamId = str_replace(".jpg.jpg",".jpg",$StreamId);
		$result_png = str_replace(".jpg",$rand.".jpg",$result_png);
		$StreamId = str_replace(".jpg",$rand.".jpg",$StreamId);
		    if (!$handle = fopen($path."reports/images/" . $StreamId, 'wb')){
		        echo "Cannot open file for writing output";
		    if (fwrite($handle, $result_png) === FALSE){
		        echo "Cannot write to file";

A bit further, where I'm just about to finalize result_html (the full report HTML).  I have like 20 preg_replaces for miscellaneous things, probably not the most efficient, but it works for a few hundred reports a day, haven't had complaints on images in a while.

	if ($new_images = preg_replace('/src="[^"]+?(TogglePlus|ToggleMinus|unsorted|sortAsc|sortDesc)\.gif"/i', 'src="/reports/images/$1.gif"', $result_html)) {
		$result_html = $new_images;}
	if ($new_images = preg_replace('/(\/images\/)((?!\.gif|\.jpg|\.jpeg|\.png).*?)("\/>)/i', "/reports$1$2".$rand.".jpg$3", $result_html)) {
		$result_html = $new_images;}
	if ($new_images = preg_replace('/src="[^"]+?(TogglePlus|ToggleMinus|unsorted|sortAsc|sortDesc)\.gif(.*?).jpg"/i', 'src="/reports/images/$1.gif"', $result_html)) {
		$result_html = $new_images;}
Jun 20, 2012 at 10:41 PM

Thanks for your input.  I am calling a SSRS report called MyChart.rdl that generates a chart.

I can export it to Excel or PDF format OK but it will NOT render as XML inside my PHP page.

It also works well within the SSRS reportServer application.

Does your proposed fix address this?

Thanks again.

Jun 20, 2012 at 11:17 PM

Tried your code.
For some reason the function getPageURL() got an error message.

Where is getPageURL() defined?  I am using IIS in Windows Server.

Fatal error: Call to undefined method SSRSReport::getPageURL() in C:\Dev2012\NxServer\Branches\Part3\htdocs\Source\Clinician\run\ on line 581 

Mar 28, 2013 at 10:10 AM

Has anyone fixed this ?

I have same isssue and no resolution for this at all.