具体代码如下:
private void Form2_Load(object sender, EventArgs e) { string colors = "#ffbb22,#ff9911,#aacc33,#aabbbb,#bb0033,#00cc33,#990099,#0011aa,#14D0EE,#B17EC3,#E67F16,#EE5907,#6A2DA1,#0A35F0,#A816D7,#D218AD,#EE0A96,#5A4DAE,#ACE9D9"; PieSeries pseries = new PieSeries(); pseries.Values.AddRange(new double[] { 0.2,0.3,0.1,0.2,0.2}); pseries.LabelVisible = true; pseries.LabelFormatter = new FarPoint.Win.Spread.Model.GeneralFormatter("0.00%", false); FillCollection fc = pseries.PieFills; List<SolidFill> list = new List<SolidFill>(); foreach (var color in colors.Split(new char[] { ',' })) { list.Add(new SolidFill(ColorTranslator.FromHtml(color))); } fc.Clear(); fc.AddRange(list.ToArray()); PiePlotArea plotArea = new PiePlotArea(); plotArea.Location = new PointF(0.2f, 0.2f); plotArea.Size = new SizeF(0.6f, 0.6f); plotArea.Series.Add(pseries); ChartModel model = new ChartModel(); model.PlotAreas.Add(plotArea); fpSpread1.ActiveSheet.Charts[0].Model = model; } 复制代码运行效果截图:
(10.8 K, 下载次数:6)