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 6617739
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T20:44:25+00:00 2026-05-25T20:44:25+00:00

I am big problem for drawing two different charts on the same form… I

  • 0

I am big problem for drawing two different charts on the same form…

I have one form, in that form i have represented the pie chart with data coming from database that was working fine…..

and i have managed that when i click on the specific part on the pie chart i want to show two different graphs .. upto click event i have managaed but I am not able to show two different charts ….

and this is my below code…

public void mschart1_MouseClick(object sender, MouseEventArgs e)
{
    // here i am checking the condition to hit the exact location in chart

    Series serries;
    Series series2 = null;
    DataTable new1 = null; 
    new1  = mData.accountstatus(); 

    DataTable new2 = null; 
    new2 = mdata2.Totals(dtpStartDate.Value, dtpenddate.Value); 

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

    area = "area1"; 
    mschart1.ChartAreas.Add(area); 
    serries = mschart1.Series.Add(area); 
    serries.ChartArea = area; 

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

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

    area = "area2"; 
    mschart1.ChartAreas.Add(area); 
    series2 = mschart1.Series.Add(area); 
    series2.ChartArea = area; 

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

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

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

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

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

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

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

    if (new2 == null) 
    { 
        series2.Points.Clear(); 
        series2.Points.AddXY("no data", 0); 
    } 

    if(new1 == null) 
    { 
        serries.Points.Clear(); 
        serries.Points.AddXY("no data", 0); 
    } 
    mschart1.Series["area1"].Points.DataBindXY(new2.Rows, "data1", new2.Rows, "Value"); 
    mschart1.Series["area2"].Points.DataBindXY(new1.Rows, "name", new2.Rows, "count"); 

    if (area == "area1") 
    { 
        foreach (Series charttypes in mschart1.Series) 
        { 
            foreach (DataPoint point in charttypes.Points) 
            { 
                switch (point.AxisLabel) 
                { 
                    case "case1": point.Color = Color.Cyan; break; 
                    case "case2": point.Color = Color.Green; break; 
                } 
                point.Label = string.Format("{0:0} - {1}", point.YValues[0], point.AxisLabel); 
            } 
        } 
    } 
    if (area == "area2") 
    { 
        foreach (Series chartareas in mschart1.Series) 
        { 
            foreach (DataPoint point in chartareas.Points) 
            { 
                switch (point.AxisLabel) 
                { 
                    case "case23": point.Color = Color.Green; break; 
                    case "case 24": point.Color = Color.Blue; break; 
                } 
                point.Label = string.Format("{0:0}", point.YValues[0]); 
            } 
        } 
    } 
} 

my problem when i click on the chart in specific area it will shows two charts but both are same charts ..(i want two different type of charts as i have mentioned in the below code)

would any one pls help on this……

Many thanks…

  • 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-25T20:44:25+00:00Added an answer on May 25, 2026 at 8:44 pm

    I guess the problem is in the pieces (two) of code like this one:

    if (area == "area2") 
    { 
        foreach (Series charttypes in mschart1.Series) 
        { 
           charttypes.ChartType = SeriesChartType.Pie; 
           ...
        }
    } 
    if (area == "area1") 
    { 
        foreach (Series charttypes in mschart1.Series) 
        { 
           charttypes.ChartType = SeriesChartType.StackedColumn; 
           ...
        }
    }
    

    Since area variable is lastly set to "area2", only the first if condition will be reached and so the chart type will be always of type Pie.

    I think you should change your code to something like:

    foreach (Series charttypes in mschart1.Series) 
    { 
         if(charttypes.ChartArea == "area2")
         {
           charttypes.ChartType = SeriesChartType.Pie; 
           ...
         }
         else if(charttypes.ChartArea == "area1")
         {
           charttypes.ChartType = SeriesChartType.StackedColumn; 
           ...
         }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big problem. I want to extract text from html table that
I have a (big) problem that all of you that work with Webforms might
Hi I have one big problem with one MYSQL search. My database TABLE looks
I have this big problem that i dont know how to fix. I have
i have a big problem with umlauts. I have a normal registration Form. And
I have two panels: one that is always visible and another that gets declared
I have a big problem that I am capturing a view into a Bitmap
Big problem. I'm not sure what it was that I did, but it seems
I am in a big problem ..i have compiled my c files using linux
I have a very big problem. I am making a CRM (Costumer Relationship Management)

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.