private void BindDataForChart(GraphPane myPane) { //绑定数据 myPane.AddPieSlice(EmployeeStatistics.ManCount, Color.FromArgb(14, 144, 206), Color.FromArgb(16, 98, 154), Color.FromArgb(12, 200, 255), 0, "男"); myPane.AddPieSlice(EmployeeStatistics.WomenCount, Color.FromArgb(252, 210, 2), Color.FromArgb(198, 165, 4), Color.FromArgb(249, 221, 81), 0, "女"); }
private void DrawGraph() { // Получим панель для рисования GraphPane pane = zedGraph.GraphPane; // Очистим список кривых на тот случай, если до этого сигналы уже были нарисованы pane.CurveList.Clear(); //Количество параметров int itemscount = 5; // Подписи параметров string[] names = new string[itemscount]; // Размер double[] values = new double[itemscount]; // Заполним данные for (int i = 0; i < itemscount; i++) { names[0] = string.Format("Q1"); names[1] = string.Format("Q2"); names[2] = string.Format("Q3"); names[3] = string.Format("Q5т"); names[4] = string.Format("Q5топ"); values[0] = _HB.Q1prRez; values[1] = _HB.Q2prRez; values[2] = _HB.Q3prRez; values[3] = _HB.Q4prRez; values[4] = _HB.Q5topprRez; } // Круговая диаграмма с выбором цвета pane.AddPieSlice(values[0], Color.Tan, 0F, names[0]); pane.AddPieSlice(values[1], Color.PeachPuff, 0F, names[1]); pane.AddPieSlice(values[2], Color.Peru, 0F, names[2]); pane.AddPieSlice(values[3], Color.NavajoWhite, 0F, names[3]); pane.AddPieSlice(values[4], Color.SandyBrown, 0F, names[4]); //pane.AddPieSlices(values, names); // цвет устанавливается автоматически pane.Legend.IsVisible = false; foreach (var x in pane.CurveList.OfType <PieItem>()) { x.LabelType = PieLabelType.Name_Percent; } // Изменим текст заголовка графика pane.Title.Text = "Результат расчета теплового баланса сушильного барабана"; // Вызываем метод AxisChange (), чтобы обновить данные об осях. zedGraph.AxisChange(); // Обновляем график zedGraph.Invalidate(); }
public PieSampleDemo() : base( "Code Project Pie Sample", "Pie Sample", DemoType.Pie, DemoType.Tutorial ) { GraphPane myPane = base.GraphPane; // Set the GraphPane title myPane.Title.Text = "2004 ZedGraph Sales by Region\n($M)"; myPane.Title.FontSpec.IsItalic = true; myPane.Title.FontSpec.Size = 24f; myPane.Title.FontSpec.Family = "Times New Roman"; // Fill the pane background with a color gradient myPane.Fill = new Fill( Color.White, Color.Goldenrod, 45.0f ); // No fill for the axis background myPane.Chart.Fill.Type = FillType.None; // Set the legend to an arbitrary location myPane.Legend.Position = LegendPos.Float ; myPane.Legend.Location = new Location( 0.95f, 0.15f, CoordType.PaneFraction, AlignH.Right, AlignV.Top ); myPane.Legend.FontSpec.Size = 10f; myPane.Legend.IsHStack = false; // Add some pie slices PieItem segment1 = myPane.AddPieSlice( 20, Color.Navy, Color.White, 45f, 0, "North" ); PieItem segment3 = myPane.AddPieSlice( 30, Color.Purple, Color.White, 45f, .0, "East" ); PieItem segment4 = myPane.AddPieSlice( 10.21, Color.LimeGreen, Color.White, 45f, 0, "West" ); PieItem segment2 = myPane.AddPieSlice( 40, Color.SandyBrown, Color.White, 45f, 0.2, "South" ); PieItem segment6 = myPane.AddPieSlice( 250, Color.Red, Color.White, 45f, 0, "Europe" ); PieItem segment7 = myPane.AddPieSlice( 50, Color.Blue, Color.White, 45f, 0.2, "Pac Rim" ); PieItem segment8 = myPane.AddPieSlice( 400, Color.Green, Color.White, 45f, 0, "South America" ); PieItem segment9 = myPane.AddPieSlice( 50, Color.Yellow, Color.White, 45f, 0.2, "Africa" ); segment2.LabelDetail.FontSpec.FontColor = Color.Red; // Sum up the pie values CurveList curves = myPane.CurveList ; double total = 0 ; for ( int x = 0 ; x < curves.Count ; x++ ) total += ((PieItem)curves[x]).Value ; // Make a text label to highlight the total value TextObj text = new TextObj( "Total 2004 Sales\n" + "$" + total.ToString () + "M", 0.18F, 0.40F, CoordType.PaneFraction ); text.Location.AlignH = AlignH.Center; text.Location.AlignV = AlignV.Bottom; text.FontSpec.Border.IsVisible = false ; text.FontSpec.Fill = new Fill( Color.White, Color.FromArgb( 255, 100, 100 ), 45F ); text.FontSpec.StringAlignment = StringAlignment.Center ; myPane.GraphObjList.Add( text ); // Create a drop shadow for the total value text item TextObj text2 = new TextObj( text ); text2.FontSpec.Fill = new Fill( Color.Black ); text2.Location.X += 0.008f; text2.Location.Y += 0.01f; myPane.GraphObjList.Add( text2 ); base.ZedGraphControl.AxisChange(); }
private void BindDataForChart(GraphPane myPane) { //绑定数据 myPane.AddPieSlice(EmployeeStatistics.WorkAge0to1Count, Color.FromArgb(14, 144, 206), Color.FromArgb(16, 98, 154), Color.FromArgb(12, 200, 255), 0, "1年以内"); myPane.AddPieSlice(EmployeeStatistics.WorkAge1to3Count, Color.FromArgb(176, 222, 9), Color.FromArgb(127, 157, 11), Color.FromArgb(200, 225, 109), 0, "1-3年"); myPane.AddPieSlice(EmployeeStatistics.WorkAge3to5Count, Color.FromArgb(248, 255, 1), Color.FromArgb(183, 201, 5), Color.FromArgb(241, 245, 5), 0, "3-5年"); myPane.AddPieSlice(EmployeeStatistics.WorkAge5to8Count, Color.FromArgb(252, 210, 2), Color.FromArgb(198, 165, 4), Color.FromArgb(249, 221, 81), 0, "5-8年"); myPane.AddPieSlice(EmployeeStatistics.WorkAge8Count, Color.FromArgb(255, 159, 6), Color.FromArgb(210, 131, 1), Color.FromArgb(251, 185, 77), 0, "8年以上"); }
private void UpdateGraphManaSymbols() { zgManaSymbols.GraphPane.CurveList.Clear(); GraphPane pane = zgManaSymbols.GraphPane; pane.Legend.IsVisible = false; pane.Title.Text = String.Format("Mana Symbols - {0}", CardCountText()); Dictionary <char, int> calculatedManaSymbols = new Dictionary <char, int>(); foreach (Card c in cards) { if (c.IsInSideboard) { continue; } foreach (KeyValuePair <char, int> symb in c.CalculatedManaSymbols) { if (calculatedManaSymbols.ContainsKey(symb.Key)) { calculatedManaSymbols[symb.Key] += symb.Value * c.Amount; } else { calculatedManaSymbols.Add(symb.Key, symb.Value * c.Amount); } } } foreach (var item in calculatedManaSymbols) { Color c = Color.Gold; // Other string name = "Multicolor and others"; if (item.Key == 'W') { c = Color.White; name = "White"; } else if (item.Key == 'U') { c = Color.Blue; name = "Blue"; } else if (item.Key == 'R') { c = Color.Red; name = "Red"; } else if (item.Key == 'B') { c = Color.Black; name = "Black"; } else if (item.Key == 'G') { c = Color.DarkGreen; name = "Green"; } PieItem pi = pane.AddPieSlice(item.Value, c, 0, name + " - " + item.Value); } zgManaSymbols.AxisChange(); }
private void OnRenderGraph(ZedGraphWeb webObject, Graphics g, MasterPane pane) { DataSet ds = (DataSet)Cache["CurseCache"]; GraphPane myPane = pane[0]; myPane.Title.Text = "Nr total de statii in functie de statia de pornire"; myPane.XAxis.Title.Text = "Statie pornire"; myPane.YAxis.Title.Text = "Nr. statii"; Color[] colors = { Color.Red, Color.Yellow, Color.Green, Color.Blue, Color.Purple, Color.Pink, Color.Plum, Color.Silver, Color.Salmon }; if (ds != null) { List <string> listaX = new List <string>(); PointPairList list = new PointPairList(); int i = 0; foreach (DataRow r in ds.Tables[0].Rows) { listaX.Add(r[2].ToString()); //rezultat list.Add(0, (int)r[3], i++); // k } i = 0; foreach (DataRow r in ds.Tables[0].Rows) { PieItem segment1 = myPane.AddPieSlice(( int)r[3], colors[(i++) % colors.Length], Color.White, 45f, (i % 2 == 0) ? 0.2 : 0, r[2].ToString()); } } }
public override void FillData(GraphPane pane, ChartData data) { for (int i = 0; i < data.Items.Count; i++) { pane.AddPieSlice(data.Items[i].Values[0], GetColor(i), 0.02, data.Items[i].Label); } }
public void CreateComponentDistributionGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the GraphPane title myPane.Title.Text = "Component Proportion"; myPane.Title.FontSpec.Size = 24f; myPane.Title.FontSpec.Family = "Tahoma"; // Fill the pane background with a color gradient // myPane.Fill = new Fill(Color.White, Color.WhiteSmoke, 45.0f); // No fill for the chart background myPane.Chart.Fill.Type = FillType.None; myPane.Legend.IsVisible = false; // Add some pie slices double cumulative = 0.0; for (int i = 0; i < pls.Factors.Count; i++) { cumulative = pls.Factors[i].DependentCumulativeProportion; myPane.AddPieSlice(pls.Factors[i].DependentProportion, colors[i % colors.Length], 0.1, pls.Factors[i].Index.ToString()); } double unexplained = 1 - cumulative; myPane.AddPieSlice(unexplained, Color.LightGray, 0.1, "Unexplained"); myPane.XAxis.Scale.MinAuto = true; myPane.XAxis.Scale.MaxAuto = true; myPane.YAxis.Scale.MinAuto = true; myPane.YAxis.Scale.MaxAuto = true; myPane.XAxis.Scale.MagAuto = true; myPane.YAxis.Scale.MagAuto = true; // Calculate the Axis Scale Ranges zgc.AxisChange(); zgc.Invalidate(); }
private void CreateGraph1(ZedGraphControl zgc) { // get a reference to the GraphPane GraphPane myPane = zgc.GraphPane; // Set the GraphPane title myPane.Title.Text = "Cycling Graph"; myPane.Title.FontSpec.IsItalic = true; myPane.Title.FontSpec.Size = 24f; myPane.Title.FontSpec.Family = "Times New Roman"; // Fill the pane background with a color gradient myPane.Fill = new Fill(Color.White, Color.Goldenrod, 45.0f); // No fill for the chart background myPane.Chart.Fill.Type = FillType.None; // Set the legend to an arbitrary location myPane.Legend.Position = LegendPos.Float; myPane.Legend.Location = new Location(0.95f, 0.15f, CoordType.PaneFraction, AlignH.Right, AlignV.Top); myPane.Legend.FontSpec.Size = 10f; myPane.Legend.IsHStack = false; // Add some pie slices PieItem segment1 = myPane.AddPieSlice(20, Color.Navy, Color.White, 45f, 0, "Heart Rate"); PieItem segment3 = myPane.AddPieSlice(30, Color.Purple, Color.White, 45f, .0, "Speed"); PieItem segment4 = myPane.AddPieSlice(10.21, Color.LimeGreen, Color.White, 45f, 0, "Cadence"); PieItem segment2 = myPane.AddPieSlice(40, Color.SandyBrown, Color.White, 45f, 0.2, "Altitude"); PieItem segment6 = myPane.AddPieSlice(250, Color.Red, Color.White, 45f, 0, "Power"); segment2.LabelDetail.FontSpec.FontColor = Color.Red; // Sum up the pie values CurveList curves = myPane.CurveList; double total = 0; for (int x = 0; x < curves.Count; x++) { total += ((PieItem)curves[x]).Value; } // Calculate the Axis Scale Ranges zgc.AxisChange(); }
private void CreateComponentGraph(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; if (ExportMemoryEstimate.isCalculatingMemoryEstimate()) { myPane.Title.Text = "Calculating Memory... Try again soon.."; return; } Color[] Colors = new Color[] { Color.Red, Color.Green, Color.Blue, Color.Yellow, Color.Orange, Color.Teal, Color.Brown, Color.Pink, Color.Purple, Color.Tan, Color.Silver, Color.Magenta, Color.Maroon, Color.PeachPuff, Color.Black, Color.CornflowerBlue, Color.Cyan, Color.Khaki, Color.Azure, Color.CadetBlue, Color.Salmon, Color.Turquoise, Color.Tomato, Color.Plum }; myPane.Title.Text = "XBOX Memory Estimate"; int numMemoryElements = ExportMemoryEstimate.getNumMemoryElements(); for (int i = 0; i < numMemoryElements; i++) { ExportMemoryEstimate.memoryElement me = ExportMemoryEstimate.getMemoryElement(i); myPane.AddPieSlice(me.mMemoryInBytes, Colors[i % Colors.Length], 0, me.mName); listBox1.Items.Add(me.mName + " : " + bytesToMB(me.mMemoryInBytes) + "MB"); } listBox1.Items.Add("---------"); int totalAvailbytes = ExportMemoryEstimate.giveTotalAvailableMemory(); myPane.AddPieSlice(totalAvailbytes, Color.White, 0, "XBOX FREE Memory"); listBox1.Items.Add("XBOX FREE Memory" + " : " + bytesToMB(totalAvailbytes) + "MB"); float totalAvail = bytesToMB(totalAvailbytes); //this will hide the axis zgc.AxisChange(); }
private void GenerateGraph() { GraphPane pane = zedIPAccess1.GraphPane; pane.CurveList.Clear(); pane.Title.Text = "The 5 Top of IP Access Access Page Graph"; pane.Legend.Position = LegendPos.InsideTopLeft; pane.Chart.Fill = new Fill(Color.White, Color.FromArgb(255, 209, 164), Color.White, 90F); pane.Fill = new Fill(Color.FromArgb(250, 250, 255)); if (_listTopOf5.Count > 0) { Color[] colors = new Color[] { Color.Red, Color.PowderBlue, Color.SeaGreen, Color.Orange, Color.Yellow, Color.Magenta, Color.Gainsboro }; double total = _totalData; long itemTotal = 0; for (int i = 0; i < _listTopOf5.Count; i++) { itemTotal = itemTotal + _listTopOf5[i].Total; pane.AddPieSlice(_listTopOf5[i].Total, colors[i], Color.White, 45f, 0.2, "IP: " + _listTopOf5[i].Client_IP + " (" + string.Format("{0:0.##}", (double)(_listTopOf5[i].Total * 100 / total)) + " %)"); } double remains = total - itemTotal; if (remains > 0) { pane.AddPieSlice(remains, colors[5], Color.White, 45f, 0.2, "Others (" + string.Format("{0:0.##}", (double)(remains * 100 / total)) + " %)"); } } zedIPAccess1.IsShowPointValues = true; zedIPAccess1.AxisChange(); }
private void GenerateGraph() { GraphPane pane = this.zedPercentStatus1.GraphPane; pane.CurveList.Clear(); pane.Title.Text = "The 3 Top of HTTP Status Graph"; pane.Legend.Position = LegendPos.InsideTopRight; pane.Chart.Fill = new Fill(Color.White, Color.BurlyWood, Color.White, 90F); pane.Fill = new Fill(Color.FromArgb(250, 250, 255)); if (_listTopOf3.Count > 0) { Color[] colors = new Color[] { Color.Red, Color.Blue, Color.Green, Color.Purple }; double total = _totalData; long itemTotal = 0; for (int i = 0; i < _listTopOf3.Count; i++) { itemTotal = itemTotal + _listTopOf3[i].Total; pane.AddPieSlice(_listTopOf3[i].Total, colors[i], Color.White, 45f, 0.2, "HTTP Status: " + _listTopOf3[i].Protocol_Status + " (" + string.Format("{0:0.##}", (double)(_listTopOf3[i].Total * 100 / total)) + " %)"); } double remains = total - itemTotal; if (remains > 0) { pane.AddPieSlice(remains, colors[3], Color.White, 45f, 0.2, "Others (" + string.Format("{0:0.##}", (double)(remains * 100 / total)) + " %)"); } } zedPercentStatus1.IsShowPointValues = true; zedPercentStatus1.AxisChange(); SetSize(); }
public GraphPane plotPieChart(ZedGraphControl zgc, HRMObjectClass hrmObject) { GraphPane pane = zgc.GraphPane; clearPane(pane); pane.AddYAxis(""); pane.Title.Text = "Power Balance"; // Left Right Balance % distribution PieItem segment1 = pane.AddPieSlice(hrmObject.calcAvg(), Color.LightBlue, 0F, "Left Leg"); PieItem segment2 = pane.AddPieSlice(100 - hrmObject.calcAvg(), Color.LightGreen, 0F, "Right Leg"); // Segment Label Type (Name and %) segment1.LabelType = PieLabelType.Percent; segment2.LabelType = PieLabelType.Percent; ZGraphControl(zgc); return(pane); }
private void UpdateGraphDistribution() { // http://zedgraph.dariowiz.com/index77e8.html?title=Pie_Charts zgDistribution.GraphPane.CurveList.Clear(); GraphPane pane = zgDistribution.GraphPane; pane.Legend.IsVisible = false; pane.Title.Text = String.Format("Distribution - {0}", CardCountText()); var qry = cards.Where(wh => !wh.IsInSideboard).GroupBy(grp => grp.Type.Substring(0, grp.Type.IndexOf('-') >= 0 ? grp.Type.IndexOf('-') : grp.Type.Length).Trim()) .Select(sel => new KeyValuePair <string, int>(sel.Key, sel.Sum(sum => sum.Amount))); foreach (var item in qry) { Color c = Color.Pink; // Other if (item.Key == "Creature") { c = Color.DarkRed; } else if (item.Key == "Basic Land") { c = Color.Goldenrod; } else if (item.Key == "Land") { c = Color.Goldenrod; } else if (item.Key == "Artifact Land") { c = Color.Goldenrod; } else if (item.Key == "Enchantment") { c = Color.Green; } else if (item.Key == "Instant") { c = Color.Navy; } else if (item.Key == "Sorcery") { c = Color.DeepSkyBlue; } else if (item.Key == "Artifact") { c = Color.LightGray; } PieItem pi = pane.AddPieSlice(item.Value, c, 0, item.Key + " - " + item.Value); } zgDistribution.AxisChange(); }
private void plotgraph() { Baglanti.GetBaglanti.Close(); Baglanti.GetBaglanti.Open(); Baglanti.GetKomut.CommandText = "Select * From KitapKayitlari"; Baglanti.GetKomut.Connection = Baglanti.GetBaglanti; OleDbDataReader oku = Baglanti.GetKomut.ExecuteReader(); int alinan = 0; int kalan = 0; while (oku.Read()) { if ((oku["Odunc"].ToString()) == "Teslim Alındı") { alinan += 1; } else if ((oku["Odunc"].ToString()) == "Alınmadı") { kalan += 1; } } ZedGraphControl zedControl = new ZedGraphControl(); GraphPane pane = new GraphPane(); int[] kveriler = new int[2]; pane.XAxis.IsVisible = false; pane.YAxis.IsVisible = false; string[] x0 = new string[] { "Kütüphanedi kitap sayısı", "Alınan kitap sayısı" }; double[] y0 = new double[] { kalan, alinan }; Color[] c0 = new Color[] { Color.DarkBlue, Color.Red }; pane.Fill = new Fill(Color.White, Color.White, 45.0f); pane.Chart.Fill.Type = FillType.None; pane.Legend.Position = LegendPos.Float; pane.Legend.Location = new Location(0.30f, 0.05f, CoordType.PaneFraction, AlignH.Right, AlignV.Top); pane.Legend.FontSpec.Size = 10f; pane.Legend.IsHStack = false; for (int i = 0; i < 2; i++) { PieItem segment1 = pane.AddPieSlice(y0[i], c0[i], 0.1, x0[i]); segment1.LabelType = PieLabelType.Name_Value_Percent; } //pane.AddPieSlices(y0, x0); zedControl.GraphPane = pane; zedControl.Height = this.Height; zedControl.Width = this.Width; zedControl.IsEnableWheelZoom = false; this.Controls.Add(zedControl); }
static int CreateTablePieChart(string fn) { GraphPane myPane = new GraphPane(new RectangleF(0, 0, 640, 480), "Flavour", "X", "Y"); // Add some pie slices PieItem segment01 = myPane.AddPieSlice(15, Color.Navy, Color.White, 45f, 0.10, "Salt"); PieItem segment02 = myPane.AddPieSlice(20, Color.DarkRed, Color.White, 45f, 0.00, "Pepper"); PieItem segment03 = myPane.AddPieSlice(26, Color.LimeGreen, Color.White, 45f, 0.00, "Nutmeg "); segment03.LabelDetail.FontSpec.FontColor = Color.Red; // Calculate the Axis Scale Ranges myPane.AxisChange(); Bitmap bm = new Bitmap(1, 1); using (Graphics g = Graphics.FromImage(bm)) myPane.AxisChange(g); myPane.GetImage().Save(fn, ImageFormat.Png); return(3); }
public void CreateChart(ZedGraphControl zgc, double Metros_lineares_livres, double Metros_lineares_ocupados, double Metros_ocupados_estimados) { GraphPane myPane = zgc.GraphPane; // Set the GraphPane title myPane.Title.Text = ""; myPane.Fill.Color = Color.LightGray; myPane.Chart.Fill.Type = FillType.None; double total = Metros_lineares_livres + Metros_lineares_ocupados + Metros_ocupados_estimados; double percent_Livre = 0; double percent_ocupado = 0; double percent_ocupado_estimado = 0; if (total > 0) { percent_Livre = Metros_lineares_livres * 100 / total; percent_ocupado = Metros_lineares_ocupados * 100 / total; percent_ocupado_estimado = Metros_ocupados_estimados * 100 / total; } // Adicionar as fatias: myPane.CurveList.Clear(); myPane.AddPieSlice(Metros_lineares_livres, Color.Green, Color.White, 45f, .05, percent_Livre > 0 ? string.Format("Livre ({0:.00}%)", percent_Livre) : "Livre"); myPane.AddPieSlice(Metros_lineares_ocupados, Color.Red, Color.White, 45f, .0, percent_ocupado > 0 ? string.Format("Ocupado ({0:.00}%)", percent_ocupado) : "Ocupado"); if (Metros_ocupados_estimados > 0) { myPane.AddPieSlice(Metros_ocupados_estimados, Color.IndianRed, Color.White, 45f, .0, string.Format("Ocupado (estimado) ({0:.00}%)", percent_ocupado_estimado)); } zgc.AxisChange(); zgc.Refresh(); }
private void BindDataForChart(GraphPane myPane) { //绑定数据 myPane.AddPieSlice(EmployeeStatistics.Age0to20Count, Color.FromArgb(14, 144, 206), Color.FromArgb(16, 98, 154), Color.FromArgb(12, 200, 255), 0, "20岁以下"); myPane.AddPieSlice(EmployeeStatistics.Age21to25Count, Color.FromArgb(5, 209, 22), Color.FromArgb(5, 146, 15), Color.FromArgb(5, 255, 30), 0, "21-25岁"); myPane.AddPieSlice(EmployeeStatistics.Age26to30Count, Color.FromArgb(176, 222, 9), Color.FromArgb(127, 157, 11), Color.FromArgb(200, 225, 109), 0, "26-30岁"); myPane.AddPieSlice(EmployeeStatistics.Age31to35Count, Color.FromArgb(248, 255, 1), Color.FromArgb(183, 201, 5), Color.FromArgb(241, 245, 5), 0, "31-35岁"); myPane.AddPieSlice(EmployeeStatistics.Age36to40Count, Color.FromArgb(252, 210, 2), Color.FromArgb(198, 165, 4), Color.FromArgb(249, 221, 81), 0, "36-40岁"); myPane.AddPieSlice(EmployeeStatistics.Age41to45Count, Color.FromArgb(255, 159, 6), Color.FromArgb(210, 131, 1), Color.FromArgb(251, 185, 77), 0, "41-45岁"); myPane.AddPieSlice(EmployeeStatistics.Age46to50Count, Color.FromArgb(255, 101, 1), Color.FromArgb(212, 84, 1), Color.FromArgb(250, 158, 99), 0, "46-50岁"); myPane.AddPieSlice(EmployeeStatistics.Age51to55Count, Color.FromArgb(255, 15, 0), Color.FromArgb(203, 13, 3), Color.FromArgb(249, 124, 117), 0, "51-55岁"); myPane.AddPieSlice(EmployeeStatistics.Age56to60Count, Color.FromArgb(226, 109, 255), Color.FromArgb(171, 12, 211), Color.FromArgb(233, 170, 248), 0, "56-60岁"); myPane.AddPieSlice(EmployeeStatistics.Age61Count, Color.FromArgb(166, 226, 243), Color.FromArgb(84, 198, 230), Color.FromArgb(178, 227, 241), 0, "60岁以上"); }
/// <summary> /// Forces a update of the scatter plot. /// </summary> /// public void UpdateGraph() { GraphPane pane = zedGraphControl.GraphPane; pane.CurveList.Clear(); if (Cumulative) { // Set the titles and axis labels pane.Title.Text = "Distribution"; pane.XAxis.Title.IsVisible = true; pane.YAxis.Title.IsVisible = true; // Add points for distribution var list = new PointPairList(); foreach (var component in source) { list.Add(component.Index, component.CumulativeProportion); } // Add a single curve LineItem curve = pane.AddCurve("label", list, Color.Red, SymbolType.Circle); curve.Line.Width = 2.0F; curve.Line.IsAntiAlias = true; curve.Symbol.Fill = new Fill(Color.White); curve.Symbol.Size = 7; } else { // Set the titles and axis labels pane.Title.Text = "Component proportion"; pane.XAxis.Title.IsVisible = false; pane.YAxis.Title.IsVisible = false; // Add pie slices for shares foreach (var component in source) { int index = component.Index; Color color = colors[index % colors.Count]; pane.AddPieSlice(component.Proportion, color, 0.1, index.ToString()); } } // Calculate the Axis Scale zedGraphControl.AxisChange(); zedGraphControl.Invalidate(); }
private void BindDataForChart(GraphPane myPane) { //绑定数据 myPane.AddPieSlice(EmployeeStatistics.XiaoXueCount, Color.FromArgb(14, 144, 206), Color.FromArgb(16, 98, 154), Color.FromArgb(12, 200, 255), 0, "小学"); myPane.AddPieSlice(EmployeeStatistics.ChuZhongCount, Color.FromArgb(255, 15, 0), Color.FromArgb(203, 13, 3), Color.FromArgb(249, 124, 117), 0, "初中"); myPane.AddPieSlice(EmployeeStatistics.ZhongZhuanCount, Color.FromArgb(166, 226, 243), Color.FromArgb(84, 198, 230), Color.FromArgb(178, 227, 241), 0, "中专"); myPane.AddPieSlice(EmployeeStatistics.JiXiaoCount, Color.FromArgb(255, 101, 1), Color.FromArgb(212, 84, 1), Color.FromArgb(250, 158, 99), 0, "技校"); myPane.AddPieSlice(EmployeeStatistics.GaoZhongCount, Color.FromArgb(5, 209, 22), Color.FromArgb(5, 146, 15), Color.FromArgb(5, 255, 30), 0, "高中"); myPane.AddPieSlice(EmployeeStatistics.DaZhuanCount, Color.FromArgb(226, 109, 255), Color.FromArgb(171, 12, 211), Color.FromArgb(233, 170, 248), 0, "大专"); myPane.AddPieSlice(EmployeeStatistics.BenKeCount, Color.FromArgb(248, 255, 1), Color.FromArgb(183, 201, 5), Color.FromArgb(241, 245, 5), 0, "本科"); myPane.AddPieSlice(EmployeeStatistics.ShuoShiCount, Color.FromArgb(255, 159, 6), Color.FromArgb(210, 131, 1), Color.FromArgb(251, 185, 77), 0, "硕士"); myPane.AddPieSlice(EmployeeStatistics.BoShiCount, Color.FromArgb(252, 210, 2), Color.FromArgb(198, 165, 4), Color.FromArgb(249, 221, 81), 0, "博士"); }
/**/ /// <summary> /// 画柱状图 /// </summary> /// <param name="graphPane"></param> private void DrawBar(GraphPane graphPane) { //折綫圖 if (IsCurveBar) { LineItem myCurve = graphPane.AddCurve("公司名称", null, CurveForBar, Color.Black, SymbolType.Circle); //myCurve.Line.Fill = new Fill(Color.White, Color.Transparent, -45F); List <double> curveList = new List <double>(); for (int i = 0; i < CurveForBar.Length; i++) { curveList.Add(CurveForBar[i]); } CreateBarLabels(graphPane, "f1", curveList); } //柱狀圖 for (int i = 0; i < Count; i++) { //graphPane.AddBar(LabelList[i], DataSource[i], Colors[i]).Bar.Fill = new Fill(Colors[i], Color.White, Colors[i]); BarItem myBar = graphPane.AddBar(LabelList[i], DataSource[i], Colors[i]); myBar.Bar.Border = new Border(false, Color.Black, 0); myBar.Bar.Fill = new Fill(Colors[i]); } //graphPane.Legend.IsHStack = false; //当有多个显示项的时候设置 Y 轴数据是叠加的还是分开的 (Title) //graphPane.BarSettings.Type = BarType.SortedOverlay; //当有多个显示项的时候设置 Y 轴数据是叠加的还是分开的 graphPane.XAxis.MajorTic.IsBetweenLabels = true; string[] labels = NameList.ToArray(); graphPane.XAxis.Scale.TextLabels = labels; graphPane.XAxis.Type = AxisType.Text; graphPane.Fill = new Fill(Color.White, Color.FromArgb(235, 235, 238), 45.0f); //graphPane.Chart.Fill = new Fill(Color.White, Color.LightGoldenrodYellow, 45.0f); } /**/ /// <summary> /// 画饼图 /// </summary> /// <param name="graphPane"></param> private void DrawPie(GraphPane graphPane) { graphPane.Fill = new Fill(Color.White, Color.White, 45.0f); graphPane.Legend.Position = LegendPos.Right;//LegendPos.Float; graphPane.Legend.Location = new Location(0.95f, 0.15f, CoordType.PaneFraction, AlignH.Right, AlignV.Top); graphPane.Legend.Border.Color = Color.White; graphPane.Legend.FontSpec.Size = 20f; graphPane.Legend.IsHStack = false; graphPane.Title.FontSpec.Size = 30f; for (int i = 0; i < Count; i++) { PieItem myPie = graphPane.AddPieSlice(ScaleData[i], Colors[i], Colors[i], 45f, 0, NameList[i]); myPie.LabelDetail.FontSpec.Size = 22f; myPie.LabelType = PieLabelType.Value; //饼图上的文字注释 } }
/** * Grafico vazio: usado quando aparecem ocupacoes negativas (erros nos dados) */ private void CreateEmptyChart(ZedGraphControl zgc) { GraphPane myPane = zgc.GraphPane; // Set the GraphPane title myPane.Title.Text = ""; myPane.Fill.Color = Color.LightGray; myPane.Chart.Fill.Type = FillType.None; // Adicionar as fatias: myPane.CurveList.Clear(); myPane.AddPieSlice(1, Color.LightSlateGray, Color.White, 45f, .0, "Ocupação não calculável"); zgc.AxisChange(); zgc.Refresh(); }
/// <summary> /// 饼形图表 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button11_Click(object sender, EventArgs e) { myPane = zedGraphControl1.GraphPane; PieItem segment1 = myPane.AddPieSlice(20, Color.Navy, Color.White, 45.0f, 0, "North"); PieItem segment3 = myPane.AddPieSlice(30, Color.Purple, Color.White, 45f, 0, "East"); //六个参数分别为:在整个饼形图中占的比重,渐变颜色1,渐变颜色2,渐变颜色角度,远离中心点的距离,饼形图的文字注释。 PieItem segment4 = myPane.AddPieSlice(10.21, Color.LimeGreen, Color.White, 45f, 0, "West"); PieItem segment2 = myPane.AddPieSlice(40, Color.SandyBrown, Color.White, 45f, 0.2, "South"); PieItem segment6 = myPane.AddPieSlice(250, Color.Red, Color.White, 45f, 0, "Europe"); PieItem segment7 = myPane.AddPieSlice(50, Color.Blue, Color.White, 45f, 0.2, "Pac Rim"); PieItem segment8 = myPane.AddPieSlice(400, Color.Green, Color.White, 45f, 0, "South America"); PieItem segment9 = myPane.AddPieSlice(50, Color.Yellow, Color.White, 45f, 0.2, "Africa"); segment2.LabelDetail.FontSpec.FontColor = Color.Red; //对其中一部分的Label提示信息进行设置 zedGraphControl1.Refresh(); }
// 製作 PieChart public void CreatePieChart() { zedGraphPane.CurveList.Clear(); zedGraphPane.Title.Text = "Result"; Color[] colors = { Color.Green, Color.Red, Color.Yellow, Color.Blue, Color.Purple }; int colorIndex = 0; foreach (string[] currentStringArray in pieChartList) { string title = currentStringArray[0] + "\t" + currentStringArray[1]; double value = Convert.ToDouble(currentStringArray[1]); zedGraphPane.AddPieSlice(value, colors[colorIndex % 5], 0, title); colorIndex++; } zedGraph.AxisChange(); }
private void drawPie() { zedGraph.GraphPane.CurveList.Clear(); zedGraph.GraphPane.GraphObjList.Clear(); GraphPane myPane = zedGraph.GraphPane; myPane.Title.Text = "Грфик платежей"; for (int i = 0; i < _payments.Count; i++) { PieItem item = myPane.AddPieSlice(_payments[i].Dolg, getRandomColor(), 0F, _payments[i].Dolg.ToString()); item.LabelType = PieLabelType.Value; } zedGraph.AxisChange(); // Обновляем график zedGraph.Invalidate(); }
public void CreateComponentDistributionGraph(ZedGraphControl zgc) { ColorSequenceCollection sequence = new ColorSequenceCollection(); GraphPane myPane = zgc.GraphPane; myPane.CurveList.Clear(); // Set the GraphPane title myPane.Title.Text = "Component Proportion"; myPane.Title.FontSpec.Size = 24f; myPane.Title.FontSpec.Family = "Tahoma"; // Fill the pane background with a color gradient // myPane.Fill = new Fill(Color.White, Color.WhiteSmoke, 45.0f); // No fill for the chart background myPane.Chart.Fill.Type = FillType.None; myPane.Legend.IsVisible = false; // Add some pie slices for (int i = 0; i < pca.Components.Count; i++) { myPane.AddPieSlice(pca.Components[i].Proportion, sequence[i], 0.1, pca.Components[i].Index.ToString()); } myPane.XAxis.Scale.MinAuto = true; myPane.XAxis.Scale.MaxAuto = true; myPane.YAxis.Scale.MinAuto = true; myPane.YAxis.Scale.MaxAuto = true; myPane.XAxis.Scale.MagAuto = true; myPane.YAxis.Scale.MagAuto = true; // Calculate the Axis Scale Ranges zgc.AxisChange(); zgc.Invalidate(); }
private void drawParts(Dictionary <ProblemParts, double> data) { ChartView.GraphPane.CurveList.Clear(); ChartView.GraphPane.GraphObjList.Clear(); piePane = ChartView.GraphPane; piePane.Title.Text = "Ratio of dangerous state to normal for parts"; var labels = new List <string>(); var values = new List <double>(); int i = 0; foreach (var key in data.Keys) { PieItem pieSlice = piePane.AddPieSlice(data[key], colors[i], 0F, key.ToString()); //pieSlice.LabelType = PieLabelType.None; //values.Add(data[key]); //labels.Add(key.ToString()); i++; } //piePane.AddPieSlices(values.ToArray(), labels.ToArray()); ChartView.AxisChange(); ChartView.Invalidate(); }
private void BindDataForChart(GraphPane myPane) { //绑定数据 myPane.AddPieSlice(EmployeeStatistics.ContractCount, Color.FromArgb(14, 144, 206), Color.FromArgb(16, 98, 154), Color.FromArgb(12, 200, 255), 0, "合同工"); myPane.AddPieSlice(EmployeeStatistics.ExternalContractCount, Color.FromArgb(5, 209, 22), Color.FromArgb(5, 146, 15), Color.FromArgb(5, 255, 30), 0, "外劳力合同工"); myPane.AddPieSlice(EmployeeStatistics.ResidenceContractCount, Color.FromArgb(176, 222, 9), Color.FromArgb(127, 157, 11), Color.FromArgb(200, 225, 109), 0, "居住证合同工"); myPane.AddPieSlice(EmployeeStatistics.PartTimerCount, Color.FromArgb(226, 109, 255), Color.FromArgb(171, 12, 211), Color.FromArgb(233, 170, 248), 0, "兼职"); myPane.AddPieSlice(EmployeeStatistics.WorkContractCount, Color.FromArgb(166, 226, 243), Color.FromArgb(84, 198, 230), Color.FromArgb(178, 227, 241), 0, "劳务工"); myPane.AddPieSlice(EmployeeStatistics.PracticerCount, Color.FromArgb(255, 159, 6), Color.FromArgb(210, 131, 1), Color.FromArgb(251, 185, 77), 0, "实习生"); }
private void RefreshGraph() { var entry = FunctionList.SelectedItem as FunctionEntry; if (entry == null) { return; } GraphPane pane = DetailsGraph.GraphPane; pane.CurveList.Clear(); pane.Title.Text = "Function Breakdown (samples)"; using (var session = m_connection.DataEngine.OpenSession(m_snapshot.Id)) using (var tx = session.BeginTransaction()) { var totalTime = session.CreateQuery("select sum(c.Time) from Call c where c.Parent.Id = :parentId1") .SetInt32("parentId1", entry.Id) .UniqueResult <double>(); var inFunc = session.CreateQuery("select sum(c.Time) from Call c where c.Parent.Id = :parentId2 and c.Child.Id = 0") .SetInt32("parentId2", entry.Id) .UniqueResult <double>(); var children = session.CreateQuery("from Call c inner join fetch c.Child where c.Parent.Id = :parentId3 order by c.Time desc") .SetInt32("parentId3", entry.Id) .List <Call>(); int index = 1; double pieTotal = 0; int otherCount = 0; string otherName = null; const double Significant = 0.01; var inFuncFraction = inFunc / totalTime; if (inFunc > 0 && inFuncFraction >= Significant) { //add a slice for self if it is significant pane.AddPieSlice(inFunc, m_colors.ColorForIndex(0), 0.0, "(self)"); pieTotal += inFunc; } else { //otherwise just add it to the other pile ++otherCount; otherName = "(self)"; } foreach (var call in children) { double fraction = call.Time / totalTime; if (index < 8 && fraction > 0.02) { var slice = pane.AddPieSlice(call.Time, m_colors.ColorForIndex(1 + index++), 0.0, call.Child.Name); pieTotal += call.Time; if (fraction < 0.03) { slice.LabelType = PieLabelType.None; } } else { ++otherCount; otherName = call.Child.Name; } } //If we only found one "other" function, no sense marking it as other double otherTotal = totalTime - pieTotal; if (otherCount == 1) { var slice = pane.AddPieSlice(otherTotal, m_colors.ColorForIndex(index + 1), 0.0, otherName); slice.LabelType = PieLabelType.None; } else if (otherCount > 1) { pane.AddPieSlice(otherTotal, m_colors.ColorForIndex(1), 0.0, string.Format("Other: {0} functions", otherCount)); } tx.Commit(); } pane.Title.Text = entry.Name; pane.AxisChange(); DetailsGraph.Refresh(); }
private void GenerateGraph() { GraphPane pane = zedAccessPage1.GraphPane; pane.Title.Text = "The 5 Top of Total Access Page Graph"; pane.CurveList.Clear(); pane.Legend.Position = LegendPos.InsideTopLeft; pane.Chart.Fill = new Fill(Color.White, Color.Orange, 90F); pane.Fill = new Fill(Color.FromArgb(250, 250, 255)); if (_listTopOf5.Count > 0) { double total = _totalAccessYear; double itemTotal = 0; for (int i = 0; i < _listTopOf5.Count; i++) { itemTotal = itemTotal + _listTopOf5[i].Total; switch (i) { case 0: pane.AddPieSlice(_listTopOf5[i].Total, Color.Blue, Color.White, 45f, 0.2, _listTopOf5[i].Page_Access + " (" + string.Format("{0:0.##}", (double)(_listTopOf5[i].Total * 100 / total)) + " %)"); break; case 1: pane.AddPieSlice(_listTopOf5[i].Total, Color.Red, Color.White, 45f, 0.2, _listTopOf5[i].Page_Access + " (" + string.Format("{0:0.##}", (double)(_listTopOf5[i].Total * 100 / total)) + " %)"); break; case 2: pane.AddPieSlice(_listTopOf5[i].Total, Color.Green, Color.White, 45f, 0.2, _listTopOf5[i].Page_Access + " (" + string.Format("{0:0.##}", (double)(_listTopOf5[i].Total * 100 / total)) + " %)"); break; case 3: pane.AddPieSlice(_listTopOf5[i].Total, Color.Cyan, Color.White, 45f, 0.2, _listTopOf5[i].Page_Access + " (" + string.Format("{0:0.##}", (double)(_listTopOf5[i].Total * 100 / total)) + " %)"); break; case 4: pane.AddPieSlice(_listTopOf5[i].Total, Color.Purple, Color.White, 45f, 0.2, _listTopOf5[i].Page_Access + " (" + string.Format("{0:0.##}", (double)(_listTopOf5[i].Total * 100 / total)) + " %)"); break; } } double remains = total - itemTotal; if (remains > 0) { pane.AddPieSlice(remains, Color.Purple, Color.White, 45f, 0.2, "Others (" + string.Format("{0:0.##}", (double)(remains * 100 / total)) + " %)"); } } zedAccessPage1.IsShowPointValues = true; zedAccessPage1.AxisChange(); }
/// <summary> /// Creates a new CurveItem using the PointPairList and add it the the given pane. /// </summary> /// <param name="pane">the GraphPane object to which to add the new curve</param> /// <param name="points">a PointPairList collection defining the points for this curve</param> /// <returns>the newly created CurveItem added to the given GraphPane</returns> /// <remarks>This method must be overriden by childs</remarks> public override CurveItem CreateInPane( GraphPane pane, PointPairList points ) { PieItem x = pane.AddPieSlice( this.Value, this.Color, this.Displacement, this.Label ); this.CopyTo( x ); return x; }