Using predefined images as fill for bar charts

3 posts, 0 answers
  1. Robert
    Robert avatar
    2 posts
    Member since:
    Aug 2011

    Posted 17 Sep 2014 Link to this post

    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. Dess
    Admin
    Dess avatar
    1601 posts

    Posted 22 Sep 2014 Link to this post

    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.
     
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Robert
    Robert avatar
    2 posts
    Member since:
    Aug 2011

    Posted 22 Sep 2014 in reply to Dess Link to this post

    Yes! thank you, that works very well. I'll check out UIChartElements and RadImageShape for more features.

    -Rob
Back to Top