Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:26:20+00:00 2026-05-25T13:26:20+00:00

hi I am trying to represent the two graphs(pie chart and bar chart) on

  • 0

hi I am trying to represent the two graphs(pie chart and bar chart) on one form using mschart controls….the data is coming from database ….

I am using single chart(kpichart) control to represent the two graphs ….

for that i ahve wrrittent teh below code

In this code i have defined two different areas to defining two graphs…..

       public void KpiMembers_MouseClick(object sender, MouseEventArgs e)
       {

        Series statusseries;
        Series liveserries = null;
        string area;
        Title title;

        try
        {
            var pos = e.Location;
            var results = KpiMembersTotalchart.HitTest(pos.X, pos.Y, false, ChartElementType.DataPoint);
            foreach (var result in results)
            {
                if (result.ChartElementType == ChartElementType.DataPoint)
                {
                    if (result.Series.Points[result.PointIndex].AxisLabel == "Live")
                    {
                        DataTable Livemembers = null;
                        Livemembers = KpiData.livemembersmembershipstatus();

                        DataTable membersalltotals = null;
                        membersalltotals = kpimembtotals.membershipTotals(dtpStartDate.Value, dtpenddate.Value);

                        KpiMembersTotalchart.ChartAreas.Clear();
                        KpiMembersTotalchart.Titles.Clear();
                        KpiMembersTotalchart.Series.Clear();


                        area = "newchart";
                        KpiMembersTotalchart.ChartAreas.Add(area);
                        liveserries = KpiMembersTotalchart.Series.Add(area);
                        liveserries.ChartArea = area;

                        title = KpiMembersTotalchart.Titles.Add("Memberstotalspoints");
                        title.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                        title.Alignment = ContentAlignment.TopLeft;
                        title.DockedToChartArea = area;


                        KpiMembersTotalchart.Titles.Add("").DockedToChartArea = area;

                        area = "subchart";
                        KpiMembersTotalchart.ChartAreas.Add(area);
                        statusseries = KpiMembersTotalchart.Series.Add(area);
                        statusseries.ChartArea = area;


                        title = KpiMembersTotalchart.Titles.Add("Live Status members by status");
                        title.Font = new Font(FontFamily.GenericSansSerif, 10, FontStyle.Bold);
                        title.Alignment = ContentAlignment.TopLeft;
                        title.DockedToChartArea = area;

                        KpiMembersTotalchart.Titles.Add("").DockedToChartArea = area;



                        foreach (Title chartTitle in KpiMembersTotalchart.Titles)
                        {
                            chartTitle.IsDockedInsideChartArea = false;
                        }

                        foreach (ChartArea chartArea in KpiMembersTotalchart.ChartAreas)
                        {
                            chartArea.Area3DStyle.Enable3D = true;
                            chartArea.AxisX.LabelStyle.IsEndLabelVisible = true;

                        }

                        if (area == "subchart")
                        {
                            foreach (Series charttypes in KpiMembersTotalchart.Series)
                            {
                                charttypes.ChartType = SeriesChartType.Pie;
                                charttypes["PielabelStyle"] = "Outside";
                                charttypes["DoughnutRadius"] = "30";
                                charttypes["PieDrawingStyle"] = "SoftEdge";
                                charttypes.BackGradientStyle = GradientStyle.DiagonalLeft;

                            }

                        }

                        if (area == "newchart")
                        {
                            foreach (Series chartareas in KpiMembersTotalchart.Series)
                            {
                                chartareas.ChartType = SeriesChartType.StackedColumn;
                                chartareas["ColumnDrawingStyle"] = "SoftEdge";
                                chartareas["LabelStyle"] = "Top";
                                chartareas.IsValueShownAsLabel = true;
                                chartareas.BackGradientStyle = GradientStyle.DiagonalLeft;
                            }
                        }


                        foreach (Legend legend in KpiMembersTotalchart.Legends)
                        {
                            legend.Enabled = false;
                        }

                        if (membersalltotals == null)
                        {
                            statusseries.Points.Clear();
                            statusseries.Points.AddXY("no status", 0);

                        }

                        if(Livemembers == null)
                        {

                            liveserries.Points.Clear();
                            liveserries.Points.AddXY("no membershipe", 0);

                        }
                        KpiMembersTotalchart.Series["newchart"].Points.DataBindXY(membersalltotals.Rows, "Status", membersalltotals.Rows, "Value");
                        KpiMembersTotalchart.Series["subchart"].Points.DataBindXY(Livemembers.Rows, "mshipname", Livemembers.Rows, "count");

                        if (area == "subchart")
                        {
                            foreach (Series charttypes in KpiMembersTotalchart.Series)
                            {
                                foreach (DataPoint point in charttypes.Points)
                                {
                                    switch (point.AxisLabel)
                                    {
                                        case "New": point.Color = Color.Cyan; break;
                                        case "Live": point.Color = Color.Green; break;
                                        case "Defaulter": point.Color = Color.Red; break;
                                        case "Cancelled": point.Color = Color.Orange; break;
                                        case "Completed": point.Color = Color.Blue; break;
                                        case "Frozen": point.Color = Color.Violet; break;
                                    }

                                    point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel);
                                }
                            }
                        }
                        if (area == "newchart")
                        {
                            foreach (Series chartareas in KpiMembersTotalchart.Series)
                            {
                                foreach (DataPoint point in chartareas.Points)
                                {

                                    switch (point.AxisLabel)
                                    {
                                        case "Silver membership": point.Color = Color.Green; break;
                                        case "Gold Membership": point.Color = Color.Blue; break;
                                        //case "Refused": point.Color = Color.Red; break;
                                        case "Weekend Peak": point.Color = Color.Cyan; break;
                                        case "prspect": point.Color = Color.Indigo; break;

                                    }
                                    point.Label = string.Format("{0:0}", point.YValues[0]);
                                }

                            }
                        }
                    }

                }
            }
        }
        catch { }

    }

My problem is i am trying to showing the two different charts (one is pie chart and another one is stacked column chart)….

but it was showing two same charts (both are pie charts) see the below diagramenter image description here

I want to show the stacked column chart instead of pie chart in second one….but it was showing two same charts(pie )

i have divided the total form in to two areas …..

What I have to do to show the two different graphs on same form using single chart control

would any one pls help on this….

Many Thanks in advance for any ideas …..

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:26:20+00:00Added an answer on May 25, 2026 at 1:26 pm

    This is a simple problem with the logic in your code.

    Your code currently reads:

                        area = "newchart";
                        ......
                        area = "subchart";
                        ......
                        if (area == "subchart")
                        ......
                        if (area == "newchart")
    

    This obviously will always evaluate the first “if” to “true” and the second “if” to “false”. You need to reorganise your code so that it doesn’t use area like this – you need to step back and rewrite your logic that creates the charts you need.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some data about opening hours I'm trying to represent using Joda-Time. The
I'm trying to represent a two-dimensional coordinate grid with a two-dimensional array. Problem is,
Am trying to solve a labyrinth by DFS, using adj List to represent the
I'm trying to plot two sets of data wrt to time on the same
I have an interesting problem trying to represent complex schedule data in a database.
I am trying to compare two byte arrays in memory and produce a data
I'm currently trying to convert xml values that represents two times. example: <from>960</from> <to>975</to>
I'm trying to remove illegal chars from a string that represent path or filename
I need to be able to compute differences between two data/time values which represent
I’m trying to write a web app using 4-tier design pattern ( Data Store,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.