简体   繁体   English

如何在c# windows forms中的图表中显示起点和终点x轴label?

[英]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.我只是菜鸟C# windows forms 申请。 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]);我正在尝试使用 function this.chart1.Series[0].Points.DataBindXY(dt.DefaultView, "tms", dt.DefaultView, head[1]);从 data.table 中获取一张图表 plot where dt is the data.table, tms is timestamp column and head[1] is a data column.其中dt是 data.table, tms是时间戳列, head[1]是数据列。 But I am not able to see the start and end x-axis label in chart.但我无法在图表中看到开始和结束 x 轴 label。 Check out my output here.在这里查看我的 output。 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?有没有预定义的function?

Thanks for helping...感谢您的帮助...

There is no predefined function, but没有预定义的 function,但是

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. 1) 如果您的数据处于某个“良好”的时间间隔内,即从 2020.05.01 0:00 到 2020.05.02 03:00,您可以调整AxisX.MinimumAxisX.Interval属性。

2) if your data is not in 'good' time interval you should use CustomLabels . 2)如果您的数据不在“好”时间间隔内,您应该使用CustomLabels It is not so easy because your CustomLabels override all normal labels.这并不容易,因为您的CustomLabels会覆盖所有普通标签。

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. 3) 如果只需要显示第一个和最后一个值,并且在哪里不重要 - 使用RectangleAnnotation - 可以放置在图表上的文本。

The easiest way for any data type is to set the IsMarginVisible property of the X axis to false: chartArea1.AxisX.IsMarginVisible = false;对于任何数据类型,最简单的方法是将 X 轴的IsMarginVisible属性设置为 false: chartArea1.AxisX.IsMarginVisible = false; or Property Box属性框

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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