public ColumnChart(DashboardHelper dashboardHelper, GadgetParameters parameters, ColumnChartSettings settings, List<XYColumnChartData> dataList)
 {
     InitializeComponent();
     this.Settings = settings;
     this.ColumnChartSettings = settings;
     this.Parameters = parameters;
     this.DashboardHelper = dashboardHelper;
     SetChartProperties();
     SetChartData(dataList);
     xyChart.Legend.BorderBrush = Brushes.Gray;
 }
        protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata)
        {
            #region Input Validation
            if (dataList == null)
            {
                throw new ArgumentNullException("dataList");
            }
            #endregion // Input Validation

            if (dataList.Count > 0)
            {
                ColumnChartSettings chartSettings = new ColumnChartSettings();
                chartSettings.ChartTitle = txtChartTitle.Text;
                chartSettings.ChartSubTitle = txtChartSubTitle.Text;
                if (strata != null)
                {
                    chartSettings.ChartStrataTitle = strata.Filter;
                }
                chartSettings.ChartWidth = int.Parse(txtWidth.Text);
                chartSettings.ChartHeight = int.Parse(txtHeight.Text);
                chartSettings.ShowDefaultGridLines = (bool)checkboxGridLines.IsChecked;

                double from;
                bool success = Double.TryParse(txtFromValue.Text, out from);
                if (success) { chartSettings.YAxisFrom = from; }

                double to;
                success = Double.TryParse(txtToValue.Text, out to);
                if (success) { chartSettings.YAxisTo = to; }

                double step;
                success = Double.TryParse(txtStepValue.Text, out step);
                if (success) { chartSettings.YAxisStep = step; }

                switch (cmbOrientation.SelectedIndex)
                {
                    case 1:
                        chartSettings.Orientation = Orientation.Horizontal;
                        break;
                    case 0:
                    default:
                        chartSettings.Orientation = Orientation.Vertical;
                        break;
                }

                switch (cmbBarType.SelectedIndex)
                {
                    case 1:
                        chartSettings.BarKind = BarKind.Cylinder;
                        break;
                    case 2:
                        chartSettings.BarKind = BarKind.Rectangle;
                        break;
                    case 3:
                        chartSettings.BarKind = BarKind.RoundedBlock;
                        break;
                    default:
                    case 0:
                        chartSettings.BarKind = BarKind.Block;
                        break;
                }

                switch (cmbBarSpacing.SelectedIndex)
                {
                    case 1:
                        chartSettings.BarSpacing = BarSpacing.None;
                        break;
                    case 2:
                        chartSettings.BarSpacing = BarSpacing.Small;
                        break;
                    case 3:
                        chartSettings.BarSpacing = BarSpacing.Medium;
                        break;
                    case 4:
                        chartSettings.BarSpacing = BarSpacing.Large;
                        break;
                    case 0:
                    default:
                        chartSettings.BarSpacing = BarSpacing.Default;
                        break;
                }

                switch (cmbComposition.SelectedIndex)
                {
                    case 0:
                        chartSettings.Composition = CompositionKind.SideBySide;
                        break;
                    case 1:
                        chartSettings.Composition = CompositionKind.Stacked;
                        break;
                    case 2:
                        chartSettings.Composition = CompositionKind.Stacked100;
                        break;
                }

                chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Right;

                if (cmbLegendDock.SelectedItem.ToString().Equals(ChartingSharedStrings.LEGEND_DOCK_VALUE_LEFT))
                {
                    chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Left;
                }
                else if (cmbLegendDock.SelectedItem.ToString().Equals(ChartingSharedStrings.LEGEND_DOCK_VALUE_RIGHT))
                {
                    chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Right;
                }
                else if (cmbLegendDock.SelectedItem.ToString().Equals(ChartingSharedStrings.LEGEND_DOCK_VALUE_TOP))
                {
                    chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Top;
                }
                else if (cmbLegendDock.SelectedItem.ToString().Equals(ChartingSharedStrings.LEGEND_DOCK_VALUE_BOTTOM))
                {
                    chartSettings.LegendDock = ComponentArt.Win.DataVisualization.Charting.Dock.Bottom;
                }

                chartSettings.LegendFontSize = double.Parse(txtLegendFontSize.Text);

                ComboBoxItem cbi = cmbPalette.SelectedItem as ComboBoxItem;
                ComponentArt.Win.DataVisualization.Palette palette = ComponentArt.Win.DataVisualization.Palette.GetPalette(cbi.Content.ToString());
                chartSettings.Palette = palette;

                chartSettings.ShowAnnotations = (bool)checkboxAnnotations.IsChecked;
                chartSettings.ShowAnnotationsY2 = (bool)checkboxAnnotationsY2.IsChecked;
                chartSettings.ShowLegend = (bool)checkboxShowLegend.IsChecked;
                chartSettings.ShowLegendBorder = (bool)checkboxShowLegendBorder.IsChecked;
                chartSettings.ShowLegendVarNames = (bool)checkboxShowVarName.IsChecked;
                chartSettings.UseDiffColors = (bool)checkboxUseDiffColors.IsChecked;
                chartSettings.UseRefValues = (bool)checkboxUseRefValues.IsChecked;
                chartSettings.XAxisLabel = txtXAxisLabelValue.Text;
                chartSettings.XAxisLabelRotation = int.Parse(txtXAxisAngle.Text);
                chartSettings.YAxisLabel = txtYAxisLabelValue.Text;
                chartSettings.YAxisFormattingString = txtYAxisFormatString.Text;
                chartSettings.Y2AxisFormattingString = txtY2AxisFormatString.Text;
                chartSettings.Y2AxisLabel = txtY2AxisLabelValue.Text;
                chartSettings.Y2AxisLegendTitle = txtY2AxisLegendTitle.Text;

                if (cmbSecondYAxis.SelectedIndex == 3)
                {
                    chartSettings.Y2AxisFormattingString = "P0";
                    chartSettings.Y2IsCumulativePercent = true;
                }

                switch (cmbXAxisLabelType.SelectedIndex)
                {
                    case 3:
                        chartSettings.XAxisLabelType = XAxisLabelType.Custom;
                        break;
                    case 1:
                        chartSettings.XAxisLabelType = XAxisLabelType.FieldPrompt;
                        Field field = DashboardHelper.GetAssociatedField(GadgetOptions.MainVariableName);
                        if (field == null)
                        {
                            chartSettings.XAxisLabel = GadgetOptions.MainVariableName;
                        }
                        else
                        {
                            chartSettings.XAxisLabel = ((IDataField)field).PromptText;
                        }
                        break;
                    case 2:
                        chartSettings.XAxisLabelType = XAxisLabelType.None;
                        break;
                    default:
                        chartSettings.XAxisLabelType = XAxisLabelType.Automatic;
                        chartSettings.XAxisLabel = GadgetOptions.MainVariableName;
                        break;
                }

                switch (cmbLineTypeY2.SelectedIndex)
                {
                    case 1:
                        chartSettings.LineKindY2 = LineKind.Polygon;
                        break;
                    case 2:
                        chartSettings.LineKindY2 = LineKind.Smooth;
                        break;
                    case 3:
                        chartSettings.LineKindY2 = LineKind.Step;
                        break;
                    default:
                    case 0:
                        chartSettings.LineKindY2 = LineKind.Auto;
                        break;
                }

                switch (cmbLineDashTypeY2.SelectedIndex)
                {
                    case 0:
                        chartSettings.LineDashStyleY2 = LineDashStyle.Dash;
                        break;
                    case 1:
                        chartSettings.LineDashStyleY2 = LineDashStyle.DashDot;
                        break;
                    case 2:
                        chartSettings.LineDashStyleY2 = LineDashStyle.DashDotDot;
                        break;
                    case 3:
                        chartSettings.LineDashStyleY2 = LineDashStyle.Dot;
                        break;
                    default:
                        chartSettings.LineDashStyleY2 = LineDashStyle.Solid;
                        break;
                }

                int lineThickness = cmbLineThicknessY2.SelectedIndex + 1;
                chartSettings.Y2LineThickness = (double)lineThickness;

                EpiDashboard.Controls.Charting.ColumnChart columnChart = new EpiDashboard.Controls.Charting.ColumnChart(DashboardHelper, GadgetOptions, chartSettings, dataList);
                columnChart.Margin = new Thickness(0, 0, 0, 16);
                columnChart.MouseEnter += new MouseEventHandler(chart_MouseEnter);
                columnChart.MouseLeave += new MouseEventHandler(chart_MouseLeave);
                panelMain.Children.Add(columnChart);
            }
        }