From a3390f0576757b6c98232a444d58b37899a909d4 Mon Sep 17 00:00:00 2001 From: the Date: Tue, 25 Jun 2024 18:43:20 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A4=D0=90=D0=9A=20=D0=95=20=D0=9E=D0=9D?= =?UTF-8?q?=D0=9E=20=D0=A0=D0=90=D0=91=D0=9E=D0=A2=D0=90=D0=95=D0=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- WinFormsApp/FormStatistics.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/WinFormsApp/FormStatistics.cs b/WinFormsApp/FormStatistics.cs index 9622e5f..fa93cbe 100644 --- a/WinFormsApp/FormStatistics.cs +++ b/WinFormsApp/FormStatistics.cs @@ -11,6 +11,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; +using System.Windows.Forms.DataVisualization.Charting; namespace WinFormsApp { @@ -38,15 +39,15 @@ namespace WinFormsApp }); var date = dateTimePickerTo.Value; chart.Series.Add("Completed"); + chart.Series["Completed"].XValueType = System.Windows.Forms.DataVisualization.Charting.ChartValueType.String; for (int i = 0; i < diff_month(dateTimePickerFrom.Value, dateTimePickerTo.Value); i++) { var count = list.Where(x => x.Date.Month == date.Month).ToList().Count; - foreach (var x in list) - { - Debug.WriteLine(x.Date.Month); - Debug.WriteLine(date.Month); - } - chart.Series["Completed"].Points.AddXY(date.Month, count); + DataPoint dataPoint = new DataPoint(); + dataPoint.XValue = i; + dataPoint.Label = $"{date.Year}.{date.Month}"; + dataPoint.SetValueY(count); + chart.Series["Completed"].Points.Add(dataPoint); date = date.AddMonths(1); } }