日期:2014-05-18  浏览次数:21234 次

c#mschart (winform) 求救 在线等
我做了一个曲线图,数据来源于数据库,
  这张表中有两个series(也有两条线),数据来源于不同的两张表(node_002_temperature与node_003_temperature),但X轴均为时间
当其中一个series已经存在于chart中时,再添加另一个series时会提示;
  “如果索引序列(XValueIndexed = true)不对齐,则无法在同一个轴上显示它们。序列“node_002_temperature”和序列“node_003_temperature”必须对齐才能执行此操作。当前这些序列的数据点的数量不同。”
这是因为两张表上的时间不同导致的吧,该怎样解决?附上部分代码:
C# code
mytype = checkedListBox1.SelectedItem.ToString();
                SeriesMethod(ref mytype);//因为是动态生成,所以我把对series相关的配置写成了方法
                _commandstr = "SELECT time, voltage FROM" + " dbo." + checkedListBox1.SelectedItem.ToString() + " ORDER BY time";
                _sqlcommand = new SqlCommand(_commandstr, _AddDase.Getcon());
                SqlDataReader sdr = _sqlcommand.ExecuteReader(CommandBehavior.CloseConnection);
                chart1.Series[checkedListBox1.SelectedItem.ToString()].Points.DataBindXY(sdr, "time", sdr, "voltage");
                chart1.ChartAreas["ChartArea1"].AxisY.Enabled = AxisEnabled.False;
                chart1.Series[checkedListBox1.SelectedItem.ToString()].YAxisType = AxisType.Secondary;
                chart1.Series[checkedListBox1.SelectedItem.ToString()].XAxisType = AxisType.Primary;
                chart1.Series[checkedListBox1.SelectedItem.ToString()].IsXValueIndexed = false;
                sdr.Close();
                _AddDase.closedatabase();



------解决方案--------------------
http://www.cnblogs.com/yangpeng0928/archive/2012/05/31/2528663.html

你参考下 这个看看吧,我之前做的,也是用MSchart。