C#Winchart配置,添加更多行

时间:2014-07-27 20:56:43

标签: c#

我的C#图表遇到了一些问题。

我想创建一个奖金图表。

此图表是我要创建的内容: Winning graph

我目前有这个: My graph

WinChart.ChartAreas[0].AxisY.Title = "$ USD";
WinChart.ChartAreas[0].AxisY.Minimum = -1;
WinChart.ChartAreas[0].AxisY.Maximum = 1;
WinChart.ChartAreas[0].AxisX.Title = "Tourneys";
WinChart.ChartAreas[0].AxisX.Minimum = 0;
WinChart.ChartAreas[0].AxisX.IsStartedFromZero = true;
WinChart.Series[0].Points.Add(0);
WinChart.Series[0].Points.Add(0.10);
WinChart.Series[0].Points.Add(0.20);
WinChart.Series[0].Points.Add(0.30);
WinChart.Series[0].Points.Add(-0.50);
WinChart.Series[0].Points.Add(-0.60);
WinChart.Series[0].Points.Add(-0.70);

如何从坐标0,0开始,如何制作$ 0的中间线?

文档链接:http://msdn.microsoft.com/en-us/library/system.windows.forms.datavisualization.charting.aspx

1 个答案:

答案 0 :(得分:2)

我会假设一些事情。 WinChart可能继承自Chart:

public class WinChart : Chart { }

并且ChartAreas是ChartAreaCollection对象,与Series

相同

所以我会这样做:

WinChart.ChartAreas[0].AxisY.Title = "$ USD";
WinChart.ChartAreas[0].AxisY.Minimum = -1;
WinChart.ChartAreas[0].AxisY.Maximum = 1;
WinChart.ChartAreas[0].AxisY.Interval = 0.2;   // adjusts y axis scale
WinChart.ChartAreas[0].AxisX.Title = "Tourneys";
WinChart.ChartAreas[0].AxisX.Minimum = 0;

Series series = new Series();
series.Points.Add(0,0);
...
series.Points.Add(5, 1.05);
WinChart.Series.Add(series);
//repeat last five lines to add second line to graph