Jump to content
Software FX Community

DateTime label format


walter

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 comment
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 comment
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 comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...