Set legend style to reflect penstyle of series

Thread is closed for posting
2 posts, 0 answers
  1. fudoki22
    fudoki22 avatar
    8 posts
    Member since:
    Jun 2009

    Posted 04 Jul 2011 Link to this post

    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
  2. Evgenia
    Admin
    Evgenia avatar
    1437 posts

    Posted 07 Jul 2011 Link to this post

    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!

Back to Top