10 Answers, 1 is accepted
LegendDisplayMode = ItemLabels
chartSeries1.Appearance.LegendDisplayMode = Telerik.Reporting.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
If I do any modification, I will get an error. Please advice if there are any other place that I need to look.
Regards
Andy Tan
Our ProductLineSales demo report contains a pie chart with LegendDisplayMode set to ItemLabels that works as expected. Those demos are installed along with the product so you can open the report locally and review it. One thing that could intervene with any settings of the chart (not only styles) is the Skin property which can override such settings. So if you're using a Skin, it is a good idea to set the customizations of the chart in the report constructor after InitializeComponent or style the whole chart manually (i.e. without setting a Skin).
All the best,
Steve
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
Attached is the screen shot that explain the problem.
Following is the listing of the designer.cs:
private
void InitializeComponent()
{
Telerik.Reporting.Charting.
ChartAxisItem chartAxisItem1 = new Telerik.Reporting.Charting.ChartAxisItem();
Telerik.Reporting.Charting.
ChartAxisItem chartAxisItem2 = new Telerik.Reporting.Charting.ChartAxisItem();
Telerik.Reporting.Charting.
ChartAxisItem chartAxisItem3 = new Telerik.Reporting.Charting.ChartAxisItem();
Telerik.Reporting.Charting.
ChartAxisItem chartAxisItem4 = new Telerik.Reporting.Charting.ChartAxisItem();
Telerik.Reporting.Charting.
ChartAxisItem chartAxisItem5 = new Telerik.Reporting.Charting.ChartAxisItem();
Telerik.Reporting.Charting.
ChartSeries chartSeries1 = new Telerik.Reporting.Charting.ChartSeries();
this.pageHeaderSection1 = new Telerik.Reporting.PageHeaderSection();
this.detail = new Telerik.Reporting.DetailSection();
this.chart1 = new Telerik.Reporting.Chart();
this.sqlDataSource1 = new Telerik.Reporting.SqlDataSource();
this.pageFooterSection1 = new Telerik.Reporting.PageFooterSection();
((System.ComponentModel.
ISupportInitialize)(this)).BeginInit();
//
// pageHeaderSection1
//
this.pageHeaderSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(2D);
this.pageHeaderSection1.Name = "pageHeaderSection1";
//
// detail
//
this.detail.Height = Telerik.Reporting.Drawing.Unit.Inch(2.8000001907348633D);
this.detail.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.chart1});
this.detail.Name = "detail";
//
// chart1
//
this.chart1.BitmapResolution = 96F;
this.chart1.DataSource = this.sqlDataSource1;
this.chart1.DefaultType = Telerik.Reporting.Charting.ChartSeriesType.Pie;
this.chart1.ImageFormat = System.Drawing.Imaging.ImageFormat.Emf;
this.chart1.Legend.TextBlock.Visible = true;
this.chart1.Location = new Telerik.Reporting.Drawing.PointU(Telerik.Reporting.Drawing.Unit.Inch(0.19999997317790985D), Telerik.Reporting.Drawing.Unit.Inch(0.20000012218952179D));
this.chart1.Name = "chart1";
this.chart1.PlotArea.XAxis.AxisLabel.Appearance.Visible = true;
this.chart1.PlotArea.XAxis.AxisLabel.Visible = true;
this.chart1.PlotArea.XAxis.IsZeroBased = false;
chartAxisItem1.TextBlock.Text =
"F Disagreed";
chartAxisItem1.Value =
new decimal(new int[] {
1,
0,
0,
0});
chartAxisItem2.TextBlock.Text =
"Disagreed";
chartAxisItem2.Value =
new decimal(new int[] {
2,
0,
0,
0});
chartAxisItem3.TextBlock.Text =
"Neutral";
chartAxisItem3.Value =
new decimal(new int[] {
3,
0,
0,
0});
chartAxisItem4.TextBlock.Text =
"Agreed";
chartAxisItem4.Value =
new decimal(new int[] {
4,
0,
0,
0});
chartAxisItem5.TextBlock.Text =
"F Agreed";
chartAxisItem5.Value =
new decimal(new int[] {
5,
0,
0,
0});
this.chart1.PlotArea.XAxis.Items.AddRange(new Telerik.Reporting.Charting.ChartAxisItem[] {
chartAxisItem1,
chartAxisItem2,
chartAxisItem3,
chartAxisItem4,
chartAxisItem5});
this.chart1.PlotArea.XAxis.MaxItemsCount = 5;
this.chart1.PlotArea.XAxis.MaxValue = 5D;
this.chart1.PlotArea.XAxis.MinValue = 1D;
chartSeries1.Appearance.FillStyle.MainColor = System.Drawing.
Color.Aqua;
chartSeries1.Appearance.LegendDisplayMode = Telerik.Reporting.Charting.
ChartSeriesLegendDisplayMode.ItemLabels;
chartSeries1.DataYColumn =
"Value";
chartSeries1.DefaultLabelValue =
"#%";
chartSeries1.Name =
"Series 1";
chartSeries1.Type = Telerik.Reporting.Charting.
ChartSeriesType.Pie;
this.chart1.Series.AddRange(new Telerik.Reporting.Charting.ChartSeries[] {
chartSeries1});
this.chart1.Size = new Telerik.Reporting.Drawing.SizeU(Telerik.Reporting.Drawing.Unit.Inch(4.8000001907348633D), Telerik.Reporting.Drawing.Unit.Inch(2.6000001430511475D));
this.chart1.Style.BackgroundColor = System.Drawing.Color.White;
//
// sqlDataSource1
//
this.sqlDataSource1.ConnectionString = "Survey";
this.sqlDataSource1.Name = "sqlDataSource1";
this.sqlDataSource1.SelectCommand = "SELECT Grade, Value\r\nFROM Result1";
//
// pageFooterSection1
//
this.pageFooterSection1.Height = Telerik.Reporting.Drawing.Unit.Inch(2D);
this.pageFooterSection1.Name = "pageFooterSection1";
//
// Report1
//
this.Items.AddRange(new Telerik.Reporting.ReportItemBase[] {
this.pageHeaderSection1,
this.detail,
this.pageFooterSection1});
this.Name = "Report1";
this.PageSettings.Margins.Bottom = Telerik.Reporting.Drawing.Unit.Inch(1D);
this.PageSettings.Margins.Left = Telerik.Reporting.Drawing.Unit.Inch(1D);
this.PageSettings.Margins.Right = Telerik.Reporting.Drawing.Unit.Inch(1D);
this.PageSettings.Margins.Top = Telerik.Reporting.Drawing.Unit.Inch(1D);
this.PageSettings.PaperKind = System.Drawing.Printing.PaperKind.Letter;
this.Style.BackgroundColor = System.Drawing.Color.White;
this.Width = Telerik.Reporting.Drawing.Unit.Inch(6D);
((System.ComponentModel.
ISupportInitialize)(this)).EndInit();
Please help.
Regards
Andy tan
Please check the related help article that will help you provide different names for the chart item labels and the values on the plot area - How-To: Programmatically Data Binding Chart to a Generic List of Objects. The general idea is that you programmatically add the chart series item, which gives you more granular control on how to display item labels and plot values. Otherwise you will have to show either equal labels or just the item labels/ plot values. This is a limitation specific to pie chart type.
I hope that helps.
Greetings,
Steve
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
I used the sample code provide in your link to try out but get this error message on this instruction:
Telerik.Reporting.Processing.Chart procChart = (Telerik.Reporting.Processing.Chart)sender;
The error message is:
An error has occurred while processing Report 'productreport': Unable to cast object of type 'Telerik.Reporting.Processing.Report' to type 'Telerik.Reporting.Processing.Chart'.
I am not sure where I am missing out.
Regards
Andy Tan
Judging by the error, you must have wired the Report NeedDataSource instead of the chart NeedDataSource. Please wire the appropriate event handler.
Regards,
Steve
the Telerik team
BLOGGERS WANTED! Write a review about Telerik Reporting or the new Report Designer, post it on your blog and get a complimentary license for Telerik Reporting. We’ll even promote your blog and help bring you a few fresh readers. Yes, it’s that simple. And it’s free. Get started today >
An error has occurred while processing Report 'chart2': Unable to cast object of type 'Telerik.Reporting.Processing.Report' to type 'Telerik.Reporting.Processing.Chart'.
what is wrong?
my code:
private void chart2_NeedDataSource(object sender, EventArgs e)
{
Telerik.Reporting.Processing.Chart procChart = (Telerik.Reporting.Processing.Chart)sender;
Telerik.Reporting.Chart defChart = (Telerik.Reporting.Chart)procChart.ItemDefinition;
defChart.Series[0].DefaultLabelValue = string.Empty;
defChart.IntelligentLabelsEnabled = false;
Class1 obj_class = new Class1();
DataTable source = new DataTable();
source = obj_class.retrvTBL("select SUM(OS.oscount)as sumcount,OS.os from OS group by os");
ChartSeries serie = new ChartSeries();
serie.Type = ChartSeriesType.Pie;
serie.Clear();
serie.Appearance.LegendDisplayMode = Telerik.Reporting.Charting.ChartSeriesLegendDisplayMode.ItemLabels;
serie.Appearance.ShowLabelConnectors = true;
foreach (DataRow dr in source.Rows)
{
ChartSeriesItem item = new ChartSeriesItem();
item.YValue = Convert.ToDouble(dr["sumcount"]);
item.Name = (string)dr["sumcount"] + " - #%";
item.Appearance.Exploded = true;
item.Label.TextBlock.Text = dr["os"].ToString();
serie.Items.Add(item);
}
defChart.Series.Add(serie);
}
Regards
saman