Re: Category Filter how to add custome values?

197 views
Skip to first unread message

asgallant

unread,
Oct 3, 2012, 2:14:46 PM10/3/12
to google-visua...@googlegroups.com
To get the labels "0-Good" etc, you need to adjust the underlying data so that the control sees those strings as the column values instead of 0, 1, 2.  You can accomplish this by setting the view.columns option of the control to use a calculated column instead of the base column.  See an example here: http://jsfiddle.net/asgallant/fqREc/1/


On Wednesday, October 3, 2012 8:00:42 AM UTC-4, Niv The Tool wrote:
simple is in it? but i could not find any sample code that shows the values field usage.

my datatable column can have 3 numbers only 0,1,2

my category filter need to display instead of these 3 numbers text instead like 0-Good,1-Bad,2-Fatal

how is my values field should look like?

many thanks in advance;

can someone drop an example code

            var types_slider = new google.visualization.ControlWrapper({
                'controlType': 'CategoryFilter',
                'containerId': 'types_control',
                'options': {
                    'filterColumnLabel': 'Type',
'values': ????????????????????????????????????????????????
                    'ui': {
                        'caption': 'All',
                        'labelStacking': 'horizontal',
                        'allowTyping': false,
                        'allowMultiple': false
                    }
                }
            });

Niv The Tool

unread,
Oct 4, 2012, 5:27:17 AM10/4/12
to google-visua...@googlegroups.com
First, let me thank you.

the CategoryFilter docs speaks of "values" configuration field (in options section).
and its ability to accept object array with toString inplementation
do you know how to create such array to be assigned to the values field.

10x again.

asgallant

unread,
Oct 4, 2012, 3:54:31 PM10/4/12
to google-visua...@googlegroups.com
Hmmm...the documenation is rather vague there.  I suspect that, ultimately, what happens is that the value returned by the toString method call is used to filter the table, which wouldn't help you (ie, you can't create an object with a numerical value and a toString method that displays the string value in the list and uses the numerical value to filter.

There is a slightly better way to handle this than I used in my example, however: http://jsfiddle.net/asgallant/fqREc/2/.  This preserves the original value and uses the formatted value to populate the list (you can also achieve this by manually formatting your DataTable values).
Reply all
Reply to author
Forward
0 new messages