1 Reply Latest reply on Jul 20, 2015 10:53 AM by diego.medrano

    Selecting Marks via JS API doesn't seem to work

    noah.feldman

      Attempts to select a Mark that lies at the intersection of several dimension always fail without error, despite documentation appearing to claim this is possible.

       

      I've experimented with a variety of workbooks, most downloaded from Tableau Public. The example used here is from "Compute Using Example".

       

      Based on the API documentation Selecting Marks and Marks Selection one would think that either of the following would work to select a single Mark:

      sheet.selectMarksAsync({
          "Region": [
              "South"
          ],
          "Ship Mode": [
              "Delivery Truck"
          ],
          "SUM(Sales)": [
              "19.02%"
          ]
          }, tableauSoftware.SelectionUpdateType.ADD
      ).then(successCallback, failureCallback);

      or

      sheet.selectMarksAsync({
          "Region": "South",
          "Ship Mode": "Delivery Truck",
          "SUM(Sales)": "19.02%"
          }, tableauSoftware.SelectionUpdateType.ADD
      ).then(successCallback, failureCallback);

      They do not; although successCallback is called, neither the visible state nor the state reported by getSelectedMarksAsync changes.

       

      The documentation (under Selecting marks) provides this example:

      // Multiple dimensions - multiple values
      // ((State = Washington OR Oregon) AND Product = Lemon)
      // OR
      // (State = Oregon AND Product = Chamomile)
      .then(function () {
          return worksheet.selectMarksAsync({
              "State": ["Washington", "Oregon"],
              "Product": "Lemon"
          }, tableau.SelectionUpdateType.REPLACE);
      })
      .then(function () {
          return worksheet.selectMarksAsync({
              "State": "Oregon",
              "Product": "Chamomile"
          }, tableau.SelectionUpdateType.ADD);
      })

      Yet using an object of key:value or an object of key:value[] pairs as an argument absolutely does not work.

       

      It appears to be impossible to select a Mark, as opposed to sequentially selecting individual field:value pairs, if one does not already have a properly constructed instance of a Mark object. The effect of building a selection pairwise is almost never the same as the effect of the original selection. Given this "mark":

      {
          "Region": "South",
          "Ship Mode": "Delivery Truck",
          "SUM(Sales)": "19.02%"
      }

      sequentially selecting each key:value pair with an updateType of tableauSoftware.SelectionUpdateType.ADD, results in the selection of 7 Marks (which is visible and is reported by getSelectedMarksAsync).

       

      Am I doing it wrong or is this actually impossible? I need to be able to select marks from serialized previous selections, so I cannot assume the presence of Mark objects.