RadChartView in RadRotator

4 posts, 0 answers
  1. Javier
    Javier avatar
    10 posts
    Member since:
    Oct 2014

    Posted 04 Sep 2015 Link to this post

    Dear,
    I would like to know how I can add a radChartView a WinForms UI RadRotator
  2. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 07 Sep 2015 Link to this post

    Hello Javier,

    Thank you for writing.

    In order to show charts in RadRotator you can add a RadImageItem displaying the exported chart:
    public Form1()
    {
        InitializeComponent();
     
        for (int i = 0; i < 3; i++)
        {
            RadImageItem imageItem = new RadImageItem();
            imageItem.Image = GetChart(@"..\..\image" + i + ".png");
            this.radRotator1.Items.Add(imageItem);
        }
         radRotator1.Start(true);
    }
     
    private Image GetChart(string filePath)
    {
        RadChartView chart = new RadChartView();
        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"));
        chart.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"));
        chart.Series.Add(barSeries2);
     
        chart.ExportToImage(filePath,this.radRotator1.Size);
        Thread.Sleep(10);
        return new Bitmap(filePath);
    }

    An alternative solution is to use a RadHostItem with RadChartView
    public Form1()
    {
        InitializeComponent();
     
        for (int i = 0; i < 3; i++)
        {
            RadHostItem hostChart = new RadHostItem(GetChart());
            this.radRotator1.Items.Add(hostChart);
        }
         radRotator1.Start(true);
    }
     
    private Control GetChart()
    {
        RadChartView chart = new RadChartView();
        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"));
        chart.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"));
        chart.Series.Add(barSeries2);
     
     
        return chart;
    }

    I hope this information helps. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
  3. UI for WinForms is Visual Studio 2017 Ready
  4. Javier
    Javier avatar
    10 posts
    Member since:
    Oct 2014

    Posted 09 Sep 2015 in reply to Dess Link to this post

    Thanks, I'll try it and you will comment on how I was.
  5. Dess
    Admin
    Dess avatar
    1609 posts

    Posted 10 Sep 2015 Link to this post

    Hello Javier,

    Thank you for writing back.
     
    Feel free to get back to us whenever is suitable for you. If you have any additional questions, please let me know.

    Regards,
    Dess
    Telerik
    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 Feedback Portal and vote to affect the priority of the items
Back to Top