本示例演示了当使用了自动 轴日期时间刻度模式 时,如何获得为 轴 的日期时间网格对齐方式和度量单位只读属性而计算的取值。 此外,在 ChartControl.DateTimeMeasurementUnitsCalculated ( WebChartControl.DateTimeMeasurementUnitsCalculated ) 事件中,还可以访问轴本身并定制其属性。
C# | 复制代码 |
---|---|
using DevExpress.XtraCharts; // ... private void chartControl1_DateTimeMeasurementUnitsCalculated (object sender, DateTimeMeasurementUnitsCalculatedEventArgs e) { // In this event, you can access the properties of the corresponding axis, // and obtain the automatically calculated value // for the axis date-time grid alignment and measure unit. ((AxisX)e.Axis).Title.Visible = true; ((AxisX)e.Axis).Title.Text = "The Axis Grid Alignment Unit is " + e.GridAlignment.ToString() + "\r\nThe Axis Measure Unit is " + e.MeasureUnit.ToString(); } |
Visual Basic | 复制代码 |
---|---|
Imports DevExpress.XtraCharts ' ... Private Sub chartControl1_DateTimeMeasurementUnitsCalculated(ByVal sender As Object, _ ByVal e As DateTimeMeasurementUnitsCalculatedEventArgs) _ Handles chartControl1.DateTimeMeasurementUnitsCalculated ' In this event, you can access the properties of the corresponding axis, ' and obtain the automatically calculated value ' for the axis date-time grid alignment and measure unit. CType(e.Axis, AxisX).Title.Visible = True CType(e.Axis, AxisX).Title.Text = _ "The Axis Grid Alignment Unit is " & e.GridAlignment.ToString() & _ Constants.vbCrLf & "The Axis Measure Unit is " & e.MeasureUnit.ToString() End Sub |
在下面的插图中显示了结果。
Show Me |
---|
在 DevExpress Code Central 数据库中可以找到完整的示例项目,网址是 http://www.devexpress.com/example=E1529。 取决于目标平台类型 (ASP.NET、WinForms 等),可以在线运行本示例,或者下载自动可执行的示例。 |