Jump to content
Software FX Community

DateTime label format


Recommended Posts

Dear CharFX Group,

I have two series, one (DateTime) for label and one (double) for value.

The following is the code and the generated chart

 inXChartObj.DataSourceSettings.DataType[0] = DataType.Label;

 inXChartObj.DataSourceSettings.DataType[1] = DataType.Value;

 inXChartObj.DataSourceSettings.DataSource = inSourceDataTableObj;

inXChartObj.AxisX.LabelsFormat.Format = AxisFormat.DateTime;

 inXChartObj.AxisX.LabelsFormat.CustomFormat = "yyyy/MM/dd HH:mm";

http://www.wretch.cc/album/show.php?i=isponder&b=11&f=1310563676&p=4

The AxisX only displays Year/Month/Day but no Hour and Minute.

Please help me on this.

Thanks in advance.

Link to post
Share on other sites

Dear maximop,

Thanks for your response.

Unfortunately, DataFormat didn't work.

But i found a workaround : set LabelsFormat before setting DataSource

inXChartObj.DataSourceSettings.DataType[0] = DataType.Label;

 inXChartObj.DataSourceSettings.DataType[1] = DataType.Value;

 inXChartObj.AxisX.LabelsFormat.Format = AxisFormat.DateTime;

 inXChartObj.DataSourceSettings.DataSource = inXYValueDataTableObj;

inXChartObj.AxisX.LabelsFormat.CustomFormat = "yyyy/MM/dd HH:mm";

everything works perfact. but i can't figure out why !?

Link to post
Share on other sites

DateTime objects in ChartFX are actually set to the double representation of that date; therefore, when passing XValues to the x-axis, you need to instruct ChartFX that the x-axis will contain DateTime values so they can be properly formatted. As you already know, this is done before binding the data to the chart. The same applies when setting the chart's DataTypes.

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...