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

Set legend style to reflect penstyle of series

1 Answer 68 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
fudoki22
Top achievements
Rank 1
fudoki22 asked on 04 Jul 2011, 05:14 PM
Hi Telerik
I have a colour scheme for my line chart - however this colour scheme does not translate very well when printed in black and white. One option is to set one of my lines to use a penstyle other than solid and this works quite well. However the legend doesn't reflect this and having printed the chart in b&w, the user is no wiser as to which chart series is which - they can see one is dotted (or dashdot etc), they just can't tell which one from the legend.

Is there a way to style the legend to reflect this?  By default the legend items are shown as squares, so this would need to change to a line or something in order for the penstyle to be visible.

thanks
--Mike

1 Answer, 1 is accepted

Sort by
0
Evgenia
Telerik team
answered on 07 Jul 2011, 11:50 AM
Hello Michael,

What I can suggest is that you make each Legend Item Marker's figure to look like the Series it is related to (for example - Square for Bar Series, Line for LineSeries and etc.). For the purpose you can handle the BeforeLayout or PrePaint events of RadChart and customize the Marker.Appearance.Figure of the legend items to any of the predefined figures (unfortunately there is no predefined dashed line figure):

  • - Cross
  • - Diamond
  • - Ellipse
  • - Circle
  • - Rectangle
  • - Star3
  • - Star4
  • - Star5
  • - Star6

What I can suggest you is to set the Figure of the LegendItem Marker to Rectangle and set custom Height  and Width for it so that it looks like a Line:

protected void RadChart1_BeforeLayout(object sender, EventArgs e)
   {
           RadChart1.Legend.Items[1].Marker.Appearance.Figure = "Rectangle";
           RadChart1.Legend.Items[1].Marker.Appearance.Dimensions.AutoSize = false;
           RadChart1.Legend.Items[1].Marker.Appearance.Dimensions.Width = 6;            
           RadChart1.Legend.Items[1].Marker.Appearance.Dimensions.Height = 2;
   }
You can find more information on customizing the legend appearance here.

All the best,
Evgenia
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

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