Живые диаграммы Windows Forms, добавление и перемещение точки по месяцам - PullRequest
0 голосов
/ 25 сентября 2019

Я хочу, чтобы значение отображалось точно в том месяце, когда оно было помечено в моей базе данных сервера ms sql.

Посмотрите на вас на картинке.

enter image description here

    cn.Open();
    cmd = new SqlCommand("Select * from rpt_KUNDE_Usatz_Gesamt Where Jahre='" + button.Text + "'", cn);
    dr = cmd.ExecuteReader();
    while (dr.Read()) {
        Values2019.Add(Convert.ToDouble(dr["SumOfMonat"]));
        MonthValue.Add(Convert.ToDouble(dr["Monat"]));
    }

    SeriesCollection s2019 = new SeriesCollection {
        new LineSeries {
            Title = DateTime.Now.AddYears(0).Year.ToString(), 
            Values = new ChartValues<double>(Values2019),
            StrokeThickness = 2,
            Stroke = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb( 243, 67, 54)),
            Fill = System.Windows.Media.Brushes.Transparent,
            LineSmoothness = 0,
            PointGeometrySize = 13,
            PointForeground = new System.Windows.Media.SolidColorBrush(System.Windows.Media.Color.FromRgb(34, 46, 49)),
            StrokeDashArray = new System.Windows.Media.DoubleCollection(20),
            DataLabels = true,
            Foreground = Brushes.White   
        }
    };

    Labels = new[] { Month() };
    Formatter = MonthValue => MonthValue.ToString("N");

    cartesianChart1.Series = s2019;
    cn.Close();


    private string Month() {
        DateTime now = DateTime.Now;
        string month = DateTime.Now.ToString("MMMM");
        return month;
    }

В чем проблема?

...