简体   繁体   中英

Change datetime format of x-axis?

I have a TChart with an area series. The area Points are mapped to datetime values. How can I change the format of the date labels on the x-axis?

This does not work:

area.add(new DateTime(timestamp), value); // Date value!
...
chart.getAxes().getBottom().getLabels().setDateTimeFormat("MMM 'yy");

This gives me an IllegalArgumentException:

new DateTime(2012,1,1).toString("MMM 'yy");

The comma ' in the string format argument is unnaccepted.

As you can read here , the single quote is used to avoid interpretation. Put two single quotes to draw a single quote:

new DateTime(2012,1,1).toString("MMM ''yy");

You need set the XValues of Area as DateTime as do in next line of code:

area.getXvalues().setDateTime(true); 

Please, try again if adding my line of code help you to solve your problem.

I hope will helps.

Thanks,

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM