//Получение выбранной диаграммы.
        private AbstractDiagram GetDiagram(DiagramType type)
        {
            AbstractDiagram diagram;

            switch (type)
            {
            case DiagramType.PieChart:
                diagram = new PieChart(DataInfo);
                break;

            case DiagramType.NormalizedHistogram:
                diagram = new NormalizedHistogram(DataInfo);
                break;

            case DiagramType.StackedHistogram:
                diagram = new StackedHistogram(DataInfo);
                break;

            case DiagramType.Plot:
                diagram = new Plot(DataInfo);
                break;

            case DiagramType.Scatter:
                diagram = new Scatter(DataInfo);
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(type));
            }
            return(diagram);
        }
Пример #2
0
        private void DrawButtonOnClick(object sender, RoutedEventArgs e)
        {
            DataInfo.Data = new double[ListBoxWithData.Items.Count];
            for (int i = 0; i < ListBoxWithData.Items.Count; i++)
            {
                DataInfo.Data[i] = double.Parse(ListBoxWithData.Items[i].ToString());
            }

            switch (Type)
            {
            case DiagramType.Piechart:
                var pieChart = new PieChart(DataInfo.Data);
                pieChart.Draw(MainCanvas);
                TitleListBox.Text = pieChart.Title;
                break;

            case DiagramType.NormalizaedHistogram:
                var normHist = new NormalizedHistogram(DataInfo.Series);
                normHist.Draw(MainCanvas);
                TitleListBox.Text = normHist.Title;
                break;

            case DiagramType.StackedHistogram:
                var stHist = new StackedHistogram(DataInfo.Series);
                stHist.Draw(MainCanvas);
                TitleListBox.Text = stHist.Title;
                break;
            }

            AddButton.IsEnabled    = false;
            SeriesButton.IsEnabled = false;
            DeleteButton.IsEnabled = false;
            DrawButton.IsEnabled   = false;

            DataInfo.Series.Clear();
            ListBoxWithData.Items.Clear();
        }