private void BuildSubPerLangGraph() { ZedGraph.ZedGraphControl zg1 = new ZedGraph.ZedGraphControl(); zg1.Dock = DockStyle.Fill; zg1.IsEnableZoom = false; zg1.IsShowPointValues = false; ZedGraph.GraphPane pane = zg1.GraphPane; pane.Fill = new ZedGraph.Fill(Color.Azure, Color.FromArgb(245, 220, 250), 90); pane.Chart.Fill = new ZedGraph.Fill(Color.Snow, Color.FromArgb(225, 240, 250), -90); pane.Title.Text = "Submission per Language"; pane.Title.FontSpec.Size = 18; pane.Title.FontSpec.FontColor = Color.Navy; pane.Title.FontSpec.Family = "Segoe UI Semibold"; pane.Title.FontSpec.IsBold = false; pane.Legend.FontSpec.Size = 12; pane.Legend.IsShowLegendSymbols = true; pane.Legend.Position = ZedGraph.LegendPos.TopCenter; double[] value = { _subInCPP, _subInJava, _subInAnsiC, _subInCPP11, _subInPascal }; string[] label = { "C++", "Java", "ANSI C", "C++11", "Pascal" }; Color[] color1 = { Color.Lime, Color.Blue, Color.Red, Color.Green, Color.Yellow }; Color[] color2 = { Color.DarkOrange, Color.DarkBlue, Color.DarkRed, Color.DarkGreen, Color.YellowGreen }; for (int i = 0; i < value.Length; ++i) { ZedGraph.PieItem pie = pane.AddPieSlice(value[i], color2[i], color1[i], 0, 0.04, label[i]); pie.LabelType = ZedGraph.PieLabelType.Name_Value; pie.LabelDetail.FontSpec.Border.IsVisible = false; pie.LabelDetail.FontSpec.Family = "Segoe UI Semibold"; pie.LabelDetail.FontSpec.Size = 12; pie.LabelDetail.FontSpec.IsAntiAlias = false; pie.IsSelectable = true; } pane.AxisChange(); this.subPerLanTab.Controls.Clear(); this.subPerLanTab.Controls.Add(zg1); }
private void btnDaySummary_Click(object sender, EventArgs e) { Random rnd = new Random(); DataTable t = GetDateTbl(); if (t != null) { if (frmPie != null && !frmPie.IsDisposed) { frmPie.Dispose(); } frmPie = new frmChart(); ZedGraph.GraphPane Pane = frmPie.zedGraph.GraphPane; //Titulos frmPie.Text = lblTimeSpent.Text + ": " + lblDay.Text + " " + dTP.Value.Date.ToString().Split()[0]; Pane.Title.Text = frmPie.Text; Pane.Title.FontSpec.Size = 24f; //Pane.Title.FontSpec.IsItalic = true; Pane.Fill = new ZedGraph.Fill(Color.White, Color.LightYellow, 45f); Pane.Chart.Fill.Type = ZedGraph.FillType.None; //fonte da legenda Pane.Legend.FontSpec.Size = 11f; //Slices int tempoTot = 0; foreach (DataRow r in t.Rows) { int tempo = (int)r["colElapTimeInSeconds"]; tempoTot += tempo; Color cor = Color.FromArgb(rnd.Next(240), rnd.Next(240), rnd.Next(240)); ZedGraph.PieItem p = Pane.AddPieSlice(Math.Round((double)tempo / 3600, 2), cor, Color.White, 45f, 0.1, r["colTask"].ToString()); //Menu pie slices removal feature ToolStripMenuItem m = new ToolStripMenuItem(r["colTask"].ToString()); m.Checked = true; frmPie.itemsMenu.DropDownItems.Add(m); m.Click += new EventHandler(m_Click); frmPie.vals.Add((double)tempo / 3600); } //Sets menu text frmPie.itemsMenu.Text = lblTask.Text; TimeSpan tsp = new TimeSpan(0, 0, tempoTot); //Total label txt = new ZedGraph.TextObj(lblTotTime.Text + "\n" + Math.Round(tsp.TotalHours, 2).ToString() + " h", 0.88f, 0.3f, ZedGraph.CoordType.PaneFraction); Pane.GraphObjList.Add(txt); txt.FontSpec.Fill = new ZedGraph.Fill(Color.White, Color.Yellow, 45f); //shadow ZedGraph.TextObj txt2 = new ZedGraph.TextObj(txt); txt2.FontSpec.Fill = new ZedGraph.Fill(Color.Black); txt2.Location.X += 0.006f; txt2.Location.Y += 0.008f; Pane.GraphObjList.Add(txt2); frmPie.zedGraph.AxisChange(); frmPie.Show(); } }
private void btnMonthSummary_Click(object sender, EventArgs e) { string mes = dTP.Value.Month.ToString(); List <string> _tasks = new List <string>(); List <double> _times = new List <double>(); foreach (DataTable tbl in PBData.Tables) { //checks if month is in selected day string[] s = tbl.TableName.Split(':'); if (s.Length > 1) { s = s[1].Split('-'); } if (s.Length > 1 && s[1] == mes) { //adds each task foreach (DataRow r in tbl.Rows) { //position int i = _tasks.IndexOf(r["colTask"].ToString()); if (i < 0) { i = _tasks.Count; _tasks.Add(r["colTask"].ToString()); _times.Add(0); } //time count _times[i] += (double)((int)r["colElapTimeInSeconds"]); } } } Random rnd = new Random(); //zedGraph Pie Chart DataTable t = GetDateTbl(); if (frmPie != null && !frmPie.IsDisposed) { frmPie.Dispose(); } frmPie = new frmChart(); ZedGraph.GraphPane Pane = frmPie.zedGraph.GraphPane; //Titulos frmPie.Text = lblTimeSpent.Text + ": " + lblMonth.Text + " " + System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.MonthNames[dTP.Value.Month - 1] + "/" + dTP.Value.Year.ToString(); Pane.Title.Text = frmPie.Text; Pane.Title.FontSpec.Size = 24f; //Pane.Title.FontSpec.IsItalic = true; Pane.Fill = new ZedGraph.Fill(Color.White, Color.LightYellow, 45f); Pane.Chart.Fill.Type = ZedGraph.FillType.None; //fonte da legenda Pane.Legend.FontSpec.Size = 11f; //Slices TimeSpan tspTot = new TimeSpan(0, 0, 0); for (int j = 0; j < _tasks.Count; j++) { TimeSpan tsp = new TimeSpan(0, 0, (int)_times[j]); tspTot += tsp; Color cor = Color.FromArgb(rnd.Next(240), rnd.Next(240), rnd.Next(240)); ZedGraph.PieItem p = Pane.AddPieSlice(Math.Round(_times[j] / 3600, 2), cor, Color.White, 45f, 0.1, _tasks[j]); //Menu pie slices removal feature ToolStripMenuItem m = new ToolStripMenuItem(_tasks[j]); m.Checked = true; frmPie.itemsMenu.DropDownItems.Add(m); m.Click += new EventHandler(m_Click); frmPie.vals.Add(_times[j] / 3600); } //Sets menu text frmPie.itemsMenu.Text = lblTask.Text; //Total label txt = new ZedGraph.TextObj(lblTotTime.Text + "\n" + Math.Round(tspTot.TotalHours, 1).ToString() + " h", 0.9f, 0.17f, ZedGraph.CoordType.PaneFraction); Pane.GraphObjList.Add(txt); txt.FontSpec.Fill = new ZedGraph.Fill(Color.White, Color.Yellow, 45f); //shadow ZedGraph.TextObj txt2 = new ZedGraph.TextObj(txt); txt2.FontSpec.Fill = new ZedGraph.Fill(Color.Black); txt2.Location.X += 0.006f; txt2.Location.Y += 0.008f; Pane.GraphObjList.Add(txt2); frmPie.zedGraph.AxisChange(); frmPie.Show(); }