public void Stacked_Chart(bool change)
        {
            DateTime from_month      = new DateTime();
            DateTime to_month        = new DateTime();
            string   selected_person = "";

            Dispatcher.Invoke(() =>
            {
                from_month      = new DateTime(Convert.ToDateTime(date_month_from.SelectedDate).Year, Convert.ToDateTime(date_month_from.SelectedDate).Month, 1);
                to_month        = Convert.ToDateTime(date_month_to.SelectedDate);
                selected_person = HoldersItems.Where(r => r.IsChecked == true).Select(x => x.HolderName).First();
                StackedSeriesCollection.Clear();
            });

            DataTable dt = BrokerageAsset.GetHistoricalInvestments(selected_person, null, null, from_month, to_month);

            IEnumerable <string> selectcategories = InvestmentCategory.Getcategories();

            Brush[] colors = { Brushes.DarkGreen, Brushes.ForestGreen, Brushes.Gainsboro, Brushes.DimGray, Brushes.Gold, Brushes.Orange, Brushes.DarkBlue };
            Dispatcher.Invoke(() =>
            {
                int count = 0;
                foreach (string category in selectcategories)
                {
                    ChartValues <DateModel> chartvalues = new ChartValues <DateModel>(dt.AsEnumerable().Where(r => r["category"].ToString() == category)
                                                                                      .Select(r => new DateModel {
                        DateTime = r.Field <DateTime>("date"), Value = r.Field <double?>("ending_mkt_value") ?? 0
                    }));
                    if (chartvalues.Count != 0)
                    {
                        StackedSeriesCollection.Add(new StackedColumnSeries
                        {
                            Values         = chartvalues,
                            StackMode      = StackMode.Values,
                            Title          = category,
                            Fill           = colors[count],
                            DataLabels     = true,
                            LabelPoint     = point => (point.Y / 1000).ToString("C1") + "k",
                            LabelsPosition = BarLabelPosition.Perpendicular,
                            Foreground     = Brushes.Black
                        });
                        count++;
                    }
                }
            });

            if (!change)
            {
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.DataBind, (Action)(() =>
                {
                    DataContext = this;
                }));
            }
        }
        public void StackedAsset_Chart(bool change, string category)
        {
            DateTime from_month      = new DateTime();
            DateTime to_month        = new DateTime();
            string   selected_person = "";
            Regex    regex           = new Regex(@"\d{1,2}\/\d{1,2}\/\d{4}");

            Dispatcher.Invoke(() =>
            {
                label_assetclass.Text = category + " Allocation";

                from_month      = new DateTime(Convert.ToDateTime(date_month_from.SelectedDate).Year, Convert.ToDateTime(date_month_from.SelectedDate).Month, 1);
                to_month        = Convert.ToDateTime(date_month_to.SelectedDate);
                selected_person = HoldersItems.Where(r => r.IsChecked == true).Select(x => x.HolderName).First();
                StackedSeriesCollection2.Clear();
            });

            string    asset_column = (new [] { "Treasuries", "Bonds", "CDs" }.Contains(category) ? "asset_description" : "asset_symbol");
            DataTable dt           = BrokerageAsset.GetHistoricalInvestments(selected_person, category, asset_column, from_month, to_month);

            string[] assets = dt.AsEnumerable().Select(r => r[asset_column].ToString()).Distinct()
                              .OrderBy(s => (regex.IsMatch(s) ? Convert.ToDateTime(regex.Match(s).Value).ToString("yyyyMMdd") : s))
                              .ToArray();
            Dispatcher.Invoke(() =>
            {
                if (assets.Length > 8)
                {
                    chartStackedAsset.LegendLocation = LegendLocation.None;
                }
                else
                {
                    chartStackedAsset.LegendLocation = LegendLocation.Top;
                }

                foreach (string asset in assets)
                {
                    ChartValues <DateModel> chartvalues = new ChartValues <DateModel>(dt.AsEnumerable().Where(r => r[asset_column].ToString() == asset)
                                                                                      .Select(r => new DateModel {
                        DateTime = r.Field <DateTime>("date"), Value = r.Field <double?>("ending_mkt_value") ?? 0
                    }));
                    if (chartvalues.Count != 0)
                    {
                        StackedSeriesCollection2.Add(new StackedColumnSeries
                        {
                            Values         = chartvalues,
                            StackMode      = StackMode.Values,
                            Title          = (regex.IsMatch(asset) ? regex.Match(asset).Value : asset),
                            DataLabels     = (assets.Length > 8 ? false : true),
                            LabelPoint     = point => (point.Y / 1000).ToString("C1") + "k",
                            LabelsPosition = BarLabelPosition.Perpendicular,
                            Foreground     = System.Windows.Media.Brushes.Black
                        });
                    }
                }
            });

            if (!change)
            {
                Dispatcher.Invoke(System.Windows.Threading.DispatcherPriority.DataBind, (Action)(() =>
                {
                    DataContext = this;
                }));
            }
        }