积极答复者
大家快看看,太奇怪了

问题
-
是关于mschart的。
1、在vb.net里新建一个项目(我用的是2008)
2、粘贴以下代码,然后运行,你会=发现,数据点位置不正确
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Chart1.ChartAreas(0).AxisX.Maximum = 5
Chart1.ChartAreas(0).AxisX.Minimum = -5
Chart1.ChartAreas(0).AxisY.Maximum = 5
Chart1.ChartAreas(0).AxisY.Minimum = -5
Chart1.ChartAreas(0).AxisX.MajorGrid.Interval = 1
Chart1.ChartAreas(0).AxisY.MajorGrid.Interval = 1
Chart1.Series(0).ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line
Chart1.Series(0).MarkerStyle = System.Windows.Forms.DataVisualization.Charting.MarkerStyle.Circle
Chart1.Series(0).IsValueShownAsLabel = True
Chart1.Series(0).Points.Clear()
Chart1.Series(0).Points.AddXY(0, 0)
Chart1.Series(0).Points.AddXY(0, 1)
Chart1.Series(0).Points.AddXY(0, 2)
End Sub
答案
-
你好
嘗試了... 你說得對..這可能是Chart Control 的Bug,我在VS2010 嘗試都有同樣問題
我已經向Microsoft Connect 發了個Bug Report 待他們去確定一下這是不是Bug 吧
詳情可以參考這個URL 有關這個Bug reportPlease correct me if my concept is wrong
Chi- 已标记为答案 BoberSongModerator 2010年9月6日 7:27
-
你好
你是用那一個 版本的我是用VS2010 PREMIUM 的
而這個Chart 控件不是叫MSChart 的, 只是叫 Chart可以在工具中的 Data Section 找到 Chart Control
http://i51.tinypic.com/ixe0eh.jpg
如果都是找不到的話可以嘗試
在"工具列"按右鍵 ->"Choose Item [選擇物件]" -> 之後你便可以看到以下的 Dialog box之後只要選擇Chart [System.Windows.Forms.DataVisualization.Charting]
http://i53.tinypic.com/15rbptd.jpg之後按確定便可
Please correct me if my concept is wrong
Chi- 已标记为答案 BoberSongModerator 2010年9月6日 7:27
全部回复
-
你好
嘗試了... 你說得對..這可能是Chart Control 的Bug,我在VS2010 嘗試都有同樣問題
我已經向Microsoft Connect 發了個Bug Report 待他們去確定一下這是不是Bug 吧
詳情可以參考這個URL 有關這個Bug reportPlease correct me if my concept is wrong
Chi- 已标记为答案 BoberSongModerator 2010年9月6日 7:27
-
感谢Chi,我试了vb6的chart没有这个问题。希望microsoft能有一个解释,我现在急需要解决这个问题,因为我正在做一个数据采集的程序,刚开始的数据都是0,显示不正确,急死我了。
再者,我刚安装了vs2010,可在工具栏里找不到mschart控件,不过升级原2008的项目,窗口里mschart控件可以显示,且也能正常运行。怎么才能把mschart控件,像vs2008一样出现在左侧的工具栏里。
另外,vs2008里的mschart是netframe3.5的,现在vs2010是netframe4.0,是否有mschart for netframe4.0的?
-
你好
你是用那一個 版本的我是用VS2010 PREMIUM 的
而這個Chart 控件不是叫MSChart 的, 只是叫 Chart可以在工具中的 Data Section 找到 Chart Control
http://i51.tinypic.com/ixe0eh.jpg
如果都是找不到的話可以嘗試
在"工具列"按右鍵 ->"Choose Item [選擇物件]" -> 之後你便可以看到以下的 Dialog box之後只要選擇Chart [System.Windows.Forms.DataVisualization.Charting]
http://i53.tinypic.com/15rbptd.jpg之後按確定便可
Please correct me if my concept is wrong
Chi- 已标记为答案 BoberSongModerator 2010年9月6日 7:27
-
谢谢Chi,通过仔细查看Chart的技术文件,知道了为什么会出现这样的问题。chart有两种显示方式,要么是散点图(scatter),要么不是。如果点的数据不包含x值,则就认为不是散点图,如果包含x值,但第一个点的x值为0(原文不是这样说的,经试验我发现是这样的),则也不认为是散点图。
原文如下:All chart types can be displayed as either scatter plots or as non-scatter plots, because both X-values and Y-values can be set. Setting an X-value will result in a scatter plot, whereas not setting this property—which is equivalent to setting it to zero—will result in a non-scatter plot. For example, to draw a point chart type, add data points that have X-values of zero. To display a traditional scatter chart, add data points that have X-values other than zero.
于是我就把第一个点的数据进行判断,如果x值是0,则付给x值0.000001,这在图上看不出来,显示就正确了。
可我不想这样,想让chart的类型就是scatter的,可怎么也找不到方法用以设置。