Beispiel #1
0
        public PieChart(DashboardHelper dashboardHelper, GadgetParameters parameters, PieChartSettings settings, List<XYColumnChartData> dataList)
        {
            InitializeComponent();
            this.Settings = settings;
            this.PieChartSettings = settings;
            this.Parameters = parameters;
            this.DashboardHelper = dashboardHelper;
            SetChartProperties();
            SetChartData(dataList);

            xyChart.Legend.BorderBrush = Brushes.Gray;
        }
        protected override void SetChartData(List<XYColumnChartData> dataList, Strata strata)
        {
            PieChartSettings chartSettings = new PieChartSettings();
            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);

            double pct = 20;
            double.TryParse(txtAnnotationPercent.Text, out pct);

            chartSettings.AnnotationPercent = pct;

            switch (cmbChartKind.SelectedIndex)
            {
                case 0:
                    chartSettings.PieChartKind = PieChartKind.Pie2D;
                    break;
                case 1:
                    chartSettings.PieChartKind = PieChartKind.Pie;
                    break;
                case 2:
                    chartSettings.PieChartKind = PieChartKind.Donut2D;
                    break;
                case 3:
                    chartSettings.PieChartKind = PieChartKind.Donut;
                    break;
            }

            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.ShowAnnotationValue = (bool)checkboxAnnotationValue.IsChecked;
            chartSettings.ShowAnnotationLabel = (bool)checkboxAnnotationLabel.IsChecked;
            chartSettings.ShowAnnotationPercent = (bool)checkboxAnnotationPercent.IsChecked;

            chartSettings.ShowLegend = (bool)checkboxShowLegend.IsChecked;
            chartSettings.ShowLegendBorder = (bool)checkboxShowLegendBorder.IsChecked;
            chartSettings.ShowLegendVarNames = (bool)checkboxShowVarName.IsChecked;

            Controls.Charting.PieChart pieChart = new Controls.Charting.PieChart(DashboardHelper, GadgetOptions, chartSettings, dataList);
            pieChart.Margin = new Thickness(0, 0, 0, 16);
            //Grid.SetColumn(columnChart, 1);
            pieChart.MouseEnter += new MouseEventHandler(chart_MouseEnter);
            pieChart.MouseLeave += new MouseEventHandler(chart_MouseLeave);
            panelMain.Children.Add(pieChart);
        }