/// <summary> /// Renders the control to the specified HTML writer. /// </summary> /// <param name="writer">The <see cref="System.Web.UI.HtmlTextWriter" /> /// object that receives the control content. </param> protected override void Render(HtmlTextWriter writer) { if (Width.Type != UnitType.Pixel) { throw new ArgumentOutOfRangeException("Width"); } if (Height.Type != UnitType.Pixel) { throw new ArgumentOutOfRangeException("Height"); } GoogleChartUrlBuilder googleChartUrlBuilder = new GoogleChartUrlBuilder(new Size((int)Width.Value, (int)Height.Value), ChartType, GetGoogleChartDataEncoder()); // // Binding if (DataSource != null) { if (DataSource is IEnumerable) { DataBindEnumerable(googleChartUrlBuilder, DataSource as IEnumerable); } } // if writer.AddAttribute(HtmlTextWriterAttribute.Src, googleChartUrlBuilder.BuildUrl()); writer.RenderBeginTag(HtmlTextWriterTag.Img); writer.RenderEndTag(); }
private static void DataBindEnumerable(GoogleChartUrlBuilder googleChartUrlBuilder, IEnumerable enumerable) { googleChartUrlBuilder.AddDataSet(enumerable); }