calculated sort column?

36 views
Skip to first unread message

Suzanne Paley

unread,
Jan 3, 2017, 7:58:07 PM1/3/17
to Google Visualization API
I have an underlying DataTable with discrete x-axis categories and multiple series.  I'm using DataViews on top of that to generate column charts, so that users can select which series to display (including calculated series that may aggregate multiple source series in various ways).  I want to provide the users with multiple sort options, including some based on calculated values, such as the maximum or minimum over all user-selected series, or the difference between the maximum and minimum of user-selected series.  I can create a calculated column in my view that generates the values the user wants to sort on (though I wouldn't want to display such a column, so there doesn't seem to be an appropriate role for it), but I can't figure out how to sort on it -- getSortedRows seems to take only column indices from the base table, not calculated columns.  Is there a way to do what I want?  If not, can I put in a feature request for calculated sort columns?

Thanks,
Suzanne

Daniel LaLiberte

unread,
Jan 4, 2017, 9:09:01 AM1/4/17
to Google Visualization API
Hi Suzanne,

I believe the getSortedRows() method should work with calculated columns as well.  Here is an example showing that it is working as I would expect:  https://jsfiddle.net/dlaliberte/fbkwmjjL/

Perhaps you have found a bug, but if so, we would need to see the details of what you are doing.  

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/9963c19d-7a77-4b50-997b-dec59d13aaa6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Suzanne Paley

unread,
Jan 4, 2017, 12:10:21 PM1/4/17
to Google Visualization API
Hi Daniel,

If I don't want the calculated sort column to appear in my graph, what can I do?  If it's included in my view, by default it will be shown as an additional series. The only other numeric role that seems to be available to me is interval, which is not what I want either.  Is there a way to suppress its display?

Suzanne


On Wednesday, January 4, 2017 at 6:09:01 AM UTC-8, Daniel LaLiberte wrote:
Hi Suzanne,

I believe the getSortedRows() method should work with calculated columns as well.  Here is an example showing that it is working as I would expect:  https://jsfiddle.net/dlaliberte/fbkwmjjL/

Perhaps you have found a bug, but if so, we would need to see the details of what you are doing.  

On Tue, Jan 3, 2017 at 7:58 PM, Suzanne Paley <suzann...@gmail.com> wrote:
I have an underlying DataTable with discrete x-axis categories and multiple series.  I'm using DataViews on top of that to generate column charts, so that users can select which series to display (including calculated series that may aggregate multiple source series in various ways).  I want to provide the users with multiple sort options, including some based on calculated values, such as the maximum or minimum over all user-selected series, or the difference between the maximum and minimum of user-selected series.  I can create a calculated column in my view that generates the values the user wants to sort on (though I wouldn't want to display such a column, so there doesn't seem to be an appropriate role for it), but I can't figure out how to sort on it -- getSortedRows seems to take only column indices from the base table, not calculated columns.  Is there a way to do what I want?  If not, can I put in a feature request for calculated sort columns?

Thanks,
Suzanne

-- 
--

Daniel LaLiberte

unread,
Jan 4, 2017, 12:14:01 PM1/4/17
to Google Visualization API
You could create yet another view that only lists the columns you do want to use in the chart.  If you are using a ChartWrapper, you can do this with a 'view' property.

We don't have a role to 'ignore' a column, though I can see that might be useful.

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.

Suzanne Paley

unread,
Jan 4, 2017, 5:14:27 PM1/4/17
to Google Visualization API
Thanks for your help.  Creating a new view that contains only my calculated sort column, and then sorting my original view by setting its rows to be getSortedRows of the new view column works well for me, without being too disruptive to my existing code.  E.g. https://jsfiddle.net/fbkwmjjL/1/
Suzanne


On Wednesday, January 4, 2017 at 9:14:01 AM UTC-8, Daniel LaLiberte wrote:
You could create yet another view that only lists the columns you do want to use in the chart.  If you are using a ChartWrapper, you can do this with a 'view' property.

We don't have a role to 'ignore' a column, though I can see that might be useful.
On Wed, Jan 4, 2017 at 12:10 PM, Suzanne Paley <suzann...@gmail.com> wrote:
Hi Daniel,

If I don't want the calculated sort column to appear in my graph, what can I do?  If it's included in my view, by default it will be shown as an additional series. The only other numeric role that seems to be available to me is interval, which is not what I want either.  Is there a way to suppress its display?

Suzanne

On Wednesday, January 4, 2017 at 6:09:01 AM UTC-8, Daniel LaLiberte wrote:
Hi Suzanne,

I believe the getSortedRows() method should work with calculated columns as well.  Here is an example showing that it is working as I would expect:  https://jsfiddle.net/dlaliberte/fbkwmjjL/

Perhaps you have found a bug, but if so, we would need to see the details of what you are doing.  

On Tue, Jan 3, 2017 at 7:58 PM, Suzanne Paley <suzann...@gmail.com> wrote:
I have an underlying DataTable with discrete x-axis categories and multiple series.  I'm using DataViews on top of that to generate column charts, so that users can select which series to display (including calculated series that may aggregate multiple source series in various ways).  I want to provide the users with multiple sort options, including some based on calculated values, such as the maximum or minimum over all user-selected series, or the difference between the maximum and minimum of user-selected series.  I can create a calculated column in my view that generates the values the user wants to sort on (though I wouldn't want to display such a column, so there doesn't seem to be an appropriate role for it), but I can't figure out how to sort on it -- getSortedRows seems to take only column indices from the base table, not calculated columns.  Is there a way to do what I want?  If not, can I put in a feature request for calculated sort columns?

Thanks,
Suzanne

-- 
--

--
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 google-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.



--
Reply all
Reply to author
Forward
0 new messages