Google表中的多级嵌套饼图

发布于 2025-01-27 11:01:19 字数 1040 浏览 4 评论 0 原文

我需要Google表中的多层嵌套饼图。 显示类别和子类别中的数字总和。可以使用代码或仅公式。

或者,如果类似于Google表的系统已经具有简单的可配置的嵌套派图,则可以考虑使用它。

这是我想结合的2个图表的示例表:

“

它可以类似于这里的相似之处,但是总和而不是计数:

三个Google Sheets的数据图(饼图)

或D3 Sunburst分区。

I need a multi-level nested pie chart in google sheets.
To show number sums in categories and sub-categories. Can use code or just formulas.

Or if a system similar to google sheets already has a easy configurable nested pie-chart I can consider using it.

Here is a sample sheet with 2 charts I want to combine:
https://docs.google.com/spreadsheets/d/1TvOf_tRNFS4zqbYR8EMGfTH1krI_iX9resrQ_AwmGZ8/edit?usp=sharing

data
chart1
chart2

It can be similar to the one here, but with sums instead of counts:

Three Google Sheets' data graphs (pie charts) in one graph

Or a D3 Sunburst Partition.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

长不大的小祸害 2025-02-03 11:01:19

动态FX:

=ARRAYFORMULA({TRANSPOSE(QUERY({A1:C}, "select sum(Col3),Col1 where Col1 is not null group by Col1 label sum(Col3)'Base Pie'"));
 {"♀", IFERROR(1/(1/TRANSPOSE(MMULT(TRANSPOSE(IF(SEQUENCE(COUNTUNIQUE(A2:A))<SEQUENCE(1, COUNTUNIQUE(A2:A)), 
 QUERY({A2:C}, "select sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''"), )*1), SEQUENCE(COUNTUNIQUE(A2:A), 1, 1, )))));
 QUERY(QUERY({A2:C, ROW(A2:A)}, "select Col2,max(Col3) where Col3 is not null group by Col4,Col2 pivot Col1"), "offset 1", )};
 {"♂", IFERROR(1/(1/TRANSPOSE(MMULT(TRANSPOSE(IF(SEQUENCE(COUNTUNIQUE(A2:A))>SEQUENCE(1, COUNTUNIQUE(A2:A)), 
 QUERY({A2:C}, "select sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''"), )*1), SEQUENCE(COUNTUNIQUE(A2:A), 1, 1, )))))}})
  • 该公式在A:C范围内获取数据,并创建所有必要的步骤,列和行,以馈送饼图。

  • 标记的行♀♂用作饼图比率校正器

  • 列E可以用作子类别标签系统(如果需要)

  • 以相同的方式

    第3行可以用作基本派的标签

  • 首先,我们创建了一个基本饼图(来自黑色行),该标签将用作背景:

“在此处输入图像描述”

  • 接下来,对于每个彩色列,我们创建一个单独的饼图,我们覆盖了基本饼图顶部。请注意,需要双击给定的切片并选择颜色或 none ♀的情况下,需要选择每个切片的颜色和子色。 ♂ slices

”在此处输入图像描述”

​src =“ https://i.sstatic.net/72mif.png” alt =“在此处输入图像说明”>

“

​“ https://i.sstatic.net/o2z16.png” rel =“ nofollow noreferrer”>

“在此处输入图像描述”

​“ nofollow noreferrer”> “

dynamic fx:

=ARRAYFORMULA({TRANSPOSE(QUERY({A1:C}, "select sum(Col3),Col1 where Col1 is not null group by Col1 label sum(Col3)'Base Pie'"));
 {"♀", IFERROR(1/(1/TRANSPOSE(MMULT(TRANSPOSE(IF(SEQUENCE(COUNTUNIQUE(A2:A))<SEQUENCE(1, COUNTUNIQUE(A2:A)), 
 QUERY({A2:C}, "select sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''"), )*1), SEQUENCE(COUNTUNIQUE(A2:A), 1, 1, )))));
 QUERY(QUERY({A2:C, ROW(A2:A)}, "select Col2,max(Col3) where Col3 is not null group by Col4,Col2 pivot Col1"), "offset 1", )};
 {"♂", IFERROR(1/(1/TRANSPOSE(MMULT(TRANSPOSE(IF(SEQUENCE(COUNTUNIQUE(A2:A))>SEQUENCE(1, COUNTUNIQUE(A2:A)), 
 QUERY({A2:C}, "select sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''"), )*1), SEQUENCE(COUNTUNIQUE(A2:A), 1, 1, )))))}})
  • the formula takes data in A:C range and creates all necessary steps, columns and rows that will feed pie charts.

  • rows labeled ♀♂ serve as pie chart ratio correctors

  • column E can be used as a subcategory labeling system if needed

  • in the same manner row 3 can be used as labels for base pie

  • first, we create a base pie chart (from the black row) which will serve as background:

enter image description here

  • next, for each colored column we create a separate pie chart that we overlay on top of the base pie chart. note that colors and sub-colors needs to be selected manually for each slice by double-clicking a given slice and selecting either color or none in the case of ♀♂ slices

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

and repeat for the next column...

enter image description here

demo spreadsheet

玉环 2025-02-03 11:01:19

e2:

=QUERY({A2:C}, "select Col1,sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''")

g2:

={FILTER(B2:C, A2:A=E2); "", SUM(FILTER(B2:C, A2:A<>E2))}

i2:

={"", SUM(FILTER(C2:C, A2:A=E2)); FILTER(B2:C, A2:A=E3); "", SUM(FILTER(B2:C, A2:A=E4))}

k2:

={"", SUM(FILTER(B2:C, A2:A<>E4)); FILTER(B2:C, A2:A=E4)}

E2:

=QUERY({A2:C}, "select Col1,sum(Col3) where Col1 is not null group by Col1 label sum(Col3)''")

G2:

={FILTER(B2:C, A2:A=E2); "", SUM(FILTER(B2:C, A2:A<>E2))}

I2:

={"", SUM(FILTER(C2:C, A2:A=E2)); FILTER(B2:C, A2:A=E3); "", SUM(FILTER(B2:C, A2:A=E4))}

K2:

={"", SUM(FILTER(B2:C, A2:A<>E4)); FILTER(B2:C, A2:A=E4)}

enter image description here

demo sheet

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文