Hi !

I'm bringing this old issue back into discussion once again because

1. the answer <<not possible>> is not an option
2. after some thinking / searching / learning I'm starting to believe that I
came up with asolution that deserves to be (at least) discussed and (maybe)
included in Google Visualization Query Language .

In the lines below I pasted the original question followed by the last
answer
I got . The goal is to render a punch card similar to those offered by
Github

---------

On Sat, Aug 24, 2013 at 11:53 PM, asgallant <[email protected]>wrote:

>
>
> On Saturday, August 24, 2013 10:10:31 PM UTC-4, olemis wrote:
>>
>> /me removing top-posting ...
>>
>> On 8/23/13, asgallant <[email protected]> wrote:
>> > On Friday, August 23, 2013 10:35:45 PM UTC-4, olemis wrote:
>> >>
>> [...]
>> >> I have a GViz SQL query returning no more than 7 rows corresponding to
>> >> days of the week as returned by `dayOfWeek()` i.e. 1=Sunday, 2=Monday,
>> >> ..., 7=Saturday . I want to display labels with (day of week) names in
>> >> X (Y) axis .
>> >>
>> >> Q:
>> >>   - I wonder whether is it possible to achieve this using
>> >>     ICU & format clause ?
>> >>     * How ?
>> >>   - I'd also like to do the same for int numbers 0-23
>> >>     representing hours to make them look like
>> >>     3am, 12m , 5pm , etc ...
>> >>     * Possible ?
>> >>     * How ?
>> >>
>> >> TIA
>> >
>>
> [...]

>
>>
> I don't think you can do any of that in the query language.  If you were
> retrieving Date objects for your date column, you could use the ICU date
> formatting to get day of week, but there's no pattern that will turn
> numbers into day strings or into time strings.  You will have to handle
> this formatting on the javascript side.
>

---------

Even if it is true that it's not possible to satisfy this use case using ICU
DecimalFormat [1]_ , the library does include a class to get his done ,
namely
RuleBasedNumberFormat [2]_ .

So I figured this out and implemented support for custom formatting
patterns in
TracGViz [3]_ plugin using a new `format_syntax` option. I do not want to be
abusive so I invite all those interested in the details to see
bhnet:product:dataviz:ticket:302 [4]_. In there you'll also find references
to
related tickets and changesets in the repository in case you want to review
them.

I'll be brief and mention that :

- options format_syntax:'column:PredefinedNumberRule' will support
specifying
ICU's default SPELLOUT, ORDINAL, DURATION rule sets to format the value
for 'column' .
- options format_syntax:'column:InlineNumberRule' will support specifying in
query FORMAT clause the text of a custom rule set used to format the value
for column .

I'll share with you a few examples based on the data table used in
GViz QL docs [7]_ :

-----------------------------------------------------------
select dayOfWeek(hireDate)
format dayOfWeek(hireDate) 'Error;Sun;Mon;Tue;Wed;Thu;Fri;Sat;Error'
options format_syntax:'dayOfWeek(hireDate):NumberRule'
-----------------------------------------------------------
select name, age, isSenior
format age 'SPELLOUT'
options no_values , format_syntax:'age:PredefinedNumberRule'
-----------------------------------------------------------
select name, age, isSenior, dayOfWeek(hireDate)
format age 'SPELLOUT',
dayOfWeek(hireDate) 'Error;Sun;Mon;Tue;Wed;Thu;Fri;Sat;Error'
options no_values ,
format_syntax:'age:PredefinedNumberRule,dayOfWeek(hireDate):NumberRule'
-----------------------------------------------------------


The result sets of these (and other) queries are documented in the test
cases
written for this feature [5]_

We are running this solution in our servers . A working version of the punch
card transforming numbers into week day names (vertical axis) is available
in
the docs [6]_

Maybe users turn out to be interested in including this option (or
something equivalent) in Google's query spec , I do not know ; but in any
case feedback will be appreciated .

.. [1] http://userguide.icu-project.org/formatparse/numbers

.. [2]
http://userguide.icu-project.org/formatparse/numbers#TOC-RuleBasedNumberFormat

.. [3] http://dataviz.blood-hound.net/wiki/Packages/TracGViz

.. [4] http://dataviz.blood-hound.net/ticket/302

.. [5]
http://dataviz.blood-hound.net/browser/tracgviz/trac-dev/gviz/tracgviz/testing/test_gvizql.py?marks=3765-3914&rev=233a8bbebb2c#L3765

.. [6]
http://widgets.blood-hound.net/wiki/Demos/HighStockGithub#github-punch-card

-- 
Regards,

Olemis - @olemislc

Apache(tm) Bloodhound contributor
http://issues.apache.org/bloodhound
http://blood-hound.net

Blog ES: http://simelo-es.blogspot.com/
Blog EN: http://simelo-en.blogspot.com/

Featured article:

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.

Reply via email to