0
我試圖在另一窗口窗體中打開圖表,但用於圖表中數據的類是第一種形式。我的目標是讓圖表能夠在無模式的窗口中多次打開。如何將一個圖表分配給另一個C#
在Form1.cs我建立我的圖表:
Chart chart = new Chart();
Series price = new Series("Price"); //create new series
chart.Series.Add(price);
chart.Series["Price"].ChartType = SeriesChartType.Candlestick;
chart.Series["Price"]["OpenCloseStyle"] = "Candlestick";
chart.Series["Price"]["ShowOpenClose"] = "Both";
chart.Series["Price"]["PriceUpColor"] = "Green"; //Price increase = green
chart.Series["Price"]["PriceDownColor"] = "red"; //price decrease = red
for (int i = 0; i < data.Count; i++)
{
chart.Series["Price"].Points.AddXY(data[i].getDate(), data[i].getHigh()); //Adds date and high value
chart.Series["Price"].Points[i].YValues[1] = System.Convert.ToDouble(data[i].getLow()); //Low value added to chart
chart.Series["Price"].Points[i].YValues[2] = System.Convert.ToDouble(data[i].getOpen()); //open value added to chart
chart.Series["Price"].Points[i].YValues[3] = System.Convert.ToDouble(data[i].getClose()); //close value added to chart
}
Form2.cs:
public void DisplayChart(Chart newChart)
{
chart1 = newChart;
chart1.Show();
}
每個窗口有相同的數據?或使用相同圖表設置的不同數據。 – 2015-03-30 23:35:42
相同的數據。希望同樣的設置,如果我也有,我可以改變那些。 – user3376703 2015-03-30 23:38:45
在你的數據變量中使用什麼樣的上下文? – Aizen 2015-03-31 00:02:32