This is a stacked bar chart on contribution of sales per segment per month in percentage.
Today we would like to create a radial alternative of the same chart.
The key idea is using Polygon as data mark to generate each color block. And we will use 100 points for drawing the contour of each Polygon, or the path.The steps are as follows:
- Union the data table with itself. This will generate a new column Table Name with two table names.
- Create Point 1 and Point 100 through the two table names.
- Create Bins using Point with step size = 1. These bins will allow us to create 100 points.
- Create IndexPoint which will index the 100 points. Set it to compute along the Point Bins.
- Create IndexMonth which will index the 12 months. Set it to compute along the order date.
- Create Percent field. This is the share of the sales at a particular month. When split by Segment, this will give the percentage of sales in each Segment.
- Sum(Sales)/Sum({Fixed Year(Order Date),Month(Order Date): Sum(Sales)})
- RUNNING_SUM([Percent])
- ZN( LOOKUP([Running Percent],-1))
- IF [IndexPoint]<=50
- THEN WINDOW_MAX( [Running Percent])
- ELSE WINDOW_MAX( [Running Percent Prev])
- END
- Create Parameter: Radius Outer (An integer from 100 and 200) This defines the outer circle size where the radial stacked bar chart resides.
- Create Radius. This defines the radius for every points including inner and outer radius.
- [Radius Inner]+[Radius Outer]*[Running Percent Radial]
- (IF [IndexPoint]<=50
- THEN [IndexPoint]-1
- ELSE 100-[IndexPoint]
- END/50
- +([IndexMonth]-1)
- )* 3.1415926/6
- SIN([Angle])*[Radius]
- COS([Angle])*[Radius]
Thanks for this, Alexander! This is one of the easiest tutorials that I've seen on this type of graph. As I recreated it with my data, I noticed that - despite having a field equivalent to [Month] that is actually 20 items instead of 12 - I only have 12 slices/angles on my chart. Do you have any idea why that is? I don't really see anything in the formulas that would lead to only 12 angles so I'm reaching out to you.
ReplyDeleteHard to tell without open your workbook. If possible, send me your workbook so that I can have a look.
DeleteHello Nicole. I came across the same issue you described and I just found a solution. The thing is that you should set the right angle increase according to the number of "slices" you want. On my dataset I have 148 countries and I want them unique represented on each bar. Thus, on the "Angle" calculated field I adjusted the bars width as following:
Delete(IF [IndexPoint]<=50
THEN [IndexPoint]-1
ELSE 100-[IndexPoint]
END/50
+([IndexMonth]-1)
) * RADIANS(2,432432)
This 2,432 degrees angle comes from 360°/148
In your case, 360°/20 = 18°. So make it *RADIANS(18).
On Mr. Mou tutorial, since he wants to divide the circle on 12 slices:
pi = 3,1415 = 180° --> 360°/12 = 2*pi/12 = pi/6
Excellent tutorial btw, thank you Alexander.
Hi Alexander, great tutorial you have here. I have 2 questions:
ReplyDelete1. How did you get the month labels to line up outside the circle? Mine are overlapped at the edge of the circle and I can't seem to change them
2. How would you go about a current YTD showing to say August and then the remaining months display the previous year?
1.You can drag the labels and place them to where you like.
Delete2.Use a rolling 12-month worth of data and you will have a full circle.
Thanks, Alexander. Unfortunately, I can't reproduce your results even when I use your workbook and carefully follow the video tutorial to construct the "Radial Stacked Bars" sheet from scratch. I see only two marks per segment per month when marks are automatic and a blank sheet when I select polygon. Is there a subtle configuration change that I am missing?
DeleteThe key is probably the Bins. Make sure they are in the view.
DeleteI can't reproduce your results even when I use your workbook and carefully follow the video tutorial to construct the "Radial Stacked Bars" sheet from scratch. I see only two marks per segment per month when marks are automatic and a blank sheet when I select polygon. Is there a subtle configuration change that I am missing?
DeleteThe remedy:
Delete1.Create a calculated field INDEX = Index()
2.Place this in the Detail card
3.Set it to compute along the Bins
Great tutorial but I think that the title needs to be a bit more descriptive like Creating Radial Stacked Bar Chart using ... (like HTML5, charts.js etc.) so the right person lands on this page
ReplyDeleteFixed. Thanks for the suggestion!
Delete