
之前为大家分享了 🌰:学做径向柱状图(Radial Column Chart)。在此基础上,我们又做了进一步的延展:径向 WIFI 信号图。
它的用法和径向柱状图一致,区别在于它将柱体分切成多个弧线(内短外长),通过高亮弧线数量,能更直观的比较数值大小。

如何在 Tableau 中具体实现呢?今天的栗子,一睹为快吧!
本期《举个栗子》,我们要给大家分享的 Tableau 技巧是:创建径向 WIFI 信号图
为方便学习,栗子使用 Tableau 自带的“Sample-Superstore”数据源。掌握栗子方法后,数据粉可尝试使用其他数据源。
具体步骤如下:
1
连接数据
打开 Tableau Desktop,连接“Sample-Superstore”数据源。在数据源页面,创建关联数据源。复制下方文本并粘贴(Ctrl+V)在视图右侧,会自动生成新表。
Path,Distance
100,1
0,1
100,0
0,0
选择内部联接,通过自定义计算设置表的关联条件为:1。

2
创建参数和计算字段
新建工作表,创建参数。
➤ 参数:@Distance from Center,数据类型选整数,当前值 5,允许值全部

➤ 参数:@Line Weight,数据类型选浮点,当前值 0.01,允许值范围,最小值 0.01,最大值 0.1,步长 0.01

➤ 参数:@Path Factor,数据类型选整数,当前值 20,允许值范围,最小值 5,最大值 100

➤ 参数:@Spacing,数据类型选整数,当前值 20,允许值范围,最小值 20,最大值 100,步长 10

右键单击“Path”字段,选择创建数据桶。数据桶大小选择参数 @Path Factor

右键单击“Distance”字段,选择创建数据桶。数据桶大小选择参数 @Line Weight

➤ 计算字段:Order Month,键入函数
DATEPART('month',[Order Date])

➤ 计算字段:Index (Distance),键入函数
INDEX()

➤ 计算字段:Index (Path),键入函数
(INDEX()-1) * [@Path Factor]

➤ 计算字段:Step Size,键入函数
3.6 / 12 * (100-[@Spacing]) / 100

➤ 计算字段:TC_Order Month,键入函数
WINDOW_MAX(MAX([Order Month]))

➤ 计算字段:TC_Sales,键入函数
WINDOW_SUM(SUM([Sales]))/4

➤ 计算字段:TC_Total Sales,键入函数
WINDOW_SUM(SUM([Sales]))/4

➤ 计算字段:TC_Percentage,键入函数
[TC_Sales] / [TC_Total Sales]

➤ 计算字段:TC_Starting Point,键入函数
(([TC_Order Month]-1)*360/12)

➤ 计算字段:x,键入函数
SIN(RADIANS(([Index (Path)]*[Step Size])+[TC_Starting Point]))*([Index (Distance)]+[@Distance from Center])

➤ 计算字段:y,键入函数
COS(RADIANS(([Index (Path)]*[Step Size])+[TC_Starting Point]))*([Index (Distance)]+[@Distance from Center])

➤ 计算字段:TC_Size,键入函数
IF ([Index (Distance)]-1) / WINDOW_MAX([Index (Distance)]-1) <= WINDOW_MAX([TC_Percentage])
THEN 1
ELSE0
END

➤ 计算字段:TC_Color,键入函数
IF ([Index (Distance)]-1) / WINDOW_MAX([Index (Distance)]-1) <= [TC_Percentage]
THEN WINDOW_MAX(MAX([Order Month]))
ELSE NULL
END

➤ 计算字段:TC_Filter,键入函数
IF ([Index (Distance)]-1) / WINDOW_MAX([Index (Distance)]-1) <= WINDOW_MAX([TC_Percentage])
THENTRUE
ELSEFALSE
END

3
创建视图
将字段“Order Date”拖放至“筛选器”卡,弹窗中选择离散的年,然后勾选:2023。

将字段“Order Month”、“Distance (数据桶)”、“Path (数据桶)”依次拖放至“标记”卡的详细信息中。右键单击“标记”卡中的“Order Month”胶囊,将其转为维度,并设置离散。
然后,将字段“x”拖放至列,"y"拖放至行。再右键单击这两个胶囊,下拉菜单均选择:计算依据 - Path (数据桶)。将“标记”卡的标记类型改为:线,完成视图如下:

将字段“Distance (数据桶)”和“Path (数据桶)”分别拖放至列,再分别右键单击这两个胶囊,下拉菜单均勾选:显示缺失值。然后,将这两个胶囊拖放至“标记”卡的详细信息中。

右键单击列上的“x”胶囊,下拉菜单选择:编辑表计算,弹窗中如图设置。然后,右键单击行上的“y”胶囊,进行同样的嵌套表计算设置。
注意:请确保“特定维度”中的字段顺序与图片保持一致!



完成后的视图如下:

将字段“TC_Color”拖放至“标记”卡的颜色中,再右键单击该胶囊,下拉菜单勾选:离散。再右键单击该胶囊,下拉菜单选择:编辑表计算,弹窗中如图设置。
注意:请确保“特定维度”中的字段顺序与图片保持一致!




将字段“TC_Size”拖放至“标记”卡的大小中,再右键单击该胶囊,下拉菜单勾选:离散。再右键单击该胶囊,下拉菜单选择:编辑表计算,弹窗中如图设置。
注意:请确保“特定维度”中的字段顺序与图片保持一致!




将字段“TC_Filter”拖放至“标记”卡的详细信息中,右键单击该胶囊,下拉菜单选择:编辑表计算,弹窗中如图设置。
注意:请确保“特定维度”中的字段顺序与图片保持一致!




接着,将“标记”卡中的“TC_Filter”胶囊拖放至“筛选器”卡,弹窗勾选:真。

将字段“TC_Sales”和“TC_Percentage”拖放至“标记”卡的工具提示中,并按需调整其大小。
最后,打开菜单栏的“设置格式”选项,去掉多余的边界、线和轴刻度。如此,就完成我们想要的径向 WIFI 信号图啦!

本期的 Tableau 技巧,你 Get 到了吗?
下一期,再见~

文章部分信息来源于网络,如有侵权请告知
网友评论