Jump to content

 

Photo

White screen with a dynamic pie chart


  • Please log in to reply
1 reply to this topic

#1 Handball95

Handball95

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 13 April 2012 - 09:20 AM

Hello

I've got a problem on Silverlight and I can't understand where it's coming from :unsure:
I use the code below to display pie charts dynamically. I've replaced the click event and added an handler on the MouseLeftButtonUp event.
That's where my problems start :rolleyes: The animations are really slow, and sometimes, without any reason, I get a white screen, but no exception seem to be thrown.
It's probably linked to a sequential problem, but I'm not an expert on the subject and I'm waiting for a miracle since yesterday <_<

Does anybody have an idea? Thanks for your help.

public static void setGraphValues(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
                UCCircleGraph me = d as UCCircleGraph;

                //Si non définis, on définit les éléments de la view
                if (me.CategoriesSerie == null)
                {
                    me.CategoriesSerie = me.ChartCircleCategories.Series[0];
                }

                me.CategoriesSerie.DataPoints.Clear();
                if (me.FirstLoad)
                {
                    me.CategoriesSerie.MouseLeftButtonUp += (s, f) => CategoriesSerie_MouseLeftButtonUp(s, f, me);
                }

                if (me.Datas.Count != 0)
                {
                    if (me.GraphMode.Mode == BudgetCategorySelectionMode.OneType)
                    {
                        MouseButtonEventHandler datapointClick = null;
                        datapointClick = (s, f) =>
                        {
                            DataPoint dataPointClicked = s as DataPoint;

                            if (me.CategoriesSerie != null && me.Datas.Where(o => o.Category.Title == dataPointClicked.LegendText).Count() != 0)
                            {
                                BudgetCategory category = me.Datas.SingleOrDefault(o => o.Category.Title == dataPointClicked.LegendText).Category;
                                if (category.Parent == null)
                                {
                                    BudgetCategorySelection budgetCategorySelection = BudgetCategorySelection.SelectOneCategory(category);
                                    me.GraphMode = budgetCategorySelection;
                                    me.CategoriesSerie.MouseLeftButtonUp -= datapointClick;

                                }
                            }
                        };
                        me.CategoriesSerie.MouseLeftButtonUp += datapointClick;

                    }

                }

                double sum = (double)me.Datas.Sum(o => o.Value);

                me.CategoriesSerie.MouseEnter += (a, <img src='http://www.visifire.com/forums/public/style_emoticons/<#EMO_DIR#>/cool.gif' class='bbc_emoticon' alt='B)' /> => category_MouseEnter(a, b, me);
                foreach (BudgetCircleGraphData data in me.Datas)
                {
                    DataPoint category = new DataPoint();
                    category.LegendText = data.Category.Title;
                    category.LabelText = data.Category.Title;
                    category.BorderThickness = new Thickness(1);
                    category.BorderColor = new SolidColorBrush(Colors.LightGray);
                    category.Color = new SolidColorBrush(data.Category.Color);
                    category.YValue = (double)data.Value;
                    decimal percentage = Math.Round((decimal)(100 * category.YValue / sum), 2);
                    category.ToolTipText = String.Format("{1}:\n{2}€ - {0}%", percentage, data.Category.Title, (double)data.Value);
                    //category.MouseLeave += new EventHandler<MouseEventArgs>(category_MouseLeave);
                    me.CategoriesSerie.DataPoints.Add(category);
                }



                if (me.Datas.Count == 0)
                {
                    me.NoDataTextBlock.Visibility = Visibility.Visible;
                }
                else
                {
                    me.NoDataTextBlock.Visibility = Visibility.Collapsed;
                }
            }
        }

        static void CategoriesSerie_MouseLeftButtonUp(object sender, MouseButtonEventArgs e, UCCircleGraph pMe)
        {
            pMe.FirstLoad = false;
        }



        static void category_MouseEnter(object sender, MouseEventArgs e, UCCircleGraph pMe)
        {
            DataPoint me = sender as DataPoint;
            foreach (DataPoint d in pMe.CategoriesSerie.DataPoints.Where(o => o.Exploded == true))
            {
                d.Exploded = false;
            }
            me.Exploded = true;
            }

        }



#2 vivek

vivek

    Advanced Member

  • Team Visifire
  • PipPipPip
  • 3,587 posts
  • Gender:Male
  • Location:Bangalore

Posted 16 April 2012 - 05:42 AM

Hi,

Are you getting this problem only while clicking on the DataPoint? If yes, can you please tell me what operation you are doing in chart using the following code.

BudgetCategorySelection budgetCategorySelection = BudgetCategorySelection.SelectOneCategory(category);
me.GraphMode = budgetCategorySelection;

Regards,
Vivek
Team Visifire





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users