private void initComboBoxes()
        {
            voivodeshipComboBox.Items.Add("Polska");
            sportComboBox.Items.Add("Wszystkie");

            for (int i = 0; i < dataHolder.VoivodeshipCount; i++)
            {
                voivodeshipComboBox.Items.Add(VoivodeshipNamesExtensions.GetName((VoivodeshipNames)i));
            }

            for (int i = 0; i < dataHolder.SportCount; i++)
            {
                sportComboBox.Items.Add(dataHolder.SportNames[i]);
            }

            propertyComboBox.Items.Add("Sekcji");
            propertyComboBox.Items.Add("Ogółem");
            propertyComboBox.Items.Add("Kobiet");
            propertyComboBox.Items.Add("Juniorów");
            propertyComboBox.Items.Add("Juniorek");

            voivodeshipComboBox.SelectedIndex     = 0;
            voivodeshipComboBox.SelectionChanged += comboBox_SelectionChanged;

            sportComboBox.SelectedIndex     = 0;
            sportComboBox.SelectionChanged += comboBox_SelectionChanged;

            propertyComboBox.SelectedIndex     = 0;
            propertyComboBox.SelectionChanged += comboBox_SelectionChanged;
        }
        public void Init()
        {
            areaNameLabel.Content = VoivodeshipNamesExtensions.GetName(voivodeshipName);

            PieChart pieChart = new PieChart(chartPosition, chartSize);

            pieChart.Create(mapPainter.GetAreaChartValues((int)voivodeshipName));

            StatisticsData[] statisticsData = mapPainter.Holder.VoivodeshipData[(int)voivodeshipName];
            StatisticsData   minData        = mapPainter.Holder.GetMinDatasInVoivodeship(voivodeshipName);
            StatisticsData   maxData        = mapPainter.Holder.GetMaxDatasInVoivodeship(voivodeshipName);

            faces = ChernoffFace.GetFaces(pieChart, statisticsData, minData, maxData);

            pieChart.Draw(chartCanvas);
            chartCanvas.Background = Brushes.Azure;

            foreach (ChernoffFace face in faces)
            {
                face.Draw(chartCanvas);
            }

            // ChernoffFace.AdjustView(faces, chartCanvas, chartCanvasScaleTransform, chartCanvasTranslateTransform);

            foreach (string sportName in mapPainter.Holder.SportNames)
            {
                sportNameCb.Items.Add(sportName);
            }

            if (sportNameCb.Items.Count > 0)
            {
                sportNameCb.SelectedIndex = 0;
            }
        }
Example #3
0
        private void drawPreview(int areaIndex)
        {
            VoivodeshipNames areaName = (VoivodeshipNames)areaIndex;

            prevLabel.Content = VoivodeshipNamesExtensions.GetName(areaName);

            Point chartPosition = new Point(previewCanvas.Width / 2, previewCanvas.Height / 2);
            int   chartSize     = (int)(previewCanvas.Width / 4);

            PieChart pieChart = new PieChart(chartPosition, chartSize);

            pieChart.Create(mapPainter.GetAreaChartValues(areaIndex));

            StatisticsData[] statisticsData = mapPainter.Holder.VoivodeshipData[areaIndex];
            StatisticsData   minData        = mapPainter.Holder.GetMinDatasInVoivodeship(areaName);
            StatisticsData   maxData        = mapPainter.Holder.GetMaxDatasInVoivodeship(areaName);

            ChernoffFace[] faces = ChernoffFace.GetFaces(pieChart, statisticsData, minData, maxData);

            previewCanvas.Children.Clear();

            pieChart.Draw(previewCanvas);

            foreach (ChernoffFace face in faces)
            {
                face.Draw(previewCanvas);
            }
        }
        private void initComboBoxes()
        {
            voivodeshipComboBox.Items.Add("Wszystkie");
            sportComboBox.Items.Add("Wszystkie");

            for (int i = 0; i < dataHolder.VoivodeshipCount; i++)
            {
                voivodeshipComboBox.Items.Add(VoivodeshipNamesExtensions.GetName((VoivodeshipNames)i));
            }

            for (int i = 0; i < dataHolder.SportCount; i++)
            {
                sportComboBox.Items.Add(dataHolder.SportNames[i]);
            }

            for (int i = 0; i < axisValues.Length; i++)
            {
                axisXComboBox.Items.Add(axisValues[i]);
                axisYComboBox.Items.Add(axisValues[i]);
            }

            voivodeshipComboBox.SelectedIndex = 0;
            sportComboBox.SelectedIndex       = 0;
            axisXComboBox.SelectedIndex       = 0;
            axisYComboBox.SelectedIndex       = 0;

            voivodeshipComboBox.SelectionChanged += comboBox_SelectionChanged;
            sportComboBox.SelectionChanged       += comboBox_SelectionChanged;
            axisXComboBox.SelectionChanged       += comboBox_SelectionChanged;
            axisYComboBox.SelectionChanged       += comboBox_SelectionChanged;
        }
