Hi,
I am new for telerik charting. i want to display a chart , in which values are binding from DB. i tried using following code but am facing performance issue - it is very very slow. can u suggest the needful
Here is the code which i used:
aspx code
aspx.cs code:
Thanks,
Harin
I am new for telerik charting. i want to display a chart , in which values are binding from DB. i tried using following code but am facing performance issue - it is very very slow. can u suggest the needful
Here is the code which i used:
aspx code
<telerik:RadChart ID="RadChart1" runat="server" ChartImageFormat="Jpeg" ChartTitle-Visible="True"> <Appearance BarWidthPercent="60" ></Appearance> <Legend Appearance-Position-AlignedPosition="BottomLeft" Appearance-Location="OutsidePlotArea" > <TextBlock Appearance-Position-AlignedPosition="BottomLeft"></TextBlock> </Legend> <ChartTitle TextBlock-Text="Forecast Vs Plan" > </ChartTitle> <Series> <telerik:ChartSeries DataYColumn="Base" Name="Base"> <Appearance FillStyle-MainColor="#ffff66" FillStyle-SecondColor="#ffff66" Border-Color="#000000" Border-PenStyle="Solid"> </Appearance> </telerik:ChartSeries> <telerik:ChartSeries DataYColumn="Plan" Name="Plan"> <Appearance FillStyle-MainColor="#ff0033" FillStyle-SecondColor="#ff0033" Border-Color="#000000" Border-PenStyle="Solid"> </Appearance> </telerik:ChartSeries> <telerik:ChartSeries DataYColumn="ForeCast" Name="ForeCast" > <Appearance FillStyle-MainColor="#6600cc" FillStyle-SecondColor="#6600cc" Border-Color="#000000" Border-PenStyle="Solid"> </Appearance> </telerik:ChartSeries> </Series> <PlotArea Appearance-Position-Y="100"> <XAxis VisibleValues="Positive"> <Appearance MajorGridLines-PenStyle="Solid" MajorGridLines-Color="#000000"> <TextAppearance AutoTextWrap="True" ></TextAppearance> </Appearance> </XAxis> <YAxis VisibleValues="Positive" > <Appearance MajorGridLines-PenStyle="Solid" MajorGridLines-Color="#000000"></Appearance> </YAxis> </PlotArea> </telerik:RadChart>protected void Graph_Load() { decimal Plan, Base, Fore, max = 0; DataSet dsResults = new DataSet(); dsResults = ForeCastBO.loadForeCast(Setinputvalues()); DataTable dt_Graph = new DataTable(); dt_Graph.Columns.Add("Division", typeof(String)); dt_Graph.Columns.Add("Plan", typeof(String)); dt_Graph.Columns.Add("Base", typeof(String)); dt_Graph.Columns.Add("ForeCast", typeof(String)); if (dsResults.Tables[0].Rows.Count > 0) { for (int i = 0; i < dsResults.Tables[0].Rows.Count; i++) { dt_Graph.Rows.Add(dsResults.Tables[0].Rows[i][3].ToString(), Decimal.Round(Convert.ToDecimal(dsResults.Tables[0].Rows[i][2].ToString())), Decimal.Round(Convert.ToDecimal(dsResults.Tables[0].Rows[i][4].ToString())), Decimal.Round(Convert.ToDecimal(dsResults.Tables[0].Rows[i][5].ToString()))); Plan = Decimal.Round(Convert.ToDecimal(dsResults.Tables[0].Rows[i][2].ToString())); Base = Decimal.Round(Convert.ToDecimal(dsResults.Tables[0].Rows[i][4].ToString())); Fore = Decimal.Round(Convert.ToDecimal(dsResults.Tables[0].Rows[i][5].ToString())); if (Plan > Base) max = Plan; else max = Base; if (Fore > max) max = Fore; } RadChart1.DataSource = dt_Graph; RadChart1.PlotArea.XAxis.DataLabelsColumn = dt_Graph.Rows[0].ToString(); int width; width = 120 * (dt_Graph.Rows.Count); RadChart1.Width = width; RadChart1.Height = 400; RadChart1.PlotArea.Appearance.FillStyle.MainColor = System.Drawing.Color.White; RadChart1.PlotArea.Appearance.FillStyle.SecondColor = System.Drawing.Color.White; RadChart1.PlotArea.YAxis.AutoScale = false; RadChart1.PlotArea.YAxis.MaxValue = Convert.ToDouble(max); RadChart1.PlotArea.YAxis.ScaleBreaks.MaxCount = 7; RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Color = System.Drawing.Color.Black; RadChart1.PlotArea.Appearance.Dimensions.Margins.Bottom = Telerik.Charting.Styles.Unit.Pixel(100); // bind to the datasource RadChart1.DataBind(); } }Thanks,
Harin