Exemplo n.º 1
0
        public static void ApplyChartStyles(ChartControl chart)
        {
            #region ApplyCustomPalette
            chart.Skins = Skins.Metro;
            #endregion

            #region chart appearance customization
            chart.ShowLegend = false;
            chart.BorderAppearance.SkinStyle      = Syncfusion.Windows.Forms.Chart.ChartBorderSkinStyle.None;
            chart.BorderAppearance.FrameThickness = new ChartThickness(-2, -2, 2, 2);
            chart.PrimaryXAxis.DrawGrid           = false;
            #endregion

            #region Chart axes customization
            chart.PrimaryXAxis.TickSize = new System.Drawing.Size(1, 5);
            chart.PrimaryYAxis.TickSize = new System.Drawing.Size(5, 1);
            chart.LegendsPlacement      = ChartPlacement.Outside;
            #endregion

            #region Legend Customization
            //Adds Custom legend to chart control
            ChartLegend legend1 = new ChartLegend(chart);
            legend1.Name = "legend1";
            legend1.RepresentationType = ChartLegendRepresentationType.None;
            legend1.Position           = ChartDock.Bottom;
            legend1.Alignment          = ChartAlignment.Center;
            ChartLegendItem[]          customItems = new ChartLegendItem[0];
            ChartLegendItemsCollection clic        = new ChartLegendItemsCollection();
            ChartLegendItem            cli1        = new ChartLegendItem("Press Esc to Cancel Zooming");
            clic.Add(cli1);
            legend1.CustomItems = clic.ToArray();
            chart.Legends.Add(legend1);
            #endregion
        }
