public string ToHtmlString() { StringBuilder scripts = new StringBuilder(); _Highstock.ForEach(x => scripts.AppendLine("<div id='{0}'></div>".FormatWith(x.ContainerName))); List <HighStock> startupCharts = _Highstock.Where(x => String.IsNullOrEmpty(x.FunctionName)).ToList(); scripts.AppendLine("<script type='text/javascript'>"); startupCharts.ForEach(x => scripts.AppendLine("var {0};".FormatWith(x.Name))); scripts.AppendLine("$(document).ready(function() {"); startupCharts.ForEach(scripts.AppendHighstock); scripts.AppendLine("});"); List <HighStock> functionCharts = _Highstock.Where(x => !String.IsNullOrEmpty(x.FunctionName)).ToList(); foreach (HighStock chart in functionCharts) { scripts.AppendLine("var {0};".FormatWith(chart.Name)); scripts.AppendLine(String.Format("function {0}() {{", chart.FunctionName)); scripts.AppendHighstock(chart); scripts.AppendLine("}"); } scripts.AppendLine("</script>"); return(scripts.ToString()); }
/// <summary> /// Returns JavaScript code for the chart in an HTML-encoded String. /// </summary> /// <returns></returns> public HtmlString ChartScriptHtmlString() { var _scripts = new StringBuilder(); _scripts.AppendLine("<script type='text/javascript'>"); if (Options != null) { _scripts.AppendLine("Highcharts.setOptions({0});".FormatWith(JsonSerializer.Serialize(Options))); } _scripts.AppendLine("var {0};".FormatWith(Name)); _scripts.AppendLine(!String.IsNullOrEmpty(FunctionName) ? String.Format("function {0}() {{", FunctionName) : "$(document).ready(function() {"); _scripts.AppendHighstock(this); _scripts.AppendLine(!String.IsNullOrEmpty(FunctionName) ? "}" : "});"); _scripts.AppendLine("</script>"); return(new HtmlString(_scripts.ToString())); }
public string ToHtmlString() { StringBuilder scripts = new StringBuilder(); _Highstock.ForEach(x => scripts.AppendLine("<div id='{0}'></div>".FormatWith(x.ContainerName))); List<Highstock> startupCharts = _Highstock.Where(x => String.IsNullOrEmpty(x.FunctionName)).ToList(); scripts.AppendLine("<script type='text/javascript'>"); startupCharts.ForEach(x => scripts.AppendLine("var {0};".FormatWith(x.Name))); scripts.AppendLine("$(document).ready(function() {"); startupCharts.ForEach(scripts.AppendHighstock); scripts.AppendLine("});"); List<Highstock> functionCharts = _Highstock.Where(x => !String.IsNullOrEmpty(x.FunctionName)).ToList(); foreach (Highstock chart in functionCharts) { scripts.AppendLine("var {0};".FormatWith(chart.Name)); scripts.AppendLine(String.Format("function {0}() {{", chart.FunctionName)); scripts.AppendHighstock(chart); scripts.AppendLine("}"); } scripts.AppendLine("</script>"); return scripts.ToString(); }
/// <summary> /// Returns JavaScript code for the chart in an HTML-encoded String. /// </summary> /// <returns></returns> public HtmlString ChartScriptHtmlString() { StringBuilder scripts = new StringBuilder(); scripts.AppendLine("<script type='text/javascript'>"); if (Options != null) scripts.AppendLine("Highcharts.setOptions({0});".FormatWith(JsonSerializer.Serialize(Options))); scripts.AppendLine("var {0};".FormatWith(Name)); scripts.AppendLine(!String.IsNullOrEmpty(FunctionName) ? String.Format("function {0}() {{", FunctionName) : "$(document).ready(function() {"); scripts.AppendHighstock(this); scripts.AppendLine(!String.IsNullOrEmpty(FunctionName) ? "}" : "});"); scripts.AppendLine("</script>"); return new HtmlString(scripts.ToString()); }