11 Replies Latest reply on Nov 20, 2017 11:26 AM by Shawn Wallwork

    How to reshape a regular chart?

    Xipu Li

      Just saw this amazing viz. I was wondering if you could tell me how to customise the chart into this shape? I can see it's a bar chart originally, but I don't know how do you make a curve like that.

      Trajectory of a Franchise Dashboard.png

      As well as this one:

      Screen Shot 2017-11-17 at 11.12.21.png


      How to reshape the regular x-y chart into some customised shape?


      Thank you!

        • 1. Re: How to reshape a regular chart?
          Shawn Wallwork


          Download it. Open it and take a look.

          • 2. Re: How to reshape a regular chart?
            Xipu Li

            I did, but still, don't know how to customise the shape.

            I'm new to Tableau, by the way. Is there any tutorial or documentation that cover the visualisation?

            • 3. Re: How to reshape a regular chart?
              Shawn Wallwork

              OK, so this isn't a custom shape. Most charts Tableau produces are essentially Scatter Plots. For instance, Maps are Scatter Plots with a map background. Line charts are Scatter Plots with lines connecting the marks. This chart is no different. She is using math and table calculations to spread marks across the X/Y grid.



              (([Inner] ) + ([Count of year])/[parameter])

              *  (SQRT(2)*

              SIN([Radial - franchise position]  *PI() /180))



              ([Inner] + ([Count of year])/[parameter])



              COS([Radial - franchise position]  *PI() /180))


              In fact these calcs produce nested table calculations. So the level of difficulty is extremely high. Beyond that I can't offer much help.



              2 of 2 people found this helpful
              • 4. Re: How to reshape a regular chart?
                Xipu Li

                Thank you for this thorough explanation.


                Alas, I'm not mathematically sophisticated; a simple circle has thrown me off... I wanted to customise my Scatter Plots to some really complex shapes like this:

                Screen Shot 2017-11-18 at 11.38.39.png


                Don't know if there's any third party tool that can allow you draw your own shape and generate lines of calculations?

                • 6. Re: How to reshape a regular chart?
                  Xipu Li

                  Thanks. That helps!

                  • 7. Re: How to reshape a regular chart?
                    Lilach Manheim

                    Thanks for the question -- I am flattered you wanted to reproduce it.


                    As Shawn Wallwork said, this is definitely towards the higher level of difficulty for custom charts. However, I'm happy to explain how I did it.


                    Data structure:

                    Each one of the circles represents a movie, and each 'row' of circles represents a series. This requires a data structure that is at the level of movie - so 1 row for every movie.

                    I was working with an initial data set that had information on each movie - IMDB score, box office gross, budget, etc. To this data, I joined another data set that listed all the movie franchises, and I added an index column that was like a unique identifier number for each movie franchise, counting up based on the date of each franchise's first movie.


                    So in the final dataset, you basically need the following for each row: movie name, year of movie, movie franchise name, movie franchise ID, plus any other columns you want to include that describe the movies.


                    The calculations & chart:

                    First, I started out with this post from Adam McCann - Dueling Data: How To: Game of Thrones Analysis Viz . He has a really great explanation of how to calculate the circular coordinates when you don't want to actually draw the full circle.


                    For my chart, you need 3 main calculations - angle, x position, and y position.


                    So step one for me was to figure out the angle calculation. This is the angle for each franchise 'row'. To use the clock metaphor, since I wanted my points to go from 9 o'clock to 12 o'clock, that is 25% of the way around the circle, which is 90 (360 * .25). In order to fit all of the franchises in my data into that 90 degrees, I divide 90 by the total number of franchises (using the maximum franchise ID).


                    Note: if you know that you will be using 25 franchises (or whatever other category field in your data), then you could just put in a static number here. However, setting this to the max ID makes it flexible, so the angle calculation would adjust to fit in however many franchises you include.


                    So this angle calculation gets you the number of degrees BETWEEN each franchise, in order for all 25 franchises to fit into that 90 degree arc. In this case it's 3.6 degrees. But, what you actually need for this chart is to get the number of degrees (or position along the arc), of each consecutive franchise. To do this, you just  need to multiply the franchise ID by that 3.6 degree increment (so the first movie is 1*3.6, the second is 2*3.6, etc.). To clean it up a bit more, I actually do the ([franchise ID] -1), so that the starting angle for the first franchise is 0.


                    The final angle calculation:   (avg([Franchise ID] -1)) * (90/total(max([Franchise ID] )))




                    The X and Y calculations are basically just to take those angles, and translate them to x and y coordinates. I can't explain the math to you (there's plenty of articles out there if you really want to do down that rabbit hole), but basically you use SIN and COS to get there. I used a combination of the base calculation that Adam shared in his post, plus one that Neil Richards explained in this post - https://questionsindataviz.com/2017/01/17/how-did-i-create-the-spiral-chart/ .


                    So the 2nd part of the calculation takes the angle from step one, and plugs it into the SIN equation: (SQRT(2) * SIN([Angle] *PI() /180))


                    Then, you need to multiply that by the members of each franchise. So I used the year of each movie to increment over the sequence of each movie within each franchise. The [count of year] is a running total calculation of the number of years in each franchise: running_COUNT(min([Title Year (fix)])). So, for each franchise, the first movie would be movie 1, 2nd movie would be movie 2, etc. Then this count restarts for each new franchise.


                    You can see that in the beginning part of the final calculation:

                              (([Inner] ) + ([Count of year])/[parameter])
                                         * (SQRT(2) * SIN([Radial - franchise position] *PI() /180))




                    You can look inside the workbook to see how the 2 parameters were set up (called  [inner] and [parameter] ) - but once I had both x and y calculated, I just used those parameters to fine tune the shape of the arc.


                    The calculation for Y is exactly the same, except it uses COS instead of SIN.




                    That's the toughest part - I swear


                    The most complicated part of building the chart itself is setting the parameters right on the table calculations. So basically, you drag X to rows, Y to columns, and you drag movie title and franchise to the detail (I do have franchise ID in there but it's not necessary). Then when you set your table calculations, for count of year, you need to set it to restart every Franchise. The angle field doesn't need to restart, because we want it to count across all franchises.


                    Oh, and I created this as a circle mark type, but you could also use shape if you wanted to of course.



                    I hope this explanation helped. It is definitely not for the faint of math hearts though

                    4 of 4 people found this helpful
                    • 8. Re: How to reshape a regular chart?
                      Shawn Wallwork

                      Great explanation Lilach! Tableau Community or Tableau Ambassadors could you copy this over to somewhere for safe keeping? Some appropriate Library.





                      • 9. Re: How to reshape a regular chart?
                        Patrick Van Der Hyde

                        Thanks for the heads up Shawn.  I'll add to places I can find but Lilach Manheim might be interested in adding a workbook and explanations to the Workbook & Calculation Library as well? 



                        • 10. Re: How to reshape a regular chart?
                          Patrick Van Der Hyde

                          Shawn - I went ahead and started up a new FAQ page - FAQ:  Advanced Chart Types 


                          It needs some more content but we have to start somewhere and this is a good start.   Feel free to send me suggestions.



                          1 of 1 people found this helpful
                          • 11. Re: How to reshape a regular chart?
                            Shawn Wallwork

                            Thanks! Will do as I come across them. Don't have a link bookmarked, but the Sankey threads and blogs should be added.