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

Border on legend markers

2 Answers 78 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Iron
Daniel asked on 04 Nov 2010, 06:29 AM
Hi. I'm formatting a chart from the code behind. I've added some extra legend markers to my chart. The ones I've created have a nice grey border around the rectanglular boxes but the ones that are auto generated have no border. I can't seem to set the border no matter what I do. I've tried setting with the following:

RadChart1.Legend.Marker.Appearance.Border.PenStyle = System.Drawing.Drawing2D.DashStyle.Solid;
RadChart1.Legend.Marker.Appearance.Border.Width = 1;
RadChart1.Legend.Marker.Appearance.Border.Color = Color.Silver;

I haven't set any border properties for the ones I've created. I'm creating these as follows. I've also attached a screen. Thanks.

LabelItem item1 = new LabelItem();
item1.Marker.Appearance.FillStyle.MainColor = HexToColor("#2FBA2F");
item1.Marker.Appearance.FillStyle.FillType = FillType.Solid;
item1.Marker.Appearance.Figure = "Rectangle";
item1.TextBlock.Text = "Good";

2 Answers, 1 is accepted

Sort by
0
Accepted
Evgenia
Telerik team
answered on 08 Nov 2010, 09:19 AM
Hello Daniel,

You can subscribe to BeforeLayout event of the chart to be able to change anything relating Legend Item Markers. Then you can easily set Border for your Markers by looping through them like this:
protected void RadChart1_BeforeLayout(object sender, EventArgs e)
   {
       for (int i = 0; i < RadChart1.Legend.Items.Count; i++)
       {
           RadChart1.Legend.Items[i].Marker.Appearance.Border.Color = Color.Silver;
           RadChart1.Legend.Items[i].Marker.Appearance.Border.Width = 1;
       }
   }
If Silver borders do not seem to be visible at first look, try setting their width to 3 for example and you will see that they do appear with this approach.

Greetings,
Evgenia
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
0
Daniel
Top achievements
Rank 1
Iron
answered on 08 Nov 2010, 11:28 PM
Excellent! That did the trick. Thanks Evgenia.

Daniel
Tags
Chart (Obsolete)
Asked by
Daniel
Top achievements
Rank 1
Iron
Answers by
Evgenia
Telerik team
Daniel
Top achievements
Rank 1
Iron
Share this question
or