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

Using a backgroun image

5 Answers 61 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
John Giblin
Top achievements
Rank 1
John Giblin asked on 07 Jul 2010, 05:28 PM
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";

            }
        }



5 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 09 Jul 2010, 09:38 AM
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
0
John Giblin
Top achievements
Rank 1
answered on 09 Jul 2010, 02:45 PM
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

 
0
Ves
Telerik team
answered on 14 Jul 2010, 08:50 AM
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
0
John Giblin
Top achievements
Rank 1
answered on 15 Jul 2010, 03:31 PM
in the Legend I want it to be the following
0
Ves
Telerik team
answered on 16 Jul 2010, 03:34 PM
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
Tags
Chart (Obsolete)
Asked by
John Giblin
Top achievements
Rank 1
Answers by
Ves
Telerik team
John Giblin
Top achievements
Rank 1
Share this question
or