如果改为你给推荐的AddChart方法
- fpSpread_Table.Sheets[0].Charts.Clear();
- string colors = "#ffbb22,#ff9911,#aacc33,#aabbbb,#bb0033,#00cc33,#990099,#0011aa,#14D0EE,#B17EC3,#E67F16,#EE5907,#6A2DA1,#0A35F0,#A816D7,#D218AD,#EE0A96,#5A4DAE,#ACE9D9";
- //获得图标数据源
- PieSeries pseries_People = new PieSeries();
- int iCount = 0;
- for (int i = 0; i < fpSpread_Table.Sheets[0].RowCount - 1; i++)
- {
- if (fpSpread_Table.Sheets[0].Cells[i, 1].Text != "")
- {
- pseries_People.Values.Add(Convert.ToDouble(fpSpread_Table.Sheets[0].Cells[i, 1].Text) / Convert.ToDouble(fpSpread_Table.Sheets[0].Cells[fpSpread_Table.Sheets[0].RowCount - 1, 1].Text));
- if (fpSpread_Table.Sheets[0].Cells[i, 0].Text != "")
- {
- pseries_People.CategoryNames.Add(fpSpread_Table.Sheets[0].Cells[i, 0].Text + " : " + fpSpread_Table.Sheets[0].Cells[i, 1].Text);
- }
- iCount++;
- }
- }
- if (iCount <= 0) return; //当收集数据源为空时,退出
- //设置显示图例样式
- pseries_People.LabelVisible = true;
- //pseries.LabelContainsCategoryName = true;
- pseries_People.LabelFormatter = new FarPoint.Win.Spread.Model.GeneralFormatter("0.00%", false);
- //将收集数据源,进行绑定
- FillCollection fc_People = pseries_People.PieFills;
- List<SolidFill> list_People = new List<SolidFill>();
- foreach (string color in colors.Split(new char[] { ',' }))
- {
- list_People.Add(new SolidFill(ColorTranslator.FromHtml(color)));
- }
- fc_People.Clear();
- fc_People.AddRange(list_People.ToArray());
复制代码
这块设置绑定数据源,百分比显示设置,不同数据源的颜色设置和图例文字设置,不知如何处理,求指教 |