public string MakeInnerHtmlChart(ChartData[] cds, int Width, int Height) { //Check that we have some data if (cds == null) { return("An error occured, could not find any plots!"); } try { //Get paths, set in global.cs string RelativePath = (string)Application["RelativePath"] + "/"; string AbsolutePath = (string)Application["PhysicalPath"] + "/"; //Generate unique filename string filename = DateTime.Now.Ticks.ToString(); //Get hostinfo IPHostEntry ihe = Dns.GetHostByName(this.Server.MachineName); //Initialize variables string[] imgs = new string[cds.Length]; StringBuilder sr = new StringBuilder(); string[] datanames = new string[cds.Length]; string xmldata; string tabdata; ArrayList files = new ArrayList(); //Run through ChartData[] and create charts for (int i = 0; i < cds.Length; i++) { //Initialize chart ChartControl cc = new ChartControl(); cc.AddChartData(cds[i]); cc.BackColor = Color.White; //Check X and Y values if (cds[i].X == null || cds[i].Y == null) { continue; } //Check y values bool ok = false; foreach (double[] d in cds[i].Y) { if (d != null) { ok = true; } } if (!ok) { continue; } //Check if the current ChartData has Width and Height set try { if (cds[i].Width != 0) { cc.Width = cds[i].Width; } else { cc.Width = Width; } if (cds[i].Height != 0) { cc.Height = cds[i].Height; } else { cc.Height = Height; } } catch {} //Create Image Image img = cc.GetImage(); if (img == null) { continue; } //Save image to disk img.Save(AbsolutePath + filename + "_" + i + ".png", ImageFormat.Png); //Store relative path to image imgs[i] = RelativePath + filename + "_" + i + ".png"; //Save ChartData as XML try { xmldata = filename + "_" + i + ".xnc"; using (Stream s = File.OpenWrite(AbsolutePath + xmldata)) { cds[i].ToXML(s); } } catch { xmldata = null; } //Save ChartData as HTML try { tabdata = filename + "_" + i + ".html"; using (Stream s = File.OpenWrite(AbsolutePath + tabdata)) { cds[i].ToHtml(s); } } catch { tabdata = null; } //Create HTML to return to client sr.Append("<table cellpadding=0 cellspacing=2><tr><td >"); sr.Append("<img src='" + "http://" + ihe.HostName + imgs[i] + "'>\n"); if (xmldata != null) { sr.Append("<tr><td align=right><a href='http://" + ihe.HostName + RelativePath + xmldata + "'>Xml format</a> | "); } if (tabdata != null) { sr.Append("<a href='http://" + ihe.HostName + RelativePath + tabdata + "' target='htmldata'>Html format</a></table><br>"); } //Files to be deleted at the end of session files.Add(AbsolutePath + filename + "_" + i + ".png"); files.Add(AbsolutePath + xmldata); files.Add(AbsolutePath + tabdata); } //Add to session end delete AddToDelete((string[])files.ToArray(typeof(string))); //Return HTML return(sr.ToString()); } catch (Exception e) { return("An unknown error occured. Please send the following message to the administrator:<br>" + e.Message + "<br>" + e.StackTrace + "<br>" + cds.Length + ", " + Width + ", " + Height); } }