/// <summary> /// Generate the fusion chart based on HTML /// </summary> /// <param name="chartType"></param> /// <param name="strURL"></param> /// <param name="strXML"></param> /// <param name="chartId"></param> /// <param name="chartWidth"></param> /// <param name="chartHeight"></param> /// <param name="debugMode"></param> /// <returns></returns> public static string RenderChartHTML(ChartTypeRestricted chartType, string strXML, string chartId, string chartWidth, string chartHeight, bool debugMode) { StringBuilder builder = new StringBuilder(); string str = string.Empty; // We convert the chart type to path string chartSWF = Utils.ConvertChartTypeToPath(chartType); // We use the XML given as param str = string.Format("&chartWidth={0}&chartHeight={1}&debugMode={2}&dataXML={3}", new object[] { chartWidth, chartHeight, boolToNum(debugMode), strXML }); // We determine if we should is http or https prefix string protocol = IsSSL() ? "https://" : "http://"; // We build the HTML and returns it builder.AppendFormat("<!-- START Code Block for Chart {0} -->" + Environment.NewLine, chartId); builder.AppendFormat("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\"" + protocol + "fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"{0}\" height=\"{1}\" name=\"{2}\">" + Environment.NewLine, chartWidth, chartHeight, chartId); builder.Append("<param name=\"allowScriptAccess\" value=\"always\" />" + Environment.NewLine); builder.AppendFormat("<param name=\"movie\" value=\"{0}\"/>" + Environment.NewLine, chartSWF); builder.AppendFormat("<param name=\"FlashVars\" value=\"{0}\" />" + Environment.NewLine, str); builder.Append("<param name=\"quality\" value=\"high\" />" + Environment.NewLine); builder.AppendFormat("<embed src=\"{0}\" FlashVars=\"{1}\" quality=\"high\" width=\"{2}\" height=\"{3}\" name=\"{4}\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"" + protocol + "www.macromedia.com/go/getflashplayer\" />" + Environment.NewLine, new object[] { chartSWF, str, chartWidth, chartHeight, chartId }); builder.Append("</object>" + Environment.NewLine); builder.AppendFormat("<!-- END Code Block for Chart {0} -->" + Environment.NewLine, chartId); return(builder.ToString()); }
/// <summary> /// Converts a ChartType into a path that can be used with RenderChartHTML function /// </summary> /// <param name="chartType">The type of the chart</param> /// <returns></returns> public static string ConvertChartTypeToPath(ChartTypeRestricted chartType) { if (ChartTypeRestricted.FCF_Area2D == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Area2D.swf"); } if (ChartTypeRestricted.FCF_Bar2D == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Bar2D.swf"); } if (ChartTypeRestricted.FCF_Column2D == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Column2D.swf"); } if (ChartTypeRestricted.FCF_Column3D == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Column3D.swf"); } if (ChartTypeRestricted.FCF_Doughnut2D == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Doughnut2D.swf"); } if (ChartTypeRestricted.FCF_Funnel == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Funnel.swf"); } if (ChartTypeRestricted.FCF_Line == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Line.swf"); } if (ChartTypeRestricted.FCF_Pie2D == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Pie2D.swf"); } if (ChartTypeRestricted.FCF_Pie3D == chartType) { return(SPContext.Current.Site.Url + FeaturePath + "FCF_Pie3D.swf"); } // Default charts in case there was no match string defaultChartType = SPContext.Current.Site.Url + FeaturePath + "FCF_Area2D.swf"; return(defaultChartType); }
/// <summary> /// Generate the fusion chart based on HTML /// </summary> /// <param name="chartType"></param> /// <param name="strURL"></param> /// <param name="strXML"></param> /// <param name="chartId"></param> /// <param name="chartWidth"></param> /// <param name="chartHeight"></param> /// <param name="debugMode"></param> /// <returns></returns> public static string RenderChartHTML(ChartTypeRestricted chartType, string strXML, string chartId, string chartWidth, string chartHeight, bool debugMode) { StringBuilder builder = new StringBuilder(); string str = string.Empty; // We convert the chart type to path string chartSWF = Utils.ConvertChartTypeToPath(chartType); // We use the XML given as param str = string.Format("&chartWidth={0}&chartHeight={1}&debugMode={2}&dataXML={3}", new object[] { chartWidth, chartHeight, boolToNum(debugMode), strXML }); // We determine if we should is http or https prefix string protocol = IsSSL() ? "https://" : "http://"; // We build the HTML and returns it builder.AppendFormat("<!-- START Code Block for Chart {0} -->" + Environment.NewLine, chartId); builder.AppendFormat("<object classid=\"clsid:d27cdb6e-ae6d-11cf-96b8-444553540000\" codebase=\""+ protocol + "fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0\" width=\"{0}\" height=\"{1}\" name=\"{2}\">" + Environment.NewLine, chartWidth, chartHeight, chartId); builder.Append("<param name=\"allowScriptAccess\" value=\"always\" />" + Environment.NewLine); builder.AppendFormat("<param name=\"movie\" value=\"{0}\"/>" + Environment.NewLine, chartSWF); builder.AppendFormat("<param name=\"FlashVars\" value=\"{0}\" />" + Environment.NewLine, str); builder.Append("<param name=\"quality\" value=\"high\" />" + Environment.NewLine); builder.AppendFormat("<embed src=\"{0}\" FlashVars=\"{1}\" quality=\"high\" width=\"{2}\" height=\"{3}\" name=\"{4}\" allowScriptAccess=\"always\" type=\"application/x-shockwave-flash\" pluginspage=\"" + protocol + "www.macromedia.com/go/getflashplayer\" />" + Environment.NewLine, new object[] { chartSWF, str, chartWidth, chartHeight, chartId }); builder.Append("</object>" + Environment.NewLine); builder.AppendFormat("<!-- END Code Block for Chart {0} -->" + Environment.NewLine, chartId); return builder.ToString(); }
/// <summary> /// Converts a ChartType into a path that can be used with RenderChartHTML function /// </summary> /// <param name="chartType">The type of the chart</param> /// <returns></returns> public static string ConvertChartTypeToPath(ChartTypeRestricted chartType) { if (ChartTypeRestricted.FCF_Area2D == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Area2D.swf"; if (ChartTypeRestricted.FCF_Bar2D == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Bar2D.swf"; if (ChartTypeRestricted.FCF_Column2D == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Column2D.swf"; if (ChartTypeRestricted.FCF_Column3D == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Column3D.swf"; if (ChartTypeRestricted.FCF_Doughnut2D == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Doughnut2D.swf"; if (ChartTypeRestricted.FCF_Funnel == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Funnel.swf"; if (ChartTypeRestricted.FCF_Line == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Line.swf"; if (ChartTypeRestricted.FCF_Pie2D == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Pie2D.swf"; if (ChartTypeRestricted.FCF_Pie3D == chartType) return SPContext.Current.Site.Url + FeaturePath + "FCF_Pie3D.swf"; // Default charts in case there was no match string defaultChartType = SPContext.Current.Site.Url + FeaturePath + "FCF_Area2D.swf"; return defaultChartType; }