Google-sheets – Possible to add a third color to a ‘bar’ sparkline

google sheetsgoogle-sheets-sparkline

I have three columns of data that I want to represent with sparklines as a stacked bar chart.

For instance, a row like

12  5   1

with this formula

=SPARKLINE(C2:E2,{"charttype","bar"})

shows an image like this: Sparkline chart

As you can see, the first and third colors are the same. I would like to specify all three colors, so that the first and third colors are different.

Google's SPARKLINE Help docs indicate bar charts set two colors by default; these can be user specified as color1 and color2. They do not provide any instructions for specifying additional colors.

I have tried specifying color1, color2, AND color3, and I have tried specifying lastcolor; neither option alters the third color. I also tried setting just color, then specifying color1 and color2 as a default, to see if Sheets would default to the setting for color for the third color. That did not work either.

Is there a way to set the 3rd color to be different from the first color?

Best Answer

You may switch the color by add "a3bc9f" (the color code in double citation mark) to change the color.

Like this: =SPARKLINE(B4:C4,{"charttype","bar";"color1",if(B4>C4,"#dd7e6b","a3bc9f");"color2",if(C4>B4,"#dd7e6b","a3bc9f")})