实时图表Windows窗体,按月添加和移动点

时间:2019-09-25 07:44:43

标签: livecharts

我希望该值准确显示在从我的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;
    }
  

问题出在哪里?

0 个答案:

没有答案