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

1.5k views Asked by At

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. i.e. 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...

2

There are 2 answers

3
capsSadSack On BEST ANSWER

There is no predefined function, but

1) if your data is in some 'good' time interval, i.e. 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.

1
RJCodeAdvance On

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