Example #5
0
        private void initTreeViewData()
        {
            dataTreeView.Items.Clear();

            for (int i = 0; i < dataHolder.VoivodeshipCount; i++)
            {
                TreeViewItem item = new TreeViewItem()
                {
                    Header = VoivodeshipNamesExtensions.GetName((VoivodeshipNames)i)
                };

                for (int j = 0; j < dataHolder.SportCount; j++)
                {
                    TreeViewItem sportItem = new TreeViewItem()
                    {
                        Header = dataHolder.SportNames[j]
                    };

                    sportItem.Items.Add(new TreeViewItem()
                    {
                        Header = "Sekcji: " + dataHolder.VoivodeshipData[i][j].Sections
                    });

                    sportItem.Items.Add(new TreeViewItem()
                    {
                        Header = "Ogółem: " + dataHolder.VoivodeshipData[i][j].Total
                    });

                    sportItem.Items.Add(new TreeViewItem()
                    {
                        Header = "Kobiet: " + dataHolder.VoivodeshipData[i][j].Womens
                    });

                    sportItem.Items.Add(new TreeViewItem()
                    {
                        Header = "Juniorów: " + dataHolder.VoivodeshipData[i][j].Boys
                    });

                    sportItem.Items.Add(new TreeViewItem()
                    {
                        Header = "Juniorek: " + dataHolder.VoivodeshipData[i][j].Girls
                    });

                    item.Items.Add(sportItem);
                }

                dataTreeView.Items.Add(item);
            }
        }
        private void updateResults()
        {
            string           selectedName = (string)voivodeshipComboBox.SelectedValue;
            VoivodeshipNames selectedArea = VoivodeshipNamesExtensions.Parse(selectedName);

            int sportIndex = sportComboBox.SelectedIndex - 1;
            StatisticsDataFields dataField = (StatisticsDataFields)propertyComboBox.SelectedIndex;

            double arithmeticAverage = dataHolder.GetArithmeticAverage(selectedArea, sportIndex, dataField);
            int    median            = dataHolder.GetMedian(selectedArea, sportIndex, dataField);

            String dominant = "";

            foreach (int dominantValue in dataHolder.GetDominant(selectedArea, sportIndex, dataField))
            {
                dominant += dominantValue + ", ";
            }

            double quarterDeviation  = dataHolder.GetQuarterDeviation(selectedArea, sportIndex, dataField);
            double standardDeviation = dataHolder.GetStandardDeviation(selectedArea, sportIndex, dataField);
            double skewness          = dataHolder.GetSkewness(selectedArea, sportIndex, dataField);
            double giniCoefficient   = dataHolder.GetGiniCoefficient(selectedArea, sportIndex, dataField);

            String skewnessDescription = String.Format("{0:0.00} ", skewness);

            if (skewness < 0)
            {
                skewnessDescription += "(Lewostronna asymetria)";
            }
            else if (skewness > 0)
            {
                skewnessDescription += "(Prawostronna asymetria)";
            }
            else
            {
                skewnessDescription += "(Rozkład symetryczny)";
            }

            arithmeticAverageLabel.Content = String.Format("{0:0.00}", arithmeticAverage);
            medianLabel.Content            = median.ToString();
            dominantLabel.Content          = dominant;
            quarterDeviationLabel.Content  = String.Format("{0:0.00}", quarterDeviation);
            standardDeviationLabel.Content = String.Format("{0:0.00}", standardDeviation);
            skewnessLabel.Content          = skewnessDescription;
            giniCoefficientLabel.Content   = String.Format("{0:0.00}", giniCoefficient);
        }
        private void update()
        {
            string               axisX        = (string)axisXComboBox.SelectedValue;
            string               axisY        = (string)axisYComboBox.SelectedValue;
            int                  sportIndex   = sportComboBox.SelectedIndex - 1;
            string               selectedName = (string)voivodeshipComboBox.SelectedValue;
            VoivodeshipNames     selectedArea = VoivodeshipNamesExtensions.Parse(selectedName);
            StatisticsDataFields dataFieldX   = (StatisticsDataFields)axisXComboBox.SelectedIndex;
            StatisticsDataFields dataFieldY   = (StatisticsDataFields)axisYComboBox.SelectedIndex;

            chart.ChartAreas["chartArea"].AxisX.Title = axisX;
            chart.ChartAreas["chartArea"].AxisY.Title = axisY;
            chart.Series["series"].Points.Clear();

            List <Point> points                        = dataHolder.GetPointsByCriteria(selectedArea, sportIndex, dataFieldX, dataFieldY);
            double       pearsonCoefficient            = dataHolder.GetPearsonCorrelationCoefficient(points);
            string       pearsonCoefficientDescription = String.Format("{0:0.00} ", pearsonCoefficient);

            if (pearsonCoefficient < 0.2)
            {
                pearsonCoefficientDescription += "(brak związku liniowego)";
            }
            else if (pearsonCoefficient < 0.4)
            {
                pearsonCoefficientDescription += "(słaba zależność)";
            }
            else if (pearsonCoefficient < 0.7)
            {
                pearsonCoefficientDescription += "(umiarkowana zależność)";
            }
            else if (pearsonCoefficient < 0.9)
            {
                pearsonCoefficientDescription += "(dość silna zależność)";
            }
            else
            {
                pearsonCoefficientDescription += "(bardzo silna zależność)";
            }

            pearsonCoefficientLabel.Content = pearsonCoefficientDescription;

            foreach (Point point in points)
            {
                chart.Series["series"].Points.AddXY(point.X, point.Y);
            }
        }