如何在毫秒图表中绑定24小时格式的日期
本文关键字:24小时 绑定 格式 日期 | 更新日期: 2023-09-27 17:59:09
public void bindChartDetail()
{
objUser = (UserEntity)Session["User"];
if (objUser == null)
{
Response.Redirect("~/Default.aspx");
}
DateTime fromDate;
DateTime toDate;
String strDomainName = "";
if (ddlDomainName.SelectedIndex > 0)
{
strDomainName = ddlDomainName.SelectedItem.Text.ToString();
}
else
{
strDomainName = lblDomainName.Text;
}
if (txtFromDate.Text != "")
{
fromDate = DateTime.ParseExact(txtFromDate.Text, "dd-MM-yyyy", null);
}
else
{
fromDate = toDate = System.DateTime.Now;
}
if (txtToDate.Text != "")
{
toDate = DateTime.ParseExact(txtToDate.Text, "dd-MM-yyyy", null);
}
else
{
toDate = System.DateTime.Now;
}
ReportBL objReport = new ReportBL();
PagedDataSource rptPager = null;
DataTable dt = null;
try
{
dt = new DataTable();
dt = objReport.USERWISEACCOUNTINGINFORMATIONWITHINBOUNDOUTBOUND(strDomainName, 0, fromDate, toDate);
if (dt == null)
{
if (dt.Rows.Count > 0)
{
byte[] YPointMember = new byte[dt.Rows.Count];
ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss";
//DateTime[] YPointMember = new DateTime[dt.Rows.Count];
for (int count = 0; count < dt.Rows.Count; count++)
{
YPointMember[count] = Convert.ToByte(dt.Rows[count]["INBOUND"]);
//YPointMember[count] = (dt.Rows[count]["connectdatetime"]);
}
Chart1.Series[0].Points.DataBindXY(YPointMember);
Chart1.Series[0].BorderWidth = 1;
Chart1.Series[0].ChartType = SeriesChartType.Line;
}
我的数据库中有两个字段:inbound
和date
。我想以24小时的格式在x轴上显示date
,但我不知道,因为我是图表控制的新手。
你可以试试这个
ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss.fff";