visualdatatools.com Forum Index visualdatatools.com
Discussion for DataTank and DataGraph
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

date formatting in expressions

 
Post new topic   Reply to topic    visualdatatools.com Forum Index -> Getting Started
View previous topic :: View next topic  
Author Message
Rowland_Carson



Joined: 02 Jun 2008
Posts: 24
Location: Cheltenham, England

PostPosted: Sat Jan 26, 2013 7:12 pm    Post subject: date formatting in expressions Reply with quote

I want to add a text box to graphs that display date-related info. The text box should say something like "All data points between 2003-01-27 and 2013-01-26", but I want the text to automatically update when new data points are imported.

I have 3 issues. I can see how to create function columns with date.max and date.min, but I can't see how to display that in a text box.

In the formula boxes for max & min functions I have to sepcify the number of rows. Is there any way that I can specify "all the rows, however many there are", to avoid having to update that value each time new data is imported?

Finally, I have my system preferences set to display dates as (eg) "2013-01-26". The max & min functions return (eg) "2013/1/26". The leading zeros option for 1-digit months and days is not honoured, and the dash as separator is not honoured.

Any advice welcomed on how to solve these problems.

in friendship

Rowland
Back to top
View user's profile Send private message Visit poster's website
David
Site Admin


Joined: 25 Nov 2006
Posts: 1967
Location: Chapel Hill, NC

PostPosted: Sat Jan 26, 2013 11:28 pm    Post subject: Reply with quote

When you have a date variable you can adjust the format. Once you add it, it will default to year/month/day, but if you click on the small triangle on the right side of the token you get a format menu. I don't look at the country setting, since I don't want the graph to look different depending on what country you open the file in.

The date.min and date.max are single scalars, and if that is the only variable in the expression the column can't guess the length. You can work around it by using the expression

date*0 + date.min

Since the expression has a date column reference the length comes from that. It won't change any of the values, unless you have a NAN value or a masked out value.

What should be there to make things easier is a variable type called "From Column". In 3.1 you now have a "From Command" variable that does this, and you can use the histogram command to compute the maximum and use the From Command variable to get that maximum. Unfortunately, this action does not preserve the fact that the max/min is really a date and not a numerical value (seconds from Jan 1st 1970). I should fix that. I am planning a "From Column" variable for 3.2.

David

David
Back to top
View user's profile Send private message Send e-mail
Rowland_Carson



Joined: 02 Jun 2008
Posts: 24
Location: Cheltenham, England

PostPosted: Sun Jan 27, 2013 3:05 pm    Post subject: Reply with quote

David - thanks for your prompt response.

I think I must be misunderstanding something as I can't make the date appear tokenized in a f(x) expression column. See screenshot:

[img]http://www.rowlandcarson.org.uk/tempo/screen_shot_1.png[/img]

(In a b(c) string expression column tokenization works but the date.max formula does not.)

I can get the formatting I desire by choosing ICU format from the "Display" pop-up menu and specifying what I want so my first issue is now solved. I have done this before but had forgotten!

[img]http://www.rowlandcarson.org.uk/tempo/screen_shot_2.png[/img]

I now have the max date filling a column in my desired format, but I can't see any way to get that shown in a text box or label. I tried making a plot of max date and hiding/excluding it but that still did not produce any useful tokens that I could include in a text box.

It seems from the latter part of your message that I won't really be able to do this until the next version comes out - am I interpreting you correctly?

regards

Rowland
Back to top
View user's profile Send private message Visit poster's website
David
Site Admin


Joined: 25 Nov 2006
Posts: 1967
Location: Chapel Hill, NC

PostPosted: Mon Jan 28, 2013 12:03 am    Post subject: Reply with quote

I just uploaded a new beta.

To get the max into a token field, do the following, assuming the date column is called "date".

1 - Create a histogram command, and select the date column.

2 - Exclude the histogram command if you don't need that drawing command.

3 - Create a global variable using the menu, and select the "From Command" option.

4 : Select the drawing command you want, and "Maximum" from the menu.

5 : In the text field add a token for the variable, and using the small menu in the token, pick which format to use.


Before the latest beta, the variable you created in "3" didn't realize that Maximum was a date and not just a number. That meant that formatting was based on the numerical value.

David
Back to top
View user's profile Send private message Send e-mail
Rowland_Carson



Joined: 02 Jun 2008
Posts: 24
Location: Cheltenham, England

PostPosted: Mon Jan 28, 2013 11:16 am    Post subject: Reply with quote

David - thanks for all your work on this! Your changes to the beta code, and your step-by step explanation got me just about where I want to be.

I have a final query. The pop up formatting menu for the date in the final text box offers a number of ways to order the presentation of the date, but no way to choose the delimiters - they are set at "/" and I prefer to use "-".

I can almost achieve the desired format by choosing the year only, inserting a dash, choosing the month number only, inserting a dash and choosing the day only. However, this results in (eg) 2013-1-1 rather than my preferred 2013-01-01, and I can't see any way to manipulate the formatting to achieve that.

Is there any reason why the pop-up menu in the token for the global variable is different from the pop-up menu in a date column? That offers total flexibility in formatting dates by using ICU format. Using that for both instances would be more consistent as well as much easier to use (for me!).

regards

Rowland
Back to top
View user's profile Send private message Visit poster's website
David
Site Admin


Joined: 25 Nov 2006
Posts: 1967
Location: Chapel Hill, NC

PostPosted: Tue Jan 29, 2013 2:01 pm    Post subject: Reply with quote

Tweaked things a little more. Now I added yyyy-MM-dd as a format, as well as a two digit date and two digit month.

The reason I don't have a "ICU" formatter option is that I don't want hidden information that you have to use a modal dialog box to see. If I had a "ICU format" option I would have to bring up a small window where you can type in the format and hit apply. I try to have as few dialogs windows as possible and I want all the layout information to be visible. The pop up menu in the token field is already a slight compromise, since you have to click on the menu to see it, but the ICU would be one level deeper.

My view is that there aren't that many formats that most people use. I want to support the most common formats by predefining them, allow you to stretch that further by using multiple tokens and then in order to go completely "nuts" I think it would make more sense to create a "Text" variable method that allows you to specify the format as part of the settings. That way I have a UI canvas to work with. It also won't take up UI real estate when you don't need the flexibility. This variable type is not at the moment on my list of things to do, but this is where the full ICU option would go if I were to implement it.

David
Back to top
View user's profile Send private message Send e-mail
Rowland_Carson



Joined: 02 Jun 2008
Posts: 24
Location: Cheltenham, England

PostPosted: Wed Jan 30, 2013 1:59 pm    Post subject: Reply with quote

David - thanks very much for your patience with my requests. With your latest beta I can now get the effect I was seeking, and I really appreciate how you have responded.

I can see how your desire to minimise hidden information takes precedence over providing a completely consistent appearance for all user interactions, and your present solution is fine for me.

You say "there aren't that many formats that most people use" - but I'm sure there are more people using ISO 8601 (ie yyyy-MM-dd, NOT yyyy/M/d) than any other single format, so I feel that ought to be one of the first formats to consider providing anywhere a date is available.

Thanks again for your cheerful and prompt attention to my queries.

in friendship

Rowland
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    visualdatatools.com Forum Index -> Getting Started All times are GMT - 3 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group