MS Chart Control: two X-axis, one for hours, the other for several days (or mixing both)

Is it possible to have a clock displaying the X axis (HH: MM)
and other (or the same) display of days (YYYY-MM-DD)
at different intervals to make it look like


| | | | | 

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


  | 2010/04/20 


Or ideally:


  | | | | | 

09: 00 10: 00 11: 00; 1:00


Discussion topic
The more I use MS Chart Control, the more I regret my decision to switch from ZedGraph. I really got angry and disappointed. I lost a lot of time on meaningless details like these, and walked around very ugly workarounds (for example, creating a lot of repeating "ghost" charts to "process" various scaled series, "What is Heck !!?", Data alignment MANUALLY adding empty points, because the case of using the default code is extremely inflexible). At first glance, this seems very fantastic, but from the moment you want to set up and do serious things, and not show an ultra basic pie chart or bar histogram, you enter the World of Hell . Therefore, I basically advise NOT to use it if you are not already stuck with it (but it's never too late to reconsider switching to something that is not so inconvenient and takes a lot of time)

EDIT: I could use Keywords, as recommended here . It seems very scared and tiring, though ... Also, it breaks the separation between Logic and Presentation (this should never happen! Sign of Poor Design ...)

For another example of such annoying similar (incomprehensible) problems see this post

+6
c # mschart
source share
1 answer

You can use one X axis, and you can set the β€œ12:00” labels to display the β€œdate”. See CustomLabel and CustomLabelsCollection in the System.Windows.Forms.DataVisualization.Charting namespace. You can use the free ILSpy to see what's inside the MSChart DLL.

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

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

Basically, it looks something like this:

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

Hope this helps.

+1
source share

All Articles