Winform图表控件不创建正确的折线图 [英] Winform Chart Control not creating proper line chart

查看:1552
本文介绍了Winform图表控件不创建正确的折线图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Winform图表控件创建折线图时遇到错误。 (我使用VS2013)

I've encountered an error while creating line charts with the Winform chart control. (I'm using VS2013)

我绘制一个折线图,它产生一个单一的实线连接第一个和最后一点的奇怪的视觉效果,正确的点。

I'm plotting a line chart and it produces the strange visual effect of a single solid line connecting the first and last points in addition to the correct points.

我不想直线。当我绘制在Excel中,我得到正确的图,所以我知道数据系列是好的。

I don't want the straight line. When I plot this in Excel, I get the correct graph so I know the data series is good.

我与许多系列设置,但不能得到直线消失。这可以固定吗?

I've tinkered with many of the series settings but cannot get the straight line to go away. Can this be fixed?

我的产生系列的代码如下。感谢您的协助。

My code that produces the series is below. Thank you for helping.

private void numericUpDown1_ValueChanged(object sender, EventArgs e)
    {
        foreach (var series in chart1.Series)
        {
            series.Points.Clear();
        }

        string chartValues = "SELECT statDay, itemCount, [60DayMAVG] FROM tbl_MAVG_dev WHERE streamID = " + numericUpDown1.Value;
        SqlConnection getStreamData = new SqlConnection("Data Source=SQLSERVER;Initial Catalog=MyOwnSQLBox;Integrated Security=True");
        SqlCommand getValuesCMD = new SqlCommand(chartValues, getStreamData);

        try
        {
            getStreamData.Open();
            SqlDataReader getValuesReader = getValuesCMD.ExecuteReader();
            while (getValuesReader.Read())
            {
                //chart1.Series["itemCount"].Points.AddXY(Convert.ToDateTime(getValuesReader.GetDateTime(0)), Convert.ToInt32(getValuesReader.GetInt64(1)));
                chart1.Series["mavg"].Points.AddXY(Convert.ToDateTime(getValuesReader.GetDateTime(0)), Convert.ToInt32(getValuesReader.GetDouble(2)));
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }


推荐答案

的结束点是过期的订单和/或您有一个重复的结束点。

One of your end points is out of date order and/or you have a duplicate of one of the end points.

这篇关于Winform图表控件不创建正确的折线图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