3 Replies Latest reply on Jun 25, 2015 9:36 AM by Michael Kovner

    Retrieving underlying data from mark via Javascript API

    Richard Pineo

      We have a usage case where we need to retrieve the identifiers make up the contents of mark representing a set of objects via the JS API.


      Our situation is that we embed a Tableau Viz in our web site and want to change available content exterior to Tableau based on the selection of a mark which represents a set of records (e.g. clicking on a bar in a histogram).


      It looks like there is no way to do this currently in the API. I've searched the forums and the interwebs to try to find a solution but the only idea I have found that might work is to enumerate the choices in a filter which reflects the current selection. This seems like a hack. Is there a more direct way that we can retrieve the values that are displayed in the 'underlying data' that makes up a mark?


      Attached is a very simple packaged workbook that illustrates what we would like to achieve. The client code would like to retrieve the values (96, 97, 98) when the bar labeled 'Orange' is selected.


      One possible solution is to select all of the records in the bottom worksheet and then enumerate the selected marks in that context. This also feels somewhat like a hack, but more importantly I do not know how to programmatically select all of the marks in the records view.



      Can anyone offer me some guidance as to how to achieve this functionality? We are open to any potential solutions current and future as this is a mission critical capability for our product.


      This is similar to these topics

      Javascript API - Get all marks in a Viz

      javascript select all marks

        • 1. Re: Retrieving underlying data from mark via Javascript API
          Michael Kovner

          Hi Richard,


          There is no function to get underlying data from marks in the jsapi, only the 'summary data' from marks. Your workaround of populating a quick filter and then querying the quick filter is one way. Another workaround I've suggested in the past is to have the row-level data on a text table and have all of the other filtering affect that text table. You can even 'hide' this text table by floating it and making it 1x1 pixels. Now you can call selectMarksAsync on that view, selecting all of the marks, and getSelectedMarksAsync to get the data from it.

          • 2. Re: Retrieving underlying data from mark via Javascript API
            Richard Pineo

            Thanks MIchael -

            I'm investigating how to use the workaround you selected with the floating text table, but am running in to a roadblock when trying to select all the marks on that view using selectMarksAsync.


            How can you select all of the marks? In the JS API reference, the signature of that function takes in which marks should be selected - is there a form that will select all available marks?

            • 3. Re: Retrieving underlying data from mark via Javascript API
              Michael Kovner

              If I remember correctly the filter update type 'ALL' works on applyFilterAsync, but not on selectMarksAsync. So you have to choose a dimension where you know of all of the values and select all of them. To make this easier, you could create a dummy dimension that has only one value and put it on the viz.