我正在尝试在单击的DataPoint和Y轴之间画一条线。我正在添加一个用于绘制线条的新系列。我的X轴包含日期。问题是当我将系列添加到图表时,x轴变为空白。
我没有通过代码更新X轴。我试图评论RecalculateAxesScale(),但没有用。
这是我的代码:
longTermSeries = new Series("Long Term");
ChartArea area = chart.ChartAreas["draw"];
area.RecalculateAxesScale();
area.AxisX.Minimum = chart.ChartAreas["draw"].AxisX.Minimum;
area.AxisX.Maximum = chart.ChartAreas["draw"].AxisX.Maximum;
area.AxisY.Minimum = chart.ChartAreas["draw"].AxisY.Minimum;
area.AxisY.Maximum = chart.ChartAreas["draw"].AxisY.Maximum;
chart.Series.Add(longTermSeries);
longTermSeries.ChartType = SeriesChartType.Line;
longTermSeries.Color = Color.Blue;
longTermSeries.Points.Add(selectedDataPoint);
longTermSeries.Points.Add(new DataPoint(area.AxisX.Maximum, selectedDataPoint.YValues[0]));