Exemplo n.º 2
0
        /// <summary>
        /// The GetLegend
        /// </summary>
        /// <param name="chart">The chart<see cref="ChartControl"/></param>
        /// <returns>The <see cref="ChartLegend"/></returns>
        internal ChartLegend GetLegend(ChartControl chart)
        {
            try
            {
                if (Chart.Legends != null)
                {
                    Chart.Legends.Clear();
                }

                ChartLegend legend = new ChartLegend(Chart);
                foreach (string axislabel in Chart.PrimaryXAxis.Labels)
                {
                    ChartLegendItem item = new ChartLegendItem(axislabel);
                }

                legend.VisibleCheckBox = true;
                Chart.Legends.Add(legend);
                return(legend);
            }
            catch (Exception e)
            {
                new Error(e).ShowDialog();
                return(null);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Initializes the ChartControl's data and sets the Chart type
        /// </summary>
        protected void InitializeChartData()
        {
            ChartSeries series1 = new ChartSeries();

            series1.Name = "Year 2004";
            series1.Text = series1.Name;
            series1.Points.Add(0, 10);
            series1.Points.Add(1, 8);
            series1.Points.Add(2, 24);
            series1.Points.Add(3, 24);
            series1.Points.Add(4, 10);
            series1.Points.Add(5, 24);
            SeriesSettings(series1);
            this.chartControl1.Series.Add(series1);
            series1.ConfigItems.PieItem.ShowSeriesTitle = true;
            series1.ConfigItems.PieItem.LabelStyle      = ChartAccumulationLabelStyle.Inside;

            ChartSeries series2 = new ChartSeries();

            series2.Name = "Year 2005";
            series2.Text = series2.Name;
            series2.Points.Add(0, 12);
            series2.Points.Add(1, 10);
            series2.Points.Add(2, 18);
            series2.Points.Add(3, 25);
            series2.Points.Add(5, 15);
            series2.Points.Add(6, 20);
            SeriesSettings(series2);
            this.chartControl1.Series.Add(series2);
            series2.ConfigItems.PieItem.ShowSeriesTitle = true;
            series2.ConfigItems.PieItem.LabelStyle      = ChartAccumulationLabelStyle.Inside;

            this.chartControl1.ChartArea.DivideArea = true;
            ChartLegend chartLegend = new ChartLegend();

            chartLegend.Name = "Legend 1";
            string[] label = new string[] { "Engineering", "Medical Sciences", "BioTechnology", "Information Services", "Art and Humanities", "Geography" };
            List <ChartLegendItem> items = new List <ChartLegendItem>();

            for (int i = 0; i < 6; i++)
            {
                ChartLegendItem legendItem = new ChartLegendItem(label[i]);
                legendItem.Font = new Font("Segoe UI", 10F);
                legendItem.RepresentationSize = new Size(15, 15);
                legendItem.TextColor          = Color.Black;
                legendItem.Border.Color       = Color.Transparent;
                items.Add(legendItem);
            }
            chartControl1.Legend.RepresentationType = ChartLegendRepresentationType.SeriesType;

            chartControl1.Legend.CustomItems    = items.ToArray();
            chartControl1.Legend.RowsCount      = 2;
            this.chartControl1.LegendAlignment  = ChartAlignment.Center;
            this.chartControl1.LegendPosition   = ChartDock.Bottom;
            this.chartControl1.LegendsPlacement = ChartPlacement.Outside;
            this.chartControl1.LegendsPlacement = ChartPlacement.Outside;
            this.chartControl1.ShowLegend       = true;
            this.chartControl1.SmoothingMode    = SmoothingMode.AntiAlias;
        }
Exemplo n.º 4
0
 /// <summary>
 /// Chart laoded event
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void chPCE_Loaded(object sender, RoutedEventArgs e)
 {
     if (chPCE.DefaultView.ChartLegend.Items.Count != 0)
     {
         ChartLegendItem var = this.chPCE.DefaultView.ChartLegend.Items[0];
         this.chPCE.DefaultView.ChartLegend.Items.Remove(var);
     }
 }
Exemplo n.º 5
0
        private void InitializeControlSettings()
        {
            ChartLegend legend1 = new ChartLegend(chartControl1);

            legend1.Name               = "legend1";
            legend1.ColumnsCount       = 1;
            legend1.RowsCount          = 1;
            legend1.RepresentationType = ChartLegendRepresentationType.None;
            legend1.ShowSymbol         = false;
            legend1.Position           = ChartDock.Bottom;
            legend1.Alignment          = ChartAlignment.Center;

            ChartLegendItem[]          customItems = new ChartLegendItem[0];
            ChartLegendItemsCollection clic        = new ChartLegendItemsCollection();
            ChartLegendItem            cli1        = new ChartLegendItem("That follows a series point");

            cli1.Type               = ChartLegendItemType.Circle;
            cli1.Border.Color       = Color.Transparent;
            cli1.RepresentationSize = new Size(8, 8);
            cli1.Interior           = new BrushInfo(Color.FromArgb(0Xc1, 0X39, 0x2b));
            clic.Add(cli1);

            ChartLegendItem cli2 = new ChartLegendItem("That uses chart coordinates");

            cli2.Type = ChartLegendItemType.InvertedTriangle;
            cli2.RepresentationSize = new Size(8, 8);
            cli2.Interior           = new BrushInfo(Color.FromArgb(0Xfc, 0Xec, 0X29));
            clic.Add(cli2);

            ChartLegendItem cli3 = new ChartLegendItem("That follows a percent type");

            cli3.Type = ChartLegendItemType.Pentagon;
            cli3.RepresentationSize = new Size(8, 8);
            cli3.Interior           = new BrushInfo(Color.FromArgb(0X00, 0X66, 0Xcc));
            clic.Add(cli3);

            ChartLegendItem cli4 = new ChartLegendItem("That follows a pixel type");

            cli4.Type = ChartLegendItemType.Triangle;
            cli4.RepresentationSize = new Size(8, 8);
            cli4.Interior           = new BrushInfo(Color.FromArgb(0X00, 0Xce, 0X45));
            clic.Add(cli4);

            legend1.CustomItems = clic.ToArray();
            chartControl1.Legends.Add(legend1);
            chartControl1.ShowToolTips = true;
        }
Exemplo n.º 6
0
        /// <summary>
        /// Chart Loaded Event Handler
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chChartExtension_Loaded(object sender, RoutedEventArgs e)
        {
            string methodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);

            Logging.LogBeginMethod(this.DataContextSlice1ChartExtension.logger, methodNamespace);
            try
            {
                if (chChartExtension.DefaultView.ChartLegend.Items.Count != 0)
                {
                    ChartLegendItem var = this.chChartExtension.DefaultView.ChartLegend.Items[0];
                    this.chChartExtension.DefaultView.ChartLegend.Items.Remove(var);
                }
            }
            catch (Exception ex)
            {
                Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                Logging.LogException(this.DataContextSlice1ChartExtension.logger, ex);
            }
        }
Exemplo n.º 7
0
        void Legend_DrawItemText(object sender, ChartLegendDrawItemTextEventArgs e)
        {
            //Get current Legend item
            ChartLegendItem item = sender as ChartLegendItem;
            //current item bounds value
            RectangleF textRect = e.TextRect;

            //Text split for description and value text by mentionted symbol in Text property
            string[] mulText = e.Text.Split('-');
            //Get Max size of text from legend item collection
            Size[] itemMaxSize = MeasureSize(e.Graphics, this.chartControl1.Legend.Items, mulText.Length);

            for (int i = 0; mulText.Length > i; i++)
            {
                //Get current text size
                SizeF currentText = e.Graphics.MeasureString(mulText[i], item.Font);
                if (i > 0)
                {
                    //Calculate value text position
                    textRect.X = textRect.Width;
                    //If you need more space between description and values text, add hard values for textRect.Widht( textRect.Width += itemMaxSize(i).Width+10)
                    textRect.Width += itemMaxSize[i].Width - 24;
                    //Hard code 30 for space between decs and values
                    //Align text for "Far" alignment
                    textRect.X += (textRect.Width - textRect.X) - currentText.Width;
                }
                else
                {
                    //Calculate description text position
                    textRect = new RectangleF(textRect.X, textRect.Y, itemMaxSize[i].Width, currentText.Height);
                }
                //Draw the text
                using (Brush sb = new SolidBrush(item.TextColor))
                {
                    e.Graphics.DrawString(mulText[i], item.Font, sb, textRect);
                }
            }
            //Set "True" to handled property to draw the legend custom text properly.
            e.Handled = true;
        }
Exemplo n.º 8
0
        public void InitialiseData()
        {
            chartControl1.Series.Clear();

            Random      random  = new Random();
            ChartSeries series1 = new ChartSeries();

            series1.Name = "Year 2006";
            series1.Text = series1.Name;
            series1.Points.Add(0, 20);
            series1.Points.Add(2, 18);
            series1.Points.Add(3, 21);
            series1.Points.Add(4, 23);
            series1.Points.Add(5, 18);
            SeriesSettings(series1);
            this.chartControl1.Series.Add(series1);

            ChartSeries series2 = new ChartSeries();

            series2.Name = "Year 2007";
            series2.Text = series2.Name;
            series2.Points.Add(0, 12);
            series2.Points.Add(2, 21);
            series2.Points.Add(3, 18);
            series2.Points.Add(4, 25);
            series2.Points.Add(5, 24);
            SeriesSettings(series2);
            this.chartControl1.Series.Add(series2);

            ChartSeries series3 = new ChartSeries();

            series3.Name = "Year 2008";
            series3.Text = series3.Name;
            series3.Points.Add(0, 18);
            series3.Points.Add(2, 12);
            series3.Points.Add(3, 18);
            series3.Points.Add(4, 21);
            series3.Points.Add(5, 31);
            SeriesSettings(series3);
            this.chartControl1.Series.Add(series3);

            //Enable MultiplePies property to enable this feature.
            chartControl1.ChartArea.MultiplePies = true;
            this.chartControl1.ShowLegend        = true;

            series1.Type = ChartSeriesType.Pie;
            series2.Type = ChartSeriesType.Pie;
            series3.Type = ChartSeriesType.Pie;

            //Each series must have DoughnutCoEfficient value [except the most inner series example: series1], to get the complete functionality of this feature.
            series2.ConfigItems.PieItem.DoughnutCoeficient = 0.7f;
            series3.ConfigItems.PieItem.DoughnutCoeficient = 0.8f;

            series3.ConfigItems.PieItem.AngleOffset = 130f;
            series2.ConfigItems.PieItem.AngleOffset = 130f;
            series1.ConfigItems.PieItem.AngleOffset = 130f;

            ChartLegend chartLegend = new ChartLegend();

            chartLegend.Name = "Legend 1";
            string[] label = new string[] { "Engineering-13.33%", "Medical Sciences-16.67%", "BioTechnology-30%", "Information Services-23%", "Economics -27%" };
            List <ChartLegendItem> items = new List <ChartLegendItem>();

            for (int i = 0; i < 5; i++)
            {
                ChartLegendItem legendItem = new ChartLegendItem(label[i]);
                legendItem.Font = new Font("Segoe UI", 9, FontStyle.Regular);
                legendItem.RepresentationSize = new Size(16, 16);
                items.Add(legendItem);
            }

            chartControl1.Legend.RepresentationType = ChartLegendRepresentationType.SeriesType;
            chartControl1.Legend.CustomItems        = items.ToArray();
            chartControl1.Legend.RowsCount          = 5;
            this.chartControl1.LegendAlignment      = ChartAlignment.Center;
            this.chartControl1.SmoothingMode        = SmoothingMode.AntiAlias;
            this.chartControl1.Legend.DrawItemText += new LegendDrawItemTextEventHandler(Legend_DrawItemText);

            if (ckBxEnable3D.Checked)
            {
                this.lblPieHeight.Visible     = true;
                this.nUpDownPieHeight.Visible = true;
            }
            else
            {
                this.lblPieHeight.Visible     = false;
                this.nUpDownPieHeight.Visible = false;
            }
        }
Exemplo n.º 9
0
        public static void ApplyChartStyles(ChartControl chart)
        {
            #region chart Skin
            chart.Skins = Skins.Metro;
            #endregion

            #region Chart Appearance Customization
            chart.BorderAppearance.SkinStyle      = Syncfusion.Windows.Forms.Chart.ChartBorderSkinStyle.None;
            chart.BorderAppearance.BaseColor      = Color.DarkOliveGreen;
            chart.BorderAppearance.FrameThickness = new ChartThickness(-2, -2, 2, 2);
            chart.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            chart.ChartArea.PrimaryXAxis.HidePartialLabels = true;
            chart.ElementsSpacing = 5;

            #endregion

            #region Axes Customization

            chart.PrimaryXAxis.HidePartialLabels = true;
            chart.PrimaryYAxis.HidePartialLabels = true;
            chart.Zooming.ShowBorder             = true;
            chart.Zooming.Opacity = 0.6f;
            chart.GetVScrollBar(chart.PrimaryYAxis).ZoomButton.Size = new Size(0, 0);
            chart.GetHScrollBar(chart.PrimaryXAxis).ZoomButton.Size = new Size(0, 0);
            chart.EnableXZooming                     = true;
            chart.EnableYZooming                     = true;
            chart.ZoomFactorX                        = 1;
            chart.ZoomFactorX                        = 1;
            chart.ShowScrollBars                     = true;
            chart.ResetOnDoubleClick                 = true;
            chart.ZoomType                           = ZoomType.Selection | ZoomType.PinchZooming;
            chart.SmoothingMode                      = System.Drawing.Drawing2D.SmoothingMode.AntiAlias;
            chart.PrimaryXAxis.Title                 = "Year";
            chart.PrimaryYAxis.Title                 = "Temperature";
            chart.PrimaryXAxis.Range                 = new Syncfusion.Windows.Forms.Chart.MinMaxInfo(1850, 2007, 40);
            chart.PrimaryXAxis.RangeType             = Syncfusion.Windows.Forms.Chart.ChartAxisRangeType.Set;
            chart.PrimaryXAxis.LabelIntersectAction  = ChartLabelIntersectAction.MultipleRows;
            chart.PrimaryXAxis.EdgeLabelsDrawingMode = ChartAxisEdgeLabelsDrawingMode.Shift;

            #endregion

            #region Legend Customization
            for (int i = 0; i < chart.Legend.Items.Length; i++)
            {
                chart.Legend.Items[i].Spacing      = 4;
                chart.Legend.ItemsSize             = new Size(13, 13);
                chart.Legend.Items[i].TextAligment = VerticalAlignment.Bottom;
                chart.Legend.BackColor             = Color.Transparent;
                chart.LegendsPlacement             = ChartPlacement.Outside;
                chart.LegendAlignment = ChartAlignment.Center;
                chart.LegendPosition  = ChartDock.Bottom;
                chart.Legend.Font     = new Font("Segoe UI", 10.25f);
            }

            //Adds Custom legend to chart control

            ChartLegendItem[]          customItems = new ChartLegendItem[0];
            ChartLegendItemsCollection clic        = new ChartLegendItemsCollection();
            ChartLegendItem            cli1        = new ChartLegendItem("Press Esc to Cancel Zooming");
            clic.Add(cli1);


            #endregion
        }
Exemplo n.º 10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ChartLegendItemBuilder" /> class.
 /// </summary>
 /// <param name="legendItem">The chart legend item.</param>
 public ChartLegendItemBuilder(ChartLegendItem legendItem)
 {
     this.legendItem = legendItem;
 }
Exemplo n.º 11
0
        //Сформувати статистику
        private void CreateButton_Click(object sender, RoutedEventArgs e)
        {
            using (SqlConnection con = new SqlConnection(connectionString))
            {
                //Обрати критерію з ComboBox
                ComboBoxItem comboItem    = (ComboBoxItem)CriteriaComboBox.SelectedItem;
                string       criterianame = comboItem.Name;

                //Обрати місяць
                ComboBoxItem comboItem2 = (ComboBoxItem)MonthComboBox.SelectedItem;
                string       monthname  = comboItem2.Name;

                //Запит для виводу інформації про діяльність
                string query = String.Format("SELECT wk.Surname , act.{0} " +
                                             "FROM Workers wk " +
                                             "INNER JOIN Activity act on wk.ID=act.WorkerID " +
                                             "WHERE act.CalendarMonthName = '{1}' AND act.CalendarYear = {2} ",
                                             criterianame, monthname, NumericUpDown.Value);

                con.Open();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(query, connectionString);
                DataTable      table       = new DataTable();
                dataAdapter.Fill(table);
                Chart.ItemsSource = table;

                //Заговолок графіку відповідно до обраних параметрів
                Chart.DefaultView.ChartTitle.Content = "Статистика: " + comboItem.Content.ToString().ToLowerInvariant() + " за " + monthname.ToLowerInvariant() + " " + NumericUpDown.Value + " року";
                //Автоматично генерувати легенду
                Chart.DefaultView.ChartLegend.UseAutoGeneratedItems = false;

                //Назва осей X та Y
                Chart.DefaultView.ChartArea.AxisX.Title = "Працівник (табельний номер)";
                Chart.DefaultView.ChartArea.AxisY.Title = "Кількість днів";

                Chart.DefaultView.ChartLegend.UseAutoGeneratedItems = true;

                //Назва легенди
                ChartLegendItem item1 = new ChartLegendItem();
                item1.Label      = "Дні";
                item1.MarkerFill = new SolidColorBrush(Colors.DarkTurquoise);
                Chart.DefaultView.ChartLegend.Items.Add(item1);
                //Форма значка легенди
                Chart.DefaultView.ChartLegend.LegendItemMarkerShape = MarkerShape.Circle;

                //показати лінії сітки
                //для присутності
                if (comboItem.Name.ToString() == "Present")
                {
                    //позитивне значення
                    CustomGridLine gridlinePositive = new CustomGridLine();
                    gridlinePositive.YIntercept      = 20;
                    gridlinePositive.Stroke          = new SolidColorBrush(Colors.Chartreuse);
                    gridlinePositive.StrokeThickness = 2;
                    this.Chart.DefaultView.ChartArea.Annotations.Add(gridlinePositive);

                    //негативне значення
                    CustomGridLine gridlineNegative = new CustomGridLine();
                    gridlineNegative.YIntercept      = 5;
                    gridlineNegative.Stroke          = new SolidColorBrush(Colors.Tomato);
                    gridlineNegative.StrokeThickness = 2;
                    this.Chart.DefaultView.ChartArea.Annotations.Add(gridlineNegative);
                }
                //для відсутності
                if (comboItem.Name.ToString() == "Absence")
                {
                    //позитивне значення
                    CustomGridLine gridlinePositive = new CustomGridLine();
                    gridlinePositive.YIntercept      = 3;
                    gridlinePositive.Stroke          = new SolidColorBrush(Colors.Chartreuse);
                    gridlinePositive.StrokeThickness = 2;
                    this.Chart.DefaultView.ChartArea.Annotations.Add(gridlinePositive);

                    //негативне значення
                    CustomGridLine gridlineNegative = new CustomGridLine();
                    gridlineNegative.YIntercept      = 15;
                    gridlineNegative.Stroke          = new SolidColorBrush(Colors.Tomato);
                    gridlineNegative.StrokeThickness = 2;
                    this.Chart.DefaultView.ChartArea.Annotations.Add(gridlineNegative);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        /// Data-Bound Event
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void chChartExtension_DataBound(object sender, Telerik.Windows.Controls.Charting.ChartDataBoundEventArgs e)
        {
            string methodNamespace = String.Format("{0}.{1}", GetType().FullName, System.Reflection.MethodInfo.GetCurrentMethod().Name);

            Logging.LogBeginMethod(this.DataContextSlice1ChartExtension.logger, methodNamespace);
            try
            {
                if (this.DataContext as ViewModelSlice1ChartExtension != null)
                {
                    if (this.chChartExtension.DefaultView.ChartLegend.Items.Count != 0)
                    {
                        this.chChartExtension.DefaultView.ChartLegend.Items.Clear();
                    }

                    int i = 0;

                    if ((this.DataContext as ViewModelSlice1ChartExtension).ChartExtensionPlottedData != null)
                    {
                        (this.DataContext as ViewModelSlice1ChartExtension).AxisXMinValue = Convert.ToDateTime(((this.DataContext as ViewModelSlice1ChartExtension).ChartExtensionPlottedData.OrderBy(a => a.ToDate)).
                                                                                                               Select(a => a.ToDate).FirstOrDefault()).ToOADate();
                        (this.DataContext as ViewModelSlice1ChartExtension).AxisXMaxValue = Convert.ToDateTime(((this.DataContext as ViewModelSlice1ChartExtension).ChartExtensionPlottedData.OrderByDescending(a => a.ToDate)).
                                                                                                               Select(a => a.ToDate).FirstOrDefault()).ToOADate();
                        int dataCount = (this.DataContext as ViewModelSlice1ChartExtension).ChartExtensionPlottedData.Count;

                        if (dataCount != 0)
                        {
                            this.chChartExtension.DefaultView.ChartArea.AxisX.Step = dataCount / 10;
                        }

                        if (this.DataContextSlice1ChartExtension.ChartExtensionPlottedData.Any(a => a.AmountTraded != null))
                        {
                            ChartLegendItem transactionLegendItem = new ChartLegendItem();
                            transactionLegendItem.MarkerFill = new SolidColorBrush(Color.FromArgb(255, 33, 54, 113));
                            transactionLegendItem.Label      = this.DataContextSlice1ChartExtension.ChartExtensionPlottedData.
                                                               Where(a => a.Type.ToUpper() == "SECURITY").Select(a => a.Ticker).FirstOrDefault();
                            this.chChartExtension.DefaultView.ChartLegend.Items.Add(transactionLegendItem);
                        }

                        if (this.DataContextSlice1ChartExtension.ChartExtensionPlottedData.Any(a => a.Type.ToUpper() == "SECURITY"))
                        {
                            i++;
                            ChartLegendItem securityLegendItem = new ChartLegendItem();
                            securityLegendItem.MarkerFill = ReturnLegendItemColor(i);
                            securityLegendItem.Label      = this.DataContextSlice1ChartExtension.ChartExtensionPlottedData.
                                                            Where(a => a.Type.ToUpper() == "SECURITY").Select(a => a.Ticker).FirstOrDefault();
                            this.chChartExtension.DefaultView.ChartLegend.Items.Add(securityLegendItem);
                        }

                        if (this.DataContextSlice1ChartExtension.ChartExtensionPlottedData.Any(a => a.Type == "COUNTRY"))
                        {
                            i++;
                            ChartLegendItem countryLegendItem = new ChartLegendItem();
                            countryLegendItem.MarkerFill = ReturnLegendItemColor(i);
                            countryLegendItem.Label      = this.DataContextSlice1ChartExtension.ChartExtensionPlottedData.
                                                           Where(a => a.Type.ToUpper() == "COUNTRY").Select(a => a.Ticker).FirstOrDefault();
                            this.chChartExtension.DefaultView.ChartLegend.Items.Add(countryLegendItem);
                        }

                        if (this.DataContextSlice1ChartExtension.ChartExtensionPlottedData.Any(a => a.Type.ToUpper() == "SECTOR"))
                        {
                            i++;
                            ChartLegendItem sectorLegendItem = new ChartLegendItem();
                            sectorLegendItem.MarkerFill = ReturnLegendItemColor(i);
                            sectorLegendItem.Label      = this.DataContextSlice1ChartExtension.ChartExtensionPlottedData.
                                                          Where(a => a.Type.ToUpper() == "SECTOR").Select(a => a.Ticker).FirstOrDefault();
                            this.chChartExtension.DefaultView.ChartLegend.Items.Add(sectorLegendItem);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Prompt.ShowDialog("Message: " + ex.Message + "\nStackTrace: " + Logging.StackTraceToString(ex), "Exception", MessageBoxButton.OK);
                Logging.LogException(this.DataContextSlice1ChartExtension.logger, ex);
            }
        }