Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
I have created a user control which has a chart to display employee statistics over a period of time. I have used MSChart. I have 3 different series and i want to switch between them at runtime so that the user has an option to view different statistics. I have used legenditem and using it's postback value, I have parsed it. I have put all of this in an UpdatePanel
 
The problem is that whenever I click on the legendItem, the control is reloaded and the Chart Area becomes blank. Here is my code. Please help me.
 
protected void Chart1_Click(object sender, ImageMapEventArgs e)
        {
            // If user clicks on the map area attribute that corresponds to a legend item
            if (e.PostBackValue.StartsWith("LegendClick"))
            {
                string args = e.PostBackValue.Split('/')[1];
                // Identify which legend item was clicked
                int index = int.Parse(args);
 
                // Legend item result
                LegendItem legendItem = this.Chart1.Legends[0].CustomItems[index];
 
                // Resets all radio button images to be unchecked
                /* foreach (LegendItem item in this.Chart1.Legends[0].CustomItems)
                 {
                     item.Cells[0].ImageTransparentColor = Color.Black;
                     item.Cells[0].Image = "radio_button_unchecked.gif";
                 }
                 */
                for (; ; )
                {
 
                    switch (legendItem.Cells[1].Text)
                    {
                        case "Points":
                            this.Chart1.Series["series1"].Enabled = true;
                            this.Chart1.Series["series2"].Enabled = false;
                            this.Chart1.Series["series3"].Enabled = false;
                            this.Chart1.Series[0].ChartType = (SeriesChartType)Enum.Parse(typeof(SeriesChartType), "Line", true);
                            this.Chart1.Legends[0].CustomItems[0].Cells[0].Image = "radio_button_checked.gif";
                            break;
 
                        case "CSAT":
                            this.Chart1.Series["series1"].Enabled = false;
                            this.Chart1.Series["series2"].Enabled = true;
                            this.Chart1.Series["series3"].Enabled = false;
                            this.Chart1.Legends[0].CustomItems[1].Cells[0].Image = "radio_button_checked.gif";
                            break;
 
                        case "SLA":
                            this.Chart1.Series["series1"].Enabled = false;
                            this.Chart1.Series["series2"].Enabled = false; ;
                            this.Chart1.Series["series3"].Enabled = true;
                            this.Chart1.Legends[0].CustomItems[2].Cells[0].Image = "radio_button_checked.gif";
                            break;
 
                    }
                }
Posted 17-Oct-12 20:37pm
Edited 17-Oct-12 21:51pm
v3
Comments
lukeer at 18-Oct-12 2:36am
   
Use the "Improve question" link just below your question to provied further detail, be it of circumstances, error messages or whatever.
 
Don't create a new question for that. That way you more likely get a usable answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 18 Oct 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100