Sparklines堆叠条形颜色选项只允许两种颜色变化?

时间:2015-03-04 14:51:35

标签: google-apps-script google-sheets

我在Google Spreadsheets中使用了迷你图功能。以下是一些数据的示例:

Feb-2015    MTD Actual  MTD Budget  Budget
Campaign 1  $41.32       $13.71   $96.00

我想根据文档here创建堆积条形图迷你图。

=sparkline(D9:F9,{
    "charttype","bar";
    "color1","blue";
    "color2","yellow";
    "color3","red"})

D9:F9对应$ 41.42:$ 96

以下是结果: enter image description here

我原本预计某段会变成红色(color3)。但迷你线似乎只能定制2种颜色。无法在文档中看到有关此内容的任何内容。这是一个错误吗?或者我误解了什么?

如果我只能使用此功能编辑2种颜色,我不认为可以使用Google-Apps-Script编辑功能?

2 个答案:

答案 0 :(得分:3)

如果您想拥有100%的3股水平,这是一个技巧。因此,如果您有3个值的总和为100,请执行以下操作:

从数据单元中删除第3个值。 设置“最大”,“ 100”(或在欧洲设置为“最大” /“ 100”)。 为迷你图单元格创建彩色背景。

这样,用单元格背景表示填充到100的第三个值-它是第三个迷你图颜色。

答案 1 :(得分:2)

条形图只列出了color1和color2选项。迷你图未明确暴露给Apps脚本,但可以作为值写入单元格。例如:

ss.appendRow(['==sparkline(D9:F9,{"charttype","bar";"color1","blue";"color2","yellow";})']);

来自文档: https://support.google.com/docs/answer/3093289?hl=en

For bar charts:

"max" sets the maximum value along the horizontal axis.
"color1" sets the first color used for bars in the chart.
"color2" sets the second color used for bars in the chart.
"empty" sets how to treat empty cells. Possible corresponding values include: "zero" or "ignore".
"nan" sets how to treat cells with non-numeric data. Options are: "convert" and "ignore".
"rtl" determines whether or not the chart is rendered right to left. Options are true or false.
相关问题