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

Using predefined images as fill for bar charts

2 Answers 63 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Robert
Top achievements
Rank 1
Robert asked on 17 Sep 2014, 02:23 PM
While using the now obsolete ChartView I was able to use custom image files in .png format, (similar, but different from the currently offered GradientStyles) as a filler for my bars in BarCharts. I used:

Series[0].Items[0].Appearance.FillStyle

which had several useful Properties.

What would be the corresponding code using RadChartView to use these same images?

Thanks,
Rob

2 Answers, 1 is accepted

Sort by
0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 22 Sep 2014, 07:27 AM
Hello Robert,

Thank you for writing.

Please have a look at the following code snippet, demonstrating how to assign an image to the elements in the BarSeries :
public Form1()
{
    InitializeComponent();
 
    BarSeries barSeries = new BarSeries("Performance", "RepresentativeName");
    barSeries.Name = "Q1";
    barSeries.DataPoints.Add(new CategoricalDataPoint(177, "Harley"));
    barSeries.DataPoints.Add(new CategoricalDataPoint(128, "White"));
    barSeries.DataPoints.Add(new CategoricalDataPoint(143, "Smith"));
    barSeries.DataPoints.Add(new CategoricalDataPoint(111, "Jones"));
    barSeries.DataPoints.Add(new CategoricalDataPoint(118, "Marshall"));
    this.radChartView1.Series.Add(barSeries);
     
    BarSeries barSeries2 = new BarSeries("Performance", "RepresentativeName");
    barSeries2.Name = "Q2";
    barSeries2.DataPoints.Add(new CategoricalDataPoint(153, "Harley"));
    barSeries2.DataPoints.Add(new CategoricalDataPoint(141, "White"));
    barSeries2.DataPoints.Add(new CategoricalDataPoint(130, "Smith"));
    barSeries2.DataPoints.Add(new CategoricalDataPoint(88, "Jones"));
    barSeries2.DataPoints.Add(new CategoricalDataPoint(109, "Marshall"));
    this.radChartView1.Series.Add(barSeries2);
}
 
private void Form1_Load(object sender, EventArgs e)
{
    foreach (UIChartElement element in this.radChartView1.Series[0].Children)
    {
        RadImageShape imageShape = new RadImageShape();
        imageShape.Image = Properties.Resources._2;
        element.BackColor = Color.Transparent;
        element.BackgroundShape = imageShape;
    }
}

I hope this information helps. Should you have further questions, I would be glad to help.

Regards,
Desislava
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Robert
Top achievements
Rank 1
answered on 22 Sep 2014, 07:59 AM
Yes! thank you, that works very well. I'll check out UIChartElements and RadImageShape for more features.

-Rob
Tags
ChartView
Asked by
Robert
Top achievements
Rank 1
Answers by
Dess | Tech Support Engineer, Principal
Telerik team
Robert
Top achievements
Rank 1
Share this question
or