来自sql的日期显示错误n行图表 [英] dates from sql showing wrongly n Lines Chart

查看:55
本文介绍了来自sql的日期显示错误n行图表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚开始使用  MS图表并且正在玩它。


我连接到sql,它使用折线图绘制数据并使用线图 - 使用c#


<那部分工作得很好。问题是图表上的日期与sql中的日期不匹配。


请参阅sql和下图中的数据。


I我不确定我做错了什么。任何帮助将不胜感激。   谢谢
























































































































































































































































Date 项目值
7/25/2012   129,841 
7/18/2012   131,422 
7/11/2012   131,867 
7/4/2012   131,867 
6/27/2012   131,678 
6/20/2012   126,655 
6/13/2012   127,844 
6/6/2012   127,844 
5/30/2012   127,844 
5/23/2012   127,246 
5/16/2012   125,643 
5/9/2012   126,134 
5/2/2012   126,134 
4/25/2012   126,019 
4/18/2012   124,435 
4/11/2012   124,668 
4/4/2012   124,668 
3/28/2012   124,067 
3/21/2012   128,761 
3/14/2012   129,170 
3/7/2012   129,170 
2/29/2012   129,170 
2/22/2012   127,247 
2/15/2012   136,595 
2/8/2012   138,446 
2/1/2012   138,446 
1/25/2012   137,147 
1/18/2012   138,371 
1/11/2012   139,005 
1/4/2012   139,005 
12/28/2011   138,818 
12/21/2011   137,517 
12/14/2011   135,424 
12/7/2011   135,424 
11/30/2011   135,424 
11/23/2011   136,588 
11/16/2011   139,480 
11/9/2011   140,352 
11/2/2011   139,290 
10/26/2011   140,028 
10/19/2011   141,662 
10/12/2011   137,544 
10/5/2011   137,544 
9/28/2011   136,906 
9/21/2011   133,080 
9/14/2011   134,305 
9/7/2011   134,305 
8/31/2011   134,305 
8/24/2011   132,599 
2011年8月17日   128,244 
8/10/2011   128,877 
8/3/2011   128,877 
2011年7月27日   128,569 
2011年7月20日   124,132 
2011年7月13日   123,986 
7/6/2011   123,985 
6/29/2011   122,834 




解决方案

问题是图表上的日期与sql中的日期不匹配。

图表控件不会显示默认情况下,x轴上的每个x值。它将根据数据计算一些合适的间隔。
(在这种情况下,它似乎是一个月。)您只有大约60个数据积分,考虑拥有10000点。每个标签都不适合图表。


您可以使用
Axis.Interval
属性(以及
Axis.IntervalType
。)


或者,如果您特别需要每个数据值有自己的网格线和标签,你可以设置

Series.IsXValueIndexed
为true,在这种情况下,x轴将被视为类别轴,x值不会影响数据点之间的距离。
(在这种情况下,您可能必须将AxisX.Interval设置为1以显示每个轴标签。)


I just started using  MS chart and is playing around with it.

I connected to sql that is pulling data and plotting it using Line Chart- using c#

That part work great. The issue is that dates on the Chart do not match the dates from the sql.

Please see data from sql and the chart below.

I am not sure what I am doing wrong. Any help will be appreciated.  Thanks

Date Item Value
7/25/2012  129,841 
7/18/2012  131,422 
7/11/2012  131,867 
7/4/2012  131,867 
6/27/2012  131,678 
6/20/2012  126,655 
6/13/2012  127,844 
6/6/2012  127,844 
5/30/2012  127,844 
5/23/2012  127,246 
5/16/2012  125,643 
5/9/2012  126,134 
5/2/2012  126,134 
4/25/2012  126,019 
4/18/2012  124,435 
4/11/2012  124,668 
4/4/2012  124,668 
3/28/2012  124,067 
3/21/2012  128,761 
3/14/2012  129,170 
3/7/2012  129,170 
2/29/2012  129,170 
2/22/2012  127,247 
2/15/2012  136,595 
2/8/2012  138,446 
2/1/2012  138,446 
1/25/2012  137,147 
1/18/2012  138,371 
1/11/2012  139,005 
1/4/2012  139,005 
12/28/2011  138,818 
12/21/2011  137,517 
12/14/2011  135,424 
12/7/2011  135,424 
11/30/2011  135,424 
11/23/2011  136,588 
11/16/2011  139,480 
11/9/2011  140,352 
11/2/2011  139,290 
10/26/2011  140,028 
10/19/2011  141,662 
10/12/2011  137,544 
10/5/2011  137,544 
9/28/2011  136,906 
9/21/2011  133,080 
9/14/2011  134,305 
9/7/2011  134,305 
8/31/2011  134,305 
8/24/2011  132,599 
8/17/2011  128,244 
8/10/2011  128,877 
8/3/2011  128,877 
7/27/2011  128,569 
7/20/2011  124,132 
7/13/2011  123,986 
7/6/2011  123,985 
6/29/2011  122,834 



解决方案

The issue is that dates on the Chart do not match the dates from the sql.

The chart control won't show every x value on the x axis by default. It will calculate some suitable interval based on the data. (In this case it seems to be a month.) You only have around 60 data points, consider having, say, 10000 points. There is no way every label would fit on the chart.

You can change the interval to whatever you want with the Axis.Interval property (and Axis.IntervalType.)

Or, if you specifically want every data value to have their own grid line and label, you can set the Series.IsXValueIndexed to true, in which case the x axis will be treated as a category axis and the x value won't affect the distance between data points. (You may have to set AxisX.Interval to 1 to show every axis label in this case.)


这篇关于来自sql的日期显示错误n行图表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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