你能告诉我我的代码有什么问题吗?我想通过System.Windows.Forms.DataVisualization.Charting库在控制台应用程序中生成图表图像...下面的代码只生成带有列的图表,但我需要带有轴的图表。有任何想法吗?
Chart chart = new Chart();
chart.Size = new System.Drawing.Size(2000, 500);
ChartArea area = new ChartArea();
chart.ChartAreas.Add(area);
chart.BackColor = System.Drawing.Color.Transparent;
chart.ChartAreas[0].AxisX.MajorGrid.Enabled = false;
chart.ChartAreas[0].AxisY.MajorGrid.Enabled = false;
chart.ChartAreas[0].AxisX.Title = "sasdasdasd";
Series series = new Series()
{
Name = "series2",
IsVisibleInLegend = false,
ChartType = SeriesChartType.Column
};
chart.Series.Add(series);
foreach (CnbItem item in items)
{
DataPoint p1 = new DataPoint(0, Double.Parse(item.Kurz));
p1.Color = System.Drawing.Color.LightBlue;
p1.AxisLabel = item.Kod;
p1.LegendText = item.Kod;
p1.Label = item.Kurz;
series.Points.Add(p1);
}
string filename = "D:\\Chart.png";
chart.SaveImage(filename, ChartImageFormat.Png);