如何使用 MigraDoc 创建饼图
How to create a Pie Chart with MigraDoc
我不断收到此错误:
ChartType 'Pie2D' not valid for combination of charts.
但是找不到合适的examples/documentation。
这是一个适用于 MigraDoc 1.50 的示例:
/// <summary>
/// Defines the charts page.
/// </summary>
public static void DefineCharts(Document document)
{
var paragraph = document.LastSection.AddParagraph("Chart Overview", "Heading1");
paragraph.AddBookmark("Charts");
document.LastSection.AddParagraph("Sample Chart", "Heading2");
Chart chart = new Chart(ChartType.Pie2D);
chart.Width = Unit.FromCentimeter(16);
chart.Height = Unit.FromCentimeter(12);
Series series = chart.SeriesCollection.AddSeries();
series.Add(new double[] { 1, 5, 11, -3, 20 });
XSeries xseries = chart.XValues.AddXSeries();
xseries.Add("Production", "Lab", "Licenses", "Taxes", "Insurances");
//chart.Legend.Docking = DockingType.Right;
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
document.LastSection.Add(chart);
}
我不断收到此错误:
ChartType 'Pie2D' not valid for combination of charts.
但是找不到合适的examples/documentation。
这是一个适用于 MigraDoc 1.50 的示例:
/// <summary>
/// Defines the charts page.
/// </summary>
public static void DefineCharts(Document document)
{
var paragraph = document.LastSection.AddParagraph("Chart Overview", "Heading1");
paragraph.AddBookmark("Charts");
document.LastSection.AddParagraph("Sample Chart", "Heading2");
Chart chart = new Chart(ChartType.Pie2D);
chart.Width = Unit.FromCentimeter(16);
chart.Height = Unit.FromCentimeter(12);
Series series = chart.SeriesCollection.AddSeries();
series.Add(new double[] { 1, 5, 11, -3, 20 });
XSeries xseries = chart.XValues.AddXSeries();
xseries.Add("Production", "Lab", "Licenses", "Taxes", "Insurances");
//chart.Legend.Docking = DockingType.Right;
chart.DataLabel.Type = DataLabelType.Percent;
chart.DataLabel.Position = DataLabelPosition.OutsideEnd;
document.LastSection.Add(chart);
}