Ejemplo n.º 1
0
        //Função que renderiza os gráficos de pizza de acordo com as informações vindas do banco de dados
        protected internal void renderIncomeChart(System.Windows.Forms.DataVisualization.Charting.Chart chart, string query, DataRow accountDataRow)
        {
            chart.Palette             = System.Windows.Forms.DataVisualization.Charting.ChartColorPalette.None;
            chart.PaletteCustomColors = Globals.myPalette;
            DataTable dataTable = Database.query(query);

            if (dataTable.Rows.Count > 0)
            {
                chart.Show();
                foreach (DataRow dataRow in dataTable.Rows)
                {
                    string category = accountDataRow.ItemArray[1].ToString().Trim();
                    if ((!string.IsNullOrEmpty(dataRow.ItemArray[0].ToString().Trim())) && ((Convert.ToInt32(dataRow.ItemArray[0])) != 0))
                    {
                        string graph = dataRow.ItemArray[0].ToString().Trim();
                        string sum   = String.Format("{0:C}", dataRow.ItemArray[0]);
                        string label = category + "\n" + sum;
                        chart.Series[0].Points.AddXY(label, graph);
                    }
                }
            }
            else
            {
                chart.Hide();
            }
        }
Ejemplo n.º 2
0
        private void updateFormValues()
        {
            srPop.Points.Clear();
            srSamp.Points.Clear();
            srPop2.Points.Clear();
            srSamp2.Points.Clear();
            System.Windows.Forms.ComboBox cmbPrimary = (System.Windows.Forms.ComboBox)hs.Controls["cmbPrimary"];
            string cmbTxt = cmbPrimary.Text;

            System.Windows.Forms.DataVisualization.Charting.Chart ch = hs.chrHistogram;
            string k = ch.Titles[0].Text.Replace("Distribution for ", "");

            if (cmbTxt == "Bins")
            {
                ch.ChartAreas[0].AxisX.Title = "Bins";
                double[] binProp1    = ClusterProportions[k];
                double[] binProp2    = ClusterSampleProportions[k];
                int[]    clusCntSamp = clusSampleCountDic[k];
                Accord.Statistics.Testing.MultinomialTest mt = new MultinomialTest(clusCntSamp, binProp1);
                ch.ChartAreas[1].AxisX.Title = "Chi-Square = " + mt.Statistic.ToString() + "\np-value = " + mt.PValue.ToString();
                double[] xAxes = (from int i in System.Linq.Enumerable.Range(0, binProp1.Length) select System.Convert.ToDouble(i)).ToArray();
                double   ypSum = 0;
                double   ysSum = 0;
                for (int i = 0; i < binProp1.Length; i++)
                {
                    double bp1 = binProp1[i];
                    double bp2 = binProp2[i];
                    ypSum += bp1;
                    ysSum += bp2;
                    srPop.Points.AddXY(xAxes[i], bp1);
                    srSamp.Points.AddXY(xAxes[i], bp2);
                    srPop2.Points.AddXY(xAxes[i], ypSum);
                    srSamp2.Points.AddXY(xAxes[i], ysSum);
                }
            }
            else
            {
                int cmbInd = System.Convert.ToInt32(cmbTxt) - 1;
                ch.ChartAreas[0].AxisX.Title = "Principle Component " + cmbTxt;
                ch.ChartAreas[1].AxisX.Title = "proportion of variance = " + pca.ProportionOfTotalVariance[cmbInd].ToString() + "\np-value = " + pDic[k][cmbInd].ToString();
                double[][] minMax1 = minMaxDic1[k];
                double[][] minMax2 = minMaxDic2[k];
                double     min     = minMax1[0][cmbInd];
                if (minMax2[0][cmbInd] < min)
                {
                    min = minMax2[0][cmbInd];
                }
                double max = minMax1[1][cmbInd];
                if (minMax2[1][cmbInd] > max)
                {
                    max = minMax2[1][cmbInd];
                }
                double   span     = (max - min) / numberOfBins;
                double[] binProp1 = binPropDic1[k][cmbInd];
                double[] binProp2 = binPropDic2[k][cmbInd];
                double[] xAxes    = new double[binProp1.Length];
                double   halfMin  = min / 2;
                for (int i = 0; i < xAxes.Length; i++)
                {
                    xAxes[i] = min + halfMin + (span * i);
                }

                double ypSum = 0;
                double ysSum = 0;
                for (int i = 0; i < binProp1.Length; i++)
                {
                    double bp1 = binProp1[i];
                    double bp2 = binProp2[i];
                    ypSum += bp1;
                    ysSum += bp2;
                    srPop.Points.AddXY(xAxes[i], bp1);
                    srSamp.Points.AddXY(xAxes[i], bp2);
                    srPop2.Points.AddXY(xAxes[i], ypSum);
                    srSamp2.Points.AddXY(xAxes[i], ysSum);
                }
            }
            ch.Show();
        }