我正在使用Visual Studio 2015,C#,WinForms。爲什麼圖表不顯示附加點?
我剛添加從工具箱和改變的類型,以線正常圖表,然後加入以下代碼:
chart1.ChartAreas[0].AxisX.LabelStyle.Format = "HH";
chart1.ChartAreas[0].AxisX.Interval = 1;
chart1.ChartAreas[0].AxisX.IntervalType = DateTimeIntervalType.Hours;
chart1.ChartAreas[0].AxisX.IntervalOffset = 0;
chart1.ChartAreas[0].AxisX.IsMarksNextToAxis = true;
chart1.ChartAreas[0].AxisX.IsStartedFromZero = true;
DateTime minDate = DateTime.Today;
DateTime maxDate = minDate.AddHours(23);
chart1.ChartAreas[0].AxisX.Minimum = minDate.ToOADate();
chart1.ChartAreas[0].AxisX.Maximum = maxDate.ToOADate();
chart1.Series[0].BorderWidth = 2;
for (int i = 0; i < 24; i++)
{
chart1.Series[0].Points.AddY(i);
}
輸出:
爲什麼圖表未示出點數已添加?
它們可能超出了AxisX.Minimum和AxisX.Maximum的極限。在調試器中查看參與變量的值。你會看到雙。這應該清除問題.. – TaW