在X轴上设置24小时刻度标记 [英] Setting 24 hours Tick Marks on X axis

查看:298
本文介绍了在X轴上设置24小时刻度标记的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是ASP.NET图表控件的新手,所以这可能是一个简单的问题。我正在创建一个RangeBar图表来显示一天的日程安排。无论返回的具体小时数如何,如何将X轴上的刻度线设置为始终显示24小时?

解决方案

按X -axis你可能意味着水平轴,它实际上是RangeBar图表中的Y轴。


你需要设置轴的最小值和最大值。如果您的值只是表示一天中小时数的数字,请将轴最小值设置为0,将最大值设置为24

 Chart1.ChartAreas(0).AxisY。最小值= 0 
Chart1.ChartAreas(0).AxisY.Maximum = 24

如果值是DateTimes,那么您需要找出开始和结束位置那个特定的日子。例如像这样......

'这应该设置为数据中的第一个日期值,例如.. 
Dim someDate As DateTime = New DateTime(2010,10,29,8,30,0)

'日期函数将清除小时,分钟和秒的日期时间
Chart1.ChartAreas(0)。 AxisY.Minimum = someDate.Date.ToOADate()
Chart1.ChartAreas(0).AxisY.Maximum = someDate.AddDays(1).Date.ToOADate()

您可能还希望将间隔设置为1(或使用DateTimes时为一小时)以显示每小时的轴标签和网格线。

 Chart1.ChartAreas(0).AxisY.Interval = 1 

'如果使用DateTimes
Chart1.ChartAreas(0).AxisY.IntervalType = DateTimeIntervalType.Hours


I am brand new to ASP.NET chart controls so this may be a simple question. I am creating a RangeBar chart to display a day's schedule. How can I set the tick marks on the X-axis to always display 24 hours regardless of the specific hours returned?

解决方案

By X-axis you probably mean the horizontal axis which is actually the Y-axis in a RangeBar chart.

You need to set the axis minimum and maximum. If your values are just numbers representing the hours of a day, set the axis minimum to 0 and maximum to 24

Chart1.ChartAreas(0).AxisY.Minimum = 0
Chart1.ChartAreas(0).AxisY.Maximum = 24

If the values are DateTimes, then you need to find out the beginning and end positions for that particular day. For example something like this..

'This should be set to the first date value in your data for example..
Dim someDate As DateTime = New DateTime(2010, 10, 29, 8, 30, 0)

'The Date-function will clear the DateTime of hours, minutes and seconds
Chart1.ChartAreas(0).AxisY.Minimum = someDate.Date.ToOADate()
Chart1.ChartAreas(0).AxisY.Maximum = someDate.AddDays(1).Date.ToOADate()

You probably also want to set the interval to 1 (or one hour when using DateTimes) to show the axis labels and grid lines for each hour.

Chart1.ChartAreas(0).AxisY.Interval = 1

'If using DateTimes
Chart1.ChartAreas(0).AxisY.IntervalType = DateTimeIntervalType.Hours


这篇关于在X轴上设置24小时刻度标记的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