How to bind date in 24 hour format in ms chart

1k views Asked by At
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;
            }

I have two field in my database: inbound and date. I want to show date on x-axis in 24 hour format, but I have no idea because I am new to chart control.

1

There are 1 answers

2
Mukesh Kalgude On

You can try this

ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss.fff";