How to toggle between 2 chart screens using winforms Syncfusion chart controls

Hi,

I need to show a chart with a set of plots and then provide a link in its toolbar to switch to another chart which has a different set of plots.

How can this be accomplished using Syncfusion chartControl?


Thanks,

Vidya



4 Replies 1 reply marked as answer

NM Nanthini Mahalingam Syncfusion Team November 28, 2022 09:39 AM UTC

Hi Vidya Suryanarayana,


Thanks for the update. We are validating the toggle between two chart screens by using the tool bar, and we will update the complete details on November 28th, 2022.


Regards,

Nanthini Mahalingam.



NM Nanthini Mahalingam Syncfusion Team November 29, 2022 12:03 PM UTC

We have analyzed your query and you can show the chart with different sets of plot data by using custom tool bar items as per the code below and sample attachment. Also the chart tool bar items contains to change the type of chart based on the requirement.


ChartToolBarItem chartToolBarItem = new ChartToolBarItem();

            chartToolBarItem.Name = "1K";

            chartToolBarItem.Image =

                System.Drawing.Image.FromFile(@"… \Pictures\Screenshots\imageTwo.jpg");

            chartOne.ToolBar.Items.Add(chartToolBarItem);

            chartOne.ToolBar.ItemClick += ToolBar_ItemClick;


   private void ToolBar_ItemClick(object sender, EventArgs e)

        {

            if(((sender as ChartToolBarItem) as ChartToolBarItemBase).Name == "1K")

            {

                Random random = new Random();

                BindingList<ActivitiesDisplayModel> dataSourceOne =

                    new BindingList<ActivitiesDisplayModel>();

                DateTime date = new DateTime(2022, 4, 1);

                for (int i = 0; i < 1000; i++)

                {

                    dataSourceOne.Add(new ActivitiesDisplayModel()

                    {

                        Date = date.AddDays(i),

                        Movement = random.Next(40, 70),

 

                    });

                }

 

                ChartDataBindModel dataSeriesModelTwo = new ChartDataBindModel(dataSourceOne);

                dataSeriesModelTwo.XName = "Date";

                dataSeriesModelTwo.YNames = new string[] { "Movement" };

                seriesOne.SeriesModel = dataSeriesModelTwo;

            }

        }


Please refer this document: https://help.syncfusion.com/windowsforms/chart/runtime-features#toolbars

Output Demo: 



Attachment: SF179060_b6c84ae2.zip


VS Vidya Suryanarayana November 30, 2022 11:12 AM UTC

Thank you!

So you are toggling datasource on the same chartcontrol right?

I was trying to maintain 2 chartcontrols and toggle their visibility.

WIll that be possible?


Thanks.

Vidya




NM Nanthini Mahalingam Syncfusion Team December 1, 2022 03:15 PM UTC

Hi Vidya Suryanarayana,


Thanks for your update,

We analyzed your query, and we can achieve the two chart controls switching states in tool bar items using their chart Visible property as per the code snippet and also the sample attachment.

        private void ToolBar_ItemClick1(object sender, EventArgs e)

        {

            var toolBar = sender as ChartToolBarItem;

            if(toolBar.Name == "FirstChart100Data")

            {

                chartTwo.Visible = true;

                chartOne.Visible = false;

            }

        }

 

        private void ToolBar_ItemClick2(object sender, EventArgs e)

        {

            var toolBar = sender as ChartToolBarItem;

            if (toolBar.Name == "SecondChart200Data")

            {

                chartTwo.Visible = false;

                chartOne.Visible = true;

            }

        }


Chart one output demo:

Chart two output demo:



Attachment: SF179060_f747c2ac.zip

Marked as answer
Loader.
Up arrow icon