[英]C# Winform charts, zooming and scale of x axis displaying date and time
I have a winform with charts in it, in my code I have already set: 我有一个带有图表的winform,在我已设置的代码中:
//Enable range selection and zooming end user interface
this.chart1.ChartAreas["ChartArea1"].CursorX.IsUserEnabled = true;
this.chart1.ChartAreas["ChartArea1"].CursorY.IsUserEnabled = true;
this.chart1.ChartAreas["ChartArea1"].CursorX.IsUserSelectionEnabled = true;
this.chart1.ChartAreas["ChartArea1"].CursorY.IsUserSelectionEnabled = true;
this.chart1.ChartAreas["ChartArea1"].AxisX.ScaleView.Zoomable = true;
this.chart1.ChartAreas["ChartArea1"].AxisY.ScaleView.Zoomable = true;
this.chart1.ChartAreas["ChartArea1"].AxisX.ScrollBar.IsPositionedInside = true;
this.chart1.ChartAreas["ChartArea1"].AxisY.ScrollBar.IsPositionedInside = true;
It zooms upon selection. 它根据选择进行缩放。 However, my selections are limited to the gridlines.
但是,我的选择仅限于网格线。 Moreover, upon selection, there is a red cross, the cross only stays at a fixed x-axis value.
此外,在选择时,存在红叉,十字仅保持在固定的x轴值。 How can I modify such the selection does not limit to gridlines/ specific fixed x-axis value?
如何修改这样的选择不限制网格线/特定的固定x轴值?
I have also set the x-axis type to date time, ie 我还将x轴类型设置为日期时间,即
this.chart1.Series[chanName].XValueType = ChartValueType.DateTime;
However, the x-axis only shows the date, but not time. 但是,x轴仅显示日期,而不显示时间。 How can I show both date and time on the x-axis?
如何在x轴上显示日期和时间? Thanks!
谢谢!
You can show both date and time on the x-axis by setting the LabelStyle.Format Property. 您可以通过设置LabelStyle.Format属性在x轴上显示日期和时间。
this.chart1.ChartAreas["ChartArea1"].AxisX.LabelStyle.Format = "g";
You need to set the CursorX.Interval Property. 您需要设置CursorX.Interval属性。 Its default value is 1.0.
其默认值为1.0。
this.chart1.ChartAreas["ChartArea1"].CursorX.Interval = 1 / 24.0 / 60.0; // 1 minute
Also you can set the AxisX.ScaleView.MinSize Property to limit selection. 您还可以设置AxisX.ScaleView.MinSize属性以限制选择。 Its default value is notset.
其默认值未设置。
this.chart1.ChartAreas["ChartArea1"].AxisX.ScaleView.MinSize = 1 / 24.0 / 60.0;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.