is .DataView compatible with ChartWrapper and ControlWrapper

376 views
Skip to first unread message

tracy love

unread,
Jun 17, 2011, 1:10:57 PM6/17/11
to google-visua...@googlegroups.com
i have a visualization app here ...
http://map.region3dfg.org/gadget/R3G_browsecolumns_2.html
that uses DataView to show selected columns from a spreadsheet data source.

i really want to be able to search and filter the spreadsheet based on a user selected field just like the stringfilter control does..

http://code.google.com/apis/chart/interactive/docs/gallery/controls.html#stringfilter

QUESTIONS:
1. can i still use DataView or do i have to use something else to control which columns are shown?
2. do i have to use ChartWrapper in order to use the controlWrapper with my existing set up?

tracy love

unread,
Jun 17, 2011, 7:27:26 PM6/17/11
to google-visua...@googlegroups.com
well in the last few hours i have gotten closer to working this out (see R3G_browsecolumns_2.html )
however i want to be able to click on my table and run a function..

google.visualization.events.addListener(tablewrapped, 'select', selectHandler);

function selectHandler() {
  var row = tablewrapped.getSelection()[0].row; //breaks down here with .getSelection not a function

but i guess i need to get the table back out of  the tablewrapped object? is this correct?

Riccardo Govoni

unread,
Jun 20, 2011, 6:34:26 AM6/20/11
to google-visua...@googlegroups.com
Regarding the last question, yes, you have to pull the chart out of the wrapper via getChart() (see the ChartWrapper docs): 

tablewrapped.getChart().getSelection()

Regarding the former questions, I see in your code that you are already seeding the Dashboard with a DataView instance, so as you already figured out, you can populate a Dashboard with a dataview.

The only things I note are:
- your tablewrapped has a 'View' option which is not needed. First, it is misspelled (it should be lowercase). Second, giving the DataView directly to the dashboard should be enough in your case.
- your showHideFld() function, which I understand is the one triggered whenever I add/remove a column from the view should trigger a redraw of the entire dashboard instead of just the table (otherwise the stringfilter won't be aware of the new columns).

Let me know if this helps,
/R.

tracy love

unread,
Jun 20, 2011, 1:35:49 PM6/20/11
to google-visua...@googlegroups.com
Riccardo,

i just posted a new version, and did what you said. i think i need to clean this up some more, so if you get a chance to look at it again and see something that could be cleaner please tell me. i am going to go make a gadget for it now, Thank You!

Riccardo Govoni

unread,
Jun 20, 2011, 1:46:49 PM6/20/11
to google-visua...@googlegroups.com
I had a very brief look and played with it for a second. Seems fine to me. You may want to reduce the spacing between the string filter and the dropdown, maybe adding a ":" in between, to make it clear that the stringfilter applies to what the dropdown says. 

/R.

ficuscr

unread,
Jul 11, 2011, 12:32:13 AM7/11/11
to google-visua...@googlegroups.com
I am having a similar issue.  Took me a moment to realize the that getChart() may not be available immediately after calling draw().  Wrapped the selection handler in a ready handler a think I got around that.

I am trying to bind the selections of a DataTable and 'Wrapped' Scatter Chart.  The getSeleciton() values look good.  But when I call setSelection() on the table nothing happens.  Next getter on the table returns an empty array.  I am at a loss.

MC Get Vizzy

unread,
Jul 11, 2011, 6:45:32 AM7/11/11
to google-visua...@googlegroups.com
Are you trying to select individual cells of the Table vizualization?  I believe that the Table does not currently support selecting individual cells.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-visualization-api/-/ASLnb3qsiIgJ.

To post to this group, send email to google-visua...@googlegroups.com.
To unsubscribe from this group, send email to google-visualizati...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.

ficuscr

unread,
Jul 11, 2011, 2:08:25 PM7/11/11
to google-visua...@googlegroups.com
It is accurate that table selections are for full rows, not cells.  Which works fine for my needs.  What I am trying to do is essentially what is demonstrated API examples here http://code.google.com/apis/ajax/playground/#interaction_using_events.  Binding the selection of a chart to a table.  In this case a Table and a ScatterChart.

Here is what I have found...

The getSelection method on a ScatterChart returns an array with an object having properties for row and column.  If that return value is passed to the setSlection of the table it doesn't work.  You have to pass only the 'row'.  Like so:

var sel = chart.getSelection();
table.setSelection([{row: sel[0].row}]);

I figure that out and now have the clicks on the ScatterChart selecting the corresponding row on the table.  I feel like the setSelection for the Table should be a little more flexible.

Also, it seems the the 'core charts', to which ScatterChart belongs, has no support for "visual cue for selection".  So while clicking a table row does set the selection on the ScatterChart there is no visual effect to indict as much.  The fact that I can 'click' the ScatterChart to make a selection and get a cue, but not accomplish the same programmatically is pretty frustrating.  Still exploring a work around and trying to make sure I am making any distinctions between hover/select effects... I think the ScatterCharts visual cue, lets call it a tooltip, is actually a hover effect, not a selection effect... Anyway, it is inconsistent with other charts.

As for chartWrapper... My conclusion is it has some bugs still and people are better off instantiating chart elements the normal way, passing options on the constructor.
Reply all
Reply to author
Forward
0 new messages