0

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

Diode
  • 68
  • 10

2 Answers2

0

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.

capsSadSack
  • 49
  • 1
  • 8
  • Thanks for your reply! I really appreciate your advice! Since it is necessary to show the start and the end time of the data(no matter where), It would be best for me to use the third option as guided. Thanks again for solving my query. Being just curious that why a good time interval is required for the first solution? – Diode May 03 '20 at 14:34
  • In the first variant (i.e. data from 2020.05.01 0:00 to 2020.05.02 03:00) you can chose 'AxisX.Minimum' as 2020.05.01 0:00 and 'AxisX.Interval' equal to an hour, so both the first and the last data points would lay on axis label values. – capsSadSack May 03 '20 at 14:39
  • Okay! Gotcha! Thanks! – Diode May 03 '20 at 14:50
0

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

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Mar 12 '22 at 06:58