Page 1 of 1

SetDateFormat function of class DateAxis in wxfreechart

Posted: Mon Jul 18, 2016 6:00 am
by Jackzz
Hi, I am a newbie to wxfreechart and is using the library(in VS 2010 and C++) to create a graph. A line of my code is as follows :

Code: Select all

bottomAxis->SetDateFormat(wxT("%d-%m-%y \n %H:%M:%S"));
From the docs,SetDateFormat() accepts date format in strftime style (http://wxcode.sourceforge.net/docs/free ... eAxis.html).
The above format specifier, if used with strftime gives date in first line and time in the second line. But SetDateFormat doesn't works in the same way. I get both date and time in the same line. Is there some way by which I can split the twi inti to lines? Any help will be appreciated. Thankyou

Re: SetDateFormat function of class DateAxis in wxfreechart

Posted: Mon Jul 18, 2016 6:08 am
by catalin
Did you try without spaces ?

Re: SetDateFormat function of class DateAxis in wxfreechart

Posted: Mon Jul 18, 2016 6:31 am
by doublemax
Which wxWidgets version?

I assume that wxfreechart uses wxDC::DrawText to draw the label which only supports multi-line texts since wx 2.9.2

Re: SetDateFormat function of class DateAxis in wxfreechart

Posted: Mon Jul 18, 2016 11:17 am
by Jackzz
catalin wrote:Did you try without spaces ?

Yes..I did.. Then date and time is shown without a space in between..

Re: SetDateFormat function of class DateAxis in wxfreechart

Posted: Mon Jul 18, 2016 11:17 am
by Jackzz
doublemax wrote:Which wxWidgets version?

I assume that wxfreechart uses wxDC::DrawText to draw the label which only supports multi-line texts since wx 2.9.2

I am using wxwdigets 3.0.0.

Re: SetDateFormat function of class DateAxis in wxfreechart

Posted: Mon Jul 18, 2016 8:44 pm
by iwbnwif
I tested this on Linux (gcc 4.8.4) and it draws the label on 2 separate lines.
doublemax: I assume that wxfreechart uses wxDC::DrawText to draw the label which only supports multi-line texts since wx 2.9.2
Yes it does, although in the OP's case I expect the label is appearing vertically, so it is drawn with wxDC::DrawRotatedText. Could this be the issue? It should be simple to check by setting:

Code: Select all

bottomAxis->SetVerticalLabelText(false);
Sorry, I don't have VS 2010 to try it :(

Jackzz, as an aside I have a slightly improved update to the wxCode wxFreeChart on GitHub (https://github.com/iwbnwif/wxFreeChart). This incorporates several bug fixes by PB and myself, although AFAIK nothing has been changed with this part of the labelling code.

Re: SetDateFormat function of class DateAxis in wxfreechart

Posted: Tue Jul 19, 2016 4:16 am
by Jackzz

Code: Select all

bottomAxis->SetVerticalLabelText(false);
Sorry, I don't have VS 2010 to try it :(
Thankyou.. this helped me.. :)