【发布时间】:2021-09-04 12:38:06
【问题描述】:
如何同时使用 List 和 DataPointCollection.DataBindY 绘制股票图表?
我知道如何在图表上添加股票数据,但我不想通过 Add 循环和重复绘制,因为实际列表要长得多。
为了一次绘制图表,我尝试了 DataPointCollection.DataBindY,但它不起作用。它需要 IEnumerable[] 但我不知道如何将 List 更改为 IEnumerable[]。
public partial class Form1 : Form
{
double[] Candle;
List<double[]> CandleList = new List<double[]>();
public Form1()
{
InitializeComponent();
Candle = new double[] { 5, 0, 3, 1 };
CandleList.Add(Candle);
Candle = new double[] { 10, 5, 7, 9 };
CandleList.Add(Candle);
}
private void button1_Click(object sender, EventArgs e)
{
for (int i = 0; i < CandleList.Count; i++)
{
chart1.Series[0].Points.Add(CandleList[i]); // works well
}
}
private void button2_Click(object sender, EventArgs e)
{
chart1.Series[0].Points.DataBindY(CandleList); // System.ArgumentException
}
}
【问题讨论】:
标签: c# charts candlestick-chart