Пример #1
0
        public LineChart(DashboardHelper dashboardHelper, GadgetParameters parameters, LineChartSettings settings, List<XYColumnChartData> dataList)
        {
            InitializeComponent();
            this.Settings = settings;
            this.LineChartSettings = settings;
            this.Parameters = parameters;
            this.DashboardHelper = dashboardHelper;
            SetChartProperties();
            SetChartData(dataList);

            xyChart.Legend.BorderBrush = Brushes.Gray;
        }
Пример #2
0
        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)
            {
                LineChartSettings chartSettings = new LineChartSettings();
                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;

                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.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;

                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 (cmbLineType.SelectedIndex)
                {
                    case 1:
                        chartSettings.LineKind = LineKind.Polygon;
                        break;
                    case 2:
                        chartSettings.LineKind = LineKind.Smooth;
                        break;
                    case 3:
                        chartSettings.LineKind = LineKind.Step;
                        break;
                    default:
                    case 0:
                        chartSettings.LineKind = LineKind.Auto;
                        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;
                }

                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;
                }

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

                int lineThicknessY1 = cmbLineThickness.SelectedIndex + 1;
                chartSettings.LineThickness = (double)lineThicknessY1;

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