简体   繁体   中英

Tableau Javascript API

Can you explain the functions below:

  1. viz = new tableau.Viz(containerDiv, url, options);

  2.  function listenToMarksSelection() { viz.addEventListener(tableau.TableauEventName.MARKS_SELECTION, onMarksSelection); }
  3. function onMarksSelection(marksEvent) { return marksEvent.getMarksAsync().then(reportSelectedMarks); }

  4. function reportSelectedMarks(marks) {

    var html = "";

     for (var markIndex = 0; markIndex < marks.length; markIndex++) { var pairs = marks[markIndex].getPairs(); html += "<b>Mark " + markIndex + ":</b><ul>"; for (var pairIndex = 0; pairIndex < pairs.length; pairIndex++) { var pair = pairs[pairIndex]; html += "<li><b>Field Name:</b> " + pair.fieldName; html += "<br/><b>Value:</b> " + pair.formattedValue + "</li>"; } } }
  1. This function just listen the selected mark

  2. This one throw the selection in reportSelectedMarks

  3. It take the marks and write it in an HTML file in a '<'li'>'. The fieldname would probably be a String and in the value it depend what you are workin with.

So basically these functions would be useful to dynamically print a selected mark on a graph or something like that and print a fielname and a value for that one.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM