9 Replies Latest reply on Aug 14, 2018 1:54 PM by Keshia Rose

    Use javascript api to create a new datapoint / marker

    Aron Spiess

      Is there a function in which the javascript api can place a marker on a chart from input given during the chart's creation?

       

      I've thought about how this could be accomplished in two ways:

       

      1. I currently use the javascript api to create my charts and I've been able to relate chart specific comments from my own backend database comment system.  But now I want to add marks that indicate there's a corresponding comment on a chart for a specific month. 

       

      2. The next best solution I think would be if tableau could reference the sheet name and workbook inside a calculated field, that way tableau could use the database I have and create the markers rather than the api doing it. However I don't see that tableau can reference these without hard coding those values in my formula.

        • 1. Re: Use javascript api to create a new datapoint / marker
          Patrick A Van Der Hyde

          Aron,

           

          I am sharing this around to see if there are any ideas from members of the support team at Tableau.

           

          Patrick 

          • 2. Re: Use javascript api to create a new datapoint / marker
            Keshia Rose

            Hi Aron,

             

            Could you give me some more detail about what you are trying to do? Currently, the JavaScript API cannot create any new data points. Are you just looking to load comments from your database to your marks?

             

            Take care,

            Keshia

            • 3. Re: Use javascript api to create a new datapoint / marker
              Aron Spiess

              We've created a php web portal that helps manage around 100+ tableau charts. Each chart is organized under a department leader in my organization, kind of like a top down org chart with many web pages/branches and layers. Charts are identified using individual sequence numbers from a MySQL database and also reference the tableau sheet name. In cases where a tableau chart is a group of charts, then we just reference the first sheet of the group. Currently, the comments are accessed the same way using the seqno and sheet name. I use Ajax to record and relate a comment to a chart. We have achieved everything except a way to visually show a marker for when a particular comment relates to a particular month. I can display a chart's comments as a list, but ideally it would be great if a marker could indicate a comment had been saved for a particular month. I was hoping the API could create an extra line with markers.

              • 4. Re: Use javascript api to create a new datapoint / marker
                Keshia Rose

                I see, well the JavaScript API cannot create new data points for you, however, you can show your comments from your database by adding that column to your charts. For example, you could connect your comments to a certain month in the data source (maybe an additional column?) and bring that data source into your dashboard. Then your dashboard adds the comment column (which might be empty for now) to tooltips, for example. Once people start commenting, the data will automatically appear in the tooltip specifically for the right month.  Another idea would be to keep the comments outside of the dashboard but update the list when someone selects a month so that the list only contains comments for that month. I think there are a few ways you can accomplish this, but those are just a couple ideas. The point is, the only way to show the comments int he dashboard is for the data connection to already exist in your data source.

                 

                Take care,

                Keshia

                • 5. Re: Use javascript api to create a new datapoint / marker
                  Aron Spiess

                  I understand I can use the database with the comments as a data source, but that would require me to hard code the relation of each comment to its specific chart. What if some of my sheet names have the same name?  My frontend ui knows what chart I'm on through the javascript API but my tableau chart doesn't know what comments to use to display in the chart. Hopefully I'm explaining myself.

                  • 6. Re: Use javascript api to create a new datapoint / marker
                    Keshia Rose

                    **** Aron, you've got me there! Hmm honestly, the only thing I can think of then is to include all comments for all sheets in the data source and use the JavaScript API to filter to the correct comment for the currently displayed sheet. This sounds like an awful idea but I think it would work, not so sure about performance though. I can't think of anyway else to do it.

                     

                    Take care,

                    Keshia

                    1 of 1 people found this helpful
                    • 7. Re: Use javascript api to create a new datapoint / marker
                      Aron Spiess

                      That makes sense! Yes I'm pulling in all the comments but then letting the javascript api do the filtering.  I'll have to see how much of a performance hit that is.  Thanks!!

                      • 8. Re: Use javascript api to create a new datapoint / marker
                        Aron Spiess

                        Another related question. I'm only setup to display an indicator under three conditions: The chart is a run chart, it's displaying a single series, and a single chart is displayed in tableau, I think not a dashboard.

                         

                        Now, let's say I select a data point on a chart, does the api tell me all the possible parameters around that selection. That way I could possibly single out how a comment gets indicated or not.

                        • 9. Re: Use javascript api to create a new datapoint / marker
                          Keshia Rose

                          Sure thing, the API will tell you any fields that are on detail for the worksheet and their values. Take a look at the 8th page in the tutorial for events for an example: JavaScript API Tutorial. Try running the first script then selecting a mark to see an example output.

                           

                          Take care,

                          Keshia