点系列错误地将XValue置于1而不是0 [英] Point series incorrectly placing XValue at 1 instead of 0

查看:60
本文介绍了点系列错误地将XValue置于1而不是0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果您有一个单独的点并且XValue为0,那么在Visual Studios中我注意到(我使用的是2012)图表控件没有正确地将数据点放在图表上吗? br />


示例代码:



Has anyone else noticed in Visual Studios's (I'm using 2012) chart control doesn't place the data point correctly on the chart if you have a single point and the XValue is 0, it places it at 1 instead?

example code:

Chart1.Series.Clear();
Chart1.Series.Add(new Series());
Chart1.Series[0].ChartType = SeriesChartType.Point;

Chart1.Series[0].Points.AddXY(0,0);





如果你跑该代码将数据点放在(1,0)。一旦添加第二个点,它将正确地绘制点(0,0)处的点。如果相反,数据点是在XValue = 0.001处添加的,而不是XValue = 0,它也会正确绘制图形。



还有其他人看过这个吗?是否有解决此问题的方法?



If you run that code it will place a data point at (1,0). As soon as a second point is added, it will correctly graph the point at (0,0). If instead the data point was added at XValue = 0.001, instead of XValue=0, it would graph correctly as well.

Has anyone else seen this? Is there a solution to this problem?

推荐答案

这取决于.NET版本(请更新标记以供参考)。在.NET 4.5中,您在系列上有一个属性IsXAxisQuantitative,您可以设置为'true'以防止此行为:

This depends on the .NET version (please update the tag for reference). In .NET 4.5, you have a property IsXAxisQuantitative on the Series that you can set to 'true' to prevent this behavior:
Chart1.Series[0]["IsXAxisQuantitive"] = true;






or

Chart1.Series[0].CustomProperties = "IsXAxisQuantitative=True";



在旧版本的.NET中,您可以在x!= 0处添加一个透明的虚拟点:


In older versions of .NET, you could add a transparant dummy point at x != 0:

DataPoint dummyPoint = new DataPoint(1, 0);
dummyPoint.Color = Color.Transparent;
Chart1.Series[0].Points.Add(dummyPoint);


这篇关于点系列错误地将XValue置于1而不是0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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