This is a migrated thread and some comments may be shown as answers.

Line style in Legend

1 Answer 103 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Top achievements
Rank 1
Sivam asked on 27 Aug 2010, 07:54 AM

The default legend shape is Rectangle. I would like to show Line in the legend. I cannot show other shapes for Line chart. I see Line is not supported in Legend.
I see from other post(other products of Telerik), the alternate way. But none of those works for Telerik reports.

Here is what i'm doing following other post, to show the legend as Line.
Telerik.Reporting.Charting.LabelItem wirlegendItem = new Telerik.Reporting.Charting.LabelItem(WIRseries.Name);
wirlegendItem.Marker.Appearance.FillStyle.MainColor = System.Drawing.Color.Black;
wirlegendItem.Marker.Appearance.Figure = Telerik.Reporting.Charting.Styles.DefaultFigures.Rectangle;
wirlegendItem.Marker.Appearance.FillStyle.FillType = Telerik.Reporting.Charting.Styles.FillType.Solid;
wirlegendItem.Marker.Appearance.Dimensions.Margins.Top = Telerik.Reporting.Charting.Styles.Unit.Pixel(0);
wirlegendItem.Marker.Appearance.Dimensions.Margins.Bottom = Telerik.Reporting.Charting.Styles.Unit.Pixel(0);
wirlegendItem.Marker.Appearance.Dimensions.Margins.Left = Telerik.Reporting.Charting.Styles.Unit.Pixel(5);
wirlegendItem.Marker.Appearance.Dimensions.Margins.Right = Telerik.Reporting.Charting.Styles.Unit.Pixel(5);
wirlegendItem.Marker.Appearance.Dimensions.Paddings.Top = Telerik.Reporting.Charting.Styles.Unit.Pixel(5);
wirlegendItem.Marker.Appearance.Dimensions.Paddings.Bottom = Telerik.Reporting.Charting.Styles.Unit.Pixel(5);
wirlegendItem.Marker.Appearance.Dimensions.Paddings.Left = Telerik.Reporting.Charting.Styles.Unit.Pixel(0);
wirlegendItem.Marker.Appearance.Dimensions.Paddings.Right = Telerik.Reporting.Charting.Styles.Unit.Pixel(0);

Is there any alternative to achieve this?


1 Answer, 1 is accepted

Sort by
Telerik team
answered on 31 Aug 2010, 05:20 PM
Hello Sivam,

We've already answered your inquiry in your support ticket, but would post the answer here in case anyone else is interested:

"The only way to achieve this would be if you construct the chart entirely programmatically i.e. the chart is not bound through the DataSource property, thus you manually specify the column for XAxis YAxis, labels etc. You can find such example in the following article: Data Binding Chart to a Generic List of Objects. Then you would be able to simulate a line in the legend with the following code:

Copy Code
RadChart1.Legend[0].Marker.Appearance.Dimensions.AutoSize = false;
RadChart1.Legend[0].Marker.Appearance.Figure = "Rectangle";
RadChart1.Legend[0].Marker.Appearance.Dimensions.Height = Telerik.Charting.Styles.Unit.Pixel(2);
RadChart1.Legend[0].Marker.Appearance.Dimensions.Width = Telerik.Charting.Styles.Unit.Pixel(20);

Since we cannot show a line out of the box, we simulate this by showing a rectangle without border which has height of 1 or 2 pixels effectively rendering a line.

All the best,
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
General Discussions
Asked by
Top achievements
Rank 1
Answers by
Telerik team
Share this question