Using a backgroun image

Thread is closed for posting
6 posts, 0 answers
  1. John Giblin
    John Giblin avatar
    155 posts
    Member since:
    Jan 2006

    Posted 07 Jul 2010 Link to this post

    I am not sure how to add a background image to a legend dynamically.  But I tried to the following without success:

            protected void rcOvernightByHHour_PrePaint(object sender, EventArgs e)
            {
                foreach (Telerik.Charting.LabelItem legend in rcOvernightByHHour.Legend.Items)
                {
                    legend.Appearance.FillStyle.FillSettings.BackgroundImage = "C:\\images\\networks\\" + legend.Name + ".jpeg";

                }
            }



  2. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 09 Jul 2010 Link to this post

    Hi John Giblin,

    You will also need to set the FillType property:

    foreach (Telerik.Charting.LabelItem legend in RadChart1.Legend.Items)
    {
        legend.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Image;
        legend.Appearance.FillStyle.FillSettings.BackgroundImage = "C:\\images\\networks\\" + legend.Name + ".jpeg";
    }


    Kind regards,
    Ves
    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
  3. John Giblin
    John Giblin avatar
    155 posts
    Member since:
    Jan 2006

    Posted 09 Jul 2010 Link to this post

    thanks Ves,

    I was able to get the image to display.  But what happens is that I see the image in the background.  I know it a background image but in the documentation you see the flag and the name.  What I wanted to see in the legend was: "Icon Image Text". Is there a way to do that

     
  4. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 14 Jul 2010 Link to this post

    Hi John Giblin,

    I am not really sure I am following you. If you need the image to appear within the legend item marker you can update the lines in the loop like this:

    foreach (Telerik.Charting.LabelItem legend in RadChart1.Legend.Items)
    {
        legend.Marker.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Image;
        legend.Marker.Appearance.FillStyle.FillSettings.BackgroundImage = "C:\\images\\networks\\" + legend.Name + ".jpeg";
    }

    If that is not really what you need, please provide more details about the expected result. You can attach an image or a simple scratch.

    Best regards,
    Ves
    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
  5. John Giblin
    John Giblin avatar
    155 posts
    Member since:
    Jan 2006

    Posted 15 Jul 2010 Link to this post

    in the Legend I want it to be the following
  6. Ves
    Admin
    Ves avatar
    2926 posts

    Posted 16 Jul 2010 Link to this post

    Hello John,

    Unfortunately this is not directly supported. You can create your own composite images, which will contain the default legend item marker and your image. Then use these images as markers:

    foreach (Telerik.Charting.LabelItem legend in RadChart1.Legend.Items)
    {
        legend.Marker.Appearance.Dimensions.AutoSize = false;
        legend.Marker.Appearance.Dimensions.Width = Telerik.Charting.Styles.Unit.Pixel(50);
        legend.Marker.Appearance.Dimensions.Height = Telerik.Charting.Styles.Unit.Pixel(16);
        legend.Marker.Appearance.Figure = "Rectangle";
        legend.Marker.Appearance.FillStyle.FillType = Telerik.Charting.Styles.FillType.Image;
        legend.Marker.Appearance.FillStyle.FillSettings.BackgroundImage = "C:\\images\\networks\\" + legend.Name + ".jpeg";
    }


    Best regards,
    Ves
    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
Back to Top