简体   繁体   中英

How to display start and end points x-axis label in a chart in c# windows forms?

I am just a rookie at C# windows forms application. I am trying to plot a chart from a data.table using the function this.chart1.Series[0].Points.DataBindXY(dt.DefaultView, "tms", dt.DefaultView, head[1]); where dt is the data.table, tms is timestamp column and head[1] is a data column. But I am not able to see the start and end x-axis label in chart. Check out my output here. ie I want to see the timestamp of start and end of the data. So how do I do it? Is there any predefined function?

Thanks for helping...

There is no predefined function, but

1) if your data is in some 'good' time interval, ie from 2020.05.01 0:00 to 2020.05.02 03:00, you can tune AxisX.Minimum and AxisX.Interval properties.

2) if your data is not in 'good' time interval you should use CustomLabels . It is not so easy because your CustomLabels override all normal labels.

3) if it is only necessary to show the first and the last values, and it is not important where - use RectangleAnnotation - text that can be placed on chart.

The easiest way for any data type is to set the IsMarginVisible property of the X axis to false: chartArea1.AxisX.IsMarginVisible = false; or Property Box

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM