SetDateFormat function of class DateAxis in wxfreechart Topic is solved

Talk here about issues with one of the components hosted at wxCode, or suggest features for it.
Post Reply
Jackzz
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Jul 18, 2016 5:50 am

SetDateFormat function of class DateAxis in wxfreechart

Post 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
Last edited by Jackzz on Mon Jul 18, 2016 11:12 am, edited 1 time in total.
catalin
Moderator
Moderator
Posts: 1618
Joined: Wed Nov 12, 2008 7:23 am
Location: Romania

Re: SetDateFormat function of class DateAxis in wxfreechart

Post by catalin »

Did you try without spaces ?
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: SetDateFormat function of class DateAxis in wxfreechart

Post 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
Use the source, Luke!
Jackzz
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Jul 18, 2016 5:50 am

Re: SetDateFormat function of class DateAxis in wxfreechart

Post by Jackzz »

catalin wrote:Did you try without spaces ?

Yes..I did.. Then date and time is shown without a space in between..
Jackzz
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Jul 18, 2016 5:50 am

Re: SetDateFormat function of class DateAxis in wxfreechart

Post 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.
iwbnwif
Super wx Problem Solver
Super wx Problem Solver
Posts: 282
Joined: Tue Mar 19, 2013 8:52 pm

Re: SetDateFormat function of class DateAxis in wxfreechart

Post 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.
wxWidgets 3.1.2, MinGW64 8.1.0, g++ 8.1.0, Ubuntu 19.04, Windows 10, CodeLite + wxCrafter
Some people, when confronted with a GUI problem, think "I know, I'll use Eclipse RCP". Now they have two problems.
Jackzz
In need of some credit
In need of some credit
Posts: 5
Joined: Mon Jul 18, 2016 5:50 am

Re: SetDateFormat function of class DateAxis in wxfreechart

Post by Jackzz »

Code: Select all

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