MS图表控件:两个X轴,一个小时,另一个天(或混合使用) [英] MS Chart Control :Two X Axis, one for hours, another for days (or mixing both)

查看:85
本文介绍了MS图表控件:两个X轴,一个小时,另一个天(或混合使用)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以显示X轴小时(HH:MM)
和另一个(或相同)显示天数(YYYY-MM-DD)
在不同的时间间隔,因此它看起来像

Is is possible to have an X Axis display hours (HH:MM)
and another (or the same) displaying Days (YYYY-MM-DD)
at different intervals so it look like

 |               |               |               |               |

09:00            &bb 10:00 11:00              b                b ; 01:00

09:00                      10:00                     11:00                          12:00                       01:00

                                                  |            
                                              2010/04/20         


或者理想情况下:


Or Ideally :

 |               |               |               |               |

09:00            &b 10:00                   11:00                    2010/04/20  &NBSP ;              01:00

09:00                     10:00                         11:00                   2010/04/20                   01:00


主题外咨询
我使用MS Chart Control的次数越多,我对从ZedGraph切换决定的遗憾就越多. 我真的很生气和沮丧,因为我在这些毫无意义的细节上花了很长时间,并且通过非常丑陋的解决方法进行规避(例如创建许多重复的幽灵"图表以处理"不同比例的系列-哎呀!!-,对齐数据手动添加空点,因为默认的代码用例非常不灵活).乍一看似乎很花哨,但是从您想要进行调整和做严肃的事情开始,而不是显示超基本的饼形图或条形图直方图的那一刻起,您便进入了地狱世界.因此,我基本上建议不要使用它,除非您已经坚持使用它了(但是重新考虑迁移到不那么花哨和费时的东西上永远不会太晚)


Off Topic Advice
The more I use MS Chart Control the more I regret my decision switching from ZedGraph. I am really getting angry and frustrated I've lost long hours on meaningless details like these and circumventing through very ugly workarounds (like creating many duplicate "ghost" charts to "handle" different scaled series , -What the Heck!!?-, aligning data MANUALLY adding empty points because the default code use case is extremely unflexible). It seems very fancy at first glance, but from the moment you want to tweak and do serious stuff rather than displaying an ultra basic pie chart or bar histogram you enter a World of Hell. So I basically advice NOT to use it, unless you are already stuck with it (but it's never too late to reconsider moving to something that isn't that wonky and time-consuming)

我可以按照此处的建议使用关键字".虽然看起来很时髦又乏味...
此外,这违反了逻辑与表示
之间的分隔(这永远都不会发生!设计不佳的迹象...)

EDIT : I could use "Keywords" as adviced here. Seems very funky and tedious though...
Besides, this violates the separation between Logic and Presentation
(this should never happen! Sign of Poor Design...)

有关此类烦人的类似(无提示)问题的另一个示例,请参见发布

For another example of such annoying similar (clueless) issues see this post

推荐答案

您可以使用单个X轴,并且可以自定义"12:00"标签以显示日期". 请参见命名空间System.Windows.Forms.DataVisualization.Charting中的CustomLabel和CustomLabelsCollection.您可以使用免费软件ILSpy来查看MSChart dll中的内容.

You can use a single X axis, and you can customize the "12:00" labels to display the "date". See CustomLabel and CustomLabelsCollection in namespace System.Windows.Forms.DataVisualization.Charting. You could use the freeware ILSpy to see what's inside MSChart dll.

CustomLabel有多个构造函数,我使用了这个构造函数:

There are several constructors for CustomLabel, I used this one:

public CustomLabel(double fromPosition, double toPosition, string text, int labelRow, LabelMarkStyle markStyle, GridTickTypes gridTick)

基本上,它是这样的:

CustomLabel label1 = new CustomLabel(...);
mychart.ChartAreas[0].AxisX.CustomLabels.Add(label1);

希望这会有所帮助.

这篇关于MS图表控件:两个X轴,一个小时,另一个天(或混合使用)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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