Esempio n. 1
0
        private void phodiemthi_Load(object sender, EventArgs e)
        {
            dataGridView1.Hide();
            dbVeMTDataContext db = new dbVeMTDataContext();
            dataGridView1.Rows.Clear();
            var results = from p in db.vemts
                          group p by p.diem into g
                          select new { diem = g.Key , soluong = g.Count() };
            dataGridView1.DataSource = results;
            db.SubmitChanges();
            //Tìm và đặt giá trị MAX cho trục Y
            int max = Convert.ToInt32(dataGridView1.Rows[0].Cells[0].Value);
            for (int i = 1; i <= dataGridView1.SelectedRows.Count; i++)
                if (max < Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value))
                    max = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value);
            if (chart1.ChartAreas[0].AxisY.Maximum < max) chart1.ChartAreas[0].AxisY.Maximum = max;

            chart1.Series.Clear();

            Series s = new Series();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                s.ChartType = SeriesChartType.Line;
                DataPoint p = new DataPoint();
                p.XValue = i;
                p.SetValueY(Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value));
                //p.AxisLabel = "Điểm " + dataGridView1.Rows[i].Cells[0].Value.ToString() +"";
                p.AxisLabel = "điểm" + i.ToString(); ;
                s.Points.Add(p);
            }
            chart1.Series.Add(s);
        }
Esempio n. 2
0
        public MitPie(int miID, int akPro)
        {
            InitializeComponent();
            this.MinimumSize = new Size(300, 300);
            this.MaximumSize = new Size(800, 500);
            chart1.Size = new Size(this.Width - 10, this.Height - 10);
            DataTable arbeiter = SqlConnection.SelectStatement("SELECT prName,sum( zeDauer ) as sum,miName,miVorname FROM tzeiterfassung LEFT JOIN tProjekt using (prID) LEFT JOIN tMitarbeiter using (miID) WHERE miID =" + miID + " GROUP BY prID");
            DataTableReader reader = arbeiter.CreateDataReader();

            Series a = chart1.Series[0];

            if (reader.HasRows)
            {
                while (reader.Read())
                {

                    DataPoint p = new DataPoint();
                    p.SetValueY(Convert.ToDouble(reader["sum"].ToString()));
                    p.AxisLabel = reader["prName"].ToString();
                    p.IsValueShownAsLabel = true;
                    a.Points.Add(p);

                }
                Mitarbeiter.Text = reader["miVorname"].ToString() + " " + reader["miName"].ToString();
            }
        }
        public ResultGraph(List<Vote> votes, List<string> options, string title)
        {
            InitializeComponent();

            this.questionTextBox.Text = title;

            this.resultsChart.Series.Clear();

            for (int i=0; i<options.Count; i++)
            {
                int value = 0;
                foreach (Vote v in votes)
                    if (v.choice == i)
                        value++;

                string s = options[i];
                this.resultsChart.Series.Add(s);
                DataPoint d = new DataPoint();
                d.SetValueY(value);
                this.resultsChart.Series[s].Points.Add(d);
            }
        }
Esempio n. 4
0
        private void button1_Click(object sender, EventArgs e)
        {
            int max = Convert.ToInt32(dataGridView1.Rows[0].Cells[0].Value);
            for (int i = 1; i <= dataGridView1.SelectedRows.Count; i++)
                if (max < Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value))
                    max = Convert.ToInt32(dataGridView1.Rows[i].Cells[0].Value);
            if (chart1.ChartAreas[0].AxisY.Maximum < max) chart1.ChartAreas[0].AxisY.Maximum = max;

            chart1.Series.Clear();

            Series s = new Series();
            for (int i = 0; i < dataGridView1.Rows.Count; i++)
            {
                s.ChartType = SeriesChartType.Line;
                DataPoint p = new DataPoint();
                p.XValue = i;
                p.SetValueY(Convert.ToDouble(dataGridView1.Rows[i].Cells[1].Value));
                p.AxisLabel =  dataGridView1.Rows[i].Cells[0].Value.ToString();
                //p.AxisLabel = dataGridView1.Rows[i].Cells[0].Value.ToString();
                s.Points.Add(p);
            }
            chart1.Series.Add(s);
        }
Esempio n. 5
0
        private void writeChartData()
        {
            while (true)
            {
                chart1.Invoke(new Action(delegate()
                    {
                        chart1.Series["Series1"].Points.Clear();
                        for (int i = 0; i < 100; i++)
                        {
                            DataPoint p = new DataPoint();
                            p.SetValueY(pts[i]);
                            if (pts[i] > offset)
                                p.Color = Color.OrangeRed;
                            else
                                p.Color = Color.DodgerBlue;
                            chart1.Series["Series1"].Points.Add(p);
                        }

                    }));
            }
        }
Esempio n. 6
0
        private void ToolStripMenuItem_PasteFromClipboard(object sender, EventArgs e)
        {
            ToolStripMenuItem TMI = (ToolStripMenuItem)sender;
            cExtendedTable ET = (cExtendedTable)TMI.Tag;

            Series TmpSerie = new Series();

            for (int i = 0; i < ET[0].Count; i++)
            {
                DataPoint DP = new DataPoint();
                // DP.XValue = ET[0][i];

                List<double> LD = new List<double>();

                for (int j = 1; j < ET.Count; j++)
                {
                    LD.Add(ET[j][i]);
                }

                DP.SetValueY(LD.ToArray());

                TmpSerie.Points.Add(DP);

                //TmpSerie.
            }

            CurrentSeries.Add(TmpSerie);

            this.Run();

            //Run();

            //if (this.GraphBelow != null)
            //{
            //    if (this.GraphBelow.GetType() == typeof(cChart1DGraph))
            //    {
            //        //  ((cChart1DGraph)this.GraphBelow).Run();
            //    }
            //}

            //   ListInput = new cListExtendedTable();
            //  ListInput.Add(ET);

            ///  this.Run();

            // cExtendedTable doc = sender.GetType();
        }
Esempio n. 7
0
        public void Plot(IEnumerable ys, string seriesName = null, string chartType = "Line")
        {
            var isNested = false;
            if (!CheckDataType(ys, out isNested))
                throw new NotSupportedException("The provided Y values type is not supported. "+SupportedTypes);

            var series = seriesName != null ? new Series(seriesName) : new Series();
            foreach (var value in ys)
            {
                var point = new DataPoint();
                if (!isNested)
                {
                    point.SetValueY(value);
                }
                else
                {
                    var yValues = ((IEnumerable) value).Cast<object>().ToArray();
                    point.SetValueY(yValues);
                }
                series.Points.Add(point);
            }
            series.ChartTypeName = chartType;
            Plot(series);
        }