Hi all,
I am using telerik reporting tool.i am passing from date and todate from aspx page and displaying chart on the report viewer.
Chart is coming correctly but legend is showing as item1, item2,item3..I want to show the name in legends and show the time in percentage in Y columns(ex: series.DefaultLabelValue = "#%").I have the datacolumn as "name" and "usage_time".
"usage_time" should be display as percentage and "name" should in the legend
please tell me how to do it?
i am putting my coding for your reference
in aspx page:
DateTime dtFromDate = (DateTime)dpFromDate.SelectedDate;
DateTime dtToDate = (DateTime)dpToDate.SelectedDate;
ReportProperty oPro = new ReportProperty();
oPro.FromDate = dtFromDate;
oPro.ToDate = dtToDate;
telerikReportGraph oReport = new telerikReportGraph();
oReport.GenerateReport(oPro);
reportviewer.Report = oReport;
in reporting.cs
public void GenerateReport(ReportProperty pro)
{
DateTime fromDate = pro.FromDate;
DateTime toDate = pro.ToDate;
titleTextBox.Value = "User/Time Pie Chart";
ds = DBMethods.GetDetailsForUserChart(1, fromDate, toDate);
ChartSeries series = new ChartSeries();
series.DataYColumn = "usage_time";
series.Type = ChartSeriesType.Pie;
series.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
series.Appearance.LabelAppearance.Visible = true;
series.Appearance.ShowLabelConnectors = true;
series.Appearance.ShowLabels = true;
series.Appearance.DiameterScale = 0.6;
chart1.ChartTitle.TextBlock.Visible = false;
chart1.ChartTitle.Visible = true;
chart1.Legend.Visible = true;
series.DefaultLabelValue = "#%";
chart1.Series.Add(series);
foreach (DataRow row in ds.Tables[0].Rows)
{
ChartSeriesItem item = new ChartSeriesItem();
item.Name = (string)row["name"];
item.Appearance.Exploded = true;
series.DefaultLabelValue = "#%";
}
this.chart1.NeedDataSource += new System.EventHandler(this.chart1_NeedDataSource_1);
}
private void chart1_NeedDataSource_1(object sender, EventArgs e)
{
(sender as Telerik.Reporting.Processing.Chart).DataSource = ds;
}
I am using telerik reporting tool.i am passing from date and todate from aspx page and displaying chart on the report viewer.
Chart is coming correctly but legend is showing as item1, item2,item3..I want to show the name in legends and show the time in percentage in Y columns(ex: series.DefaultLabelValue = "#%").I have the datacolumn as "name" and "usage_time".
"usage_time" should be display as percentage and "name" should in the legend
please tell me how to do it?
i am putting my coding for your reference
in aspx page:
DateTime dtFromDate = (DateTime)dpFromDate.SelectedDate;
DateTime dtToDate = (DateTime)dpToDate.SelectedDate;
ReportProperty oPro = new ReportProperty();
oPro.FromDate = dtFromDate;
oPro.ToDate = dtToDate;
telerikReportGraph oReport = new telerikReportGraph();
oReport.GenerateReport(oPro);
reportviewer.Report = oReport;
in reporting.cs
public void GenerateReport(ReportProperty pro)
{
DateTime fromDate = pro.FromDate;
DateTime toDate = pro.ToDate;
titleTextBox.Value = "User/Time Pie Chart";
ds = DBMethods.GetDetailsForUserChart(1, fromDate, toDate);
ChartSeries series = new ChartSeries();
series.DataYColumn = "usage_time";
series.Type = ChartSeriesType.Pie;
series.Appearance.LegendDisplayMode = ChartSeriesLegendDisplayMode.ItemLabels;
series.Appearance.LabelAppearance.Visible = true;
series.Appearance.ShowLabelConnectors = true;
series.Appearance.ShowLabels = true;
series.Appearance.DiameterScale = 0.6;
chart1.ChartTitle.TextBlock.Visible = false;
chart1.ChartTitle.Visible = true;
chart1.Legend.Visible = true;
series.DefaultLabelValue = "#%";
chart1.Series.Add(series);
foreach (DataRow row in ds.Tables[0].Rows)
{
ChartSeriesItem item = new ChartSeriesItem();
item.Name = (string)row["name"];
item.Appearance.Exploded = true;
series.DefaultLabelValue = "#%";
}
this.chart1.NeedDataSource += new System.EventHandler(this.chart1_NeedDataSource_1);
}
private void chart1_NeedDataSource_1(object sender, EventArgs e)
{
(sender as Telerik.Reporting.Processing.Chart).DataSource = ds;
}